<> Navigation: * [[AJMPublic/teaching/scm-lab|SCM Wiki page]] * [[AJMPublic/teaching/arduino-pi/projects/arduino/getting-started|Arduino: Getting Started page]] = BOE Bot = {{attachment:whiskerbot.jpg||width=400}} The Board Of Education robot (BOE Bot) is an Arduino-based self-navigating robot that can be constructed to sense the world with touch, visible light and infrared light. You can make it navigate mazes, detect edges, follow paths and detect and follow other BOE Bots. Have a look at the following examples on Youtube: * Here's the simplest version of the robot: [[http://www.youtube.com/watch?v=FcTAQok9GfQ|Navigation with whiskers.]] * Here we have two robots: [[http://www.youtube.com/watch?v=CDuMIQ24OqU|one following the other.]] They use IR light and sensors for detection. == Aims of the experiment == Today much of science and technology relies on using computers to process and make sense of large bodies of data. This often requires a knowledge of programming languages like C, C++ and Python. But programming on its own can be intimidating and even (to some) boring. In this cool experiment we will combine hands-on electronics and robotics with programming to actually see the results of our programs. You will learn how to use and program the Arduino microcontroller which forms the brains of the BOE Bot. The Arduino is a simple but powerful microcontroller that can accept various forms of input (from sensors) and process the inputs (using the program - this is where you come in) to produce outputs (that is, control the robot). By the end of the experiment you will know how to use and program the Arduino, the basics of electronics (resistors, diodes, photo transistors) and will know enough to get you going onto your own projects. == Assessment == The assessement of this experiment is rather different from any of the others you will have done in the SCM laboratory. There is no error analysis or data collection in the usual sense. Instead the focus here is on programming and the development of algorithms to control the robot. Therefore, you will be assessed on * Your description of the algorithms: this is a high-level description that must be done in the text of the report. * Comments in the programs that describe what the program is doing. * A description of the modifications you have made, why you made them, and what their effects (if any) were. * You will need to describe each stage in the robot's construction and development. * Each section below includes an Assessment sub-section describing what is essential for your report. * Each section contains challenges which include questions, exercises and projects. In most cases you will need to do the exercises only. Solutions are also provided, but these are meant as a guide and learning aid. Your solution and description must be made in your own words. Any programs included here must be well commented. {{{#!wiki note Note //Should you include programs in your report? // If you do so, the report will become very long indeed. But you do need to include the important bits of the programs you have used. //How do you know which bits of the programs to include? // The parts needed to make your point are all that you need. Do you really need the definitions of all variables? Or the setup() portion? Often not. Often all you will need is to say something along the lines: the following function was used to read out the phototransistors....followed by snippit of the function...and an explanation of how it works. For an example of how to quote only small portions of the program see [[http://learn.parallax.com/node/243|the examples on this page]]. ([[attachment:how_to_quote_and_comment_programs.pdf|click here for a PDF version]]) Try to be as concise as you can. Remember that the report must be between 8 to 12 pages only! }}} {{{#!wiki important Important Structure of your report: Your report should be broadly structured as follows: * '''Theory''': There is no theory as such. This is a programming exercise, so your Theory section should describe the elements of programming that you have learnt during the course of this experiment. Use short snippets of code to illustrate the different structures. Start from the overall structure of an Arduino sketch. * '''Experimental setup''': This would include the Arduino, the BOE bot, and related circuits. * '''Results''': These would include the data you have been asked to record below. But unlike the other experiments you have done, you are expected to describe the working of some programs. * '''Error Analysis''': There is none. Instead the marks usually allocated to this will be distributed to the Results section. * '''Conclusions''': This I leave to you. What was this experiment all about? What happened? What did you learn? What were the results of the exercises? Where do you see this lead? What's the point of programming in the context of a Physics laboratory? What are the applications of microcontrollers? What are the strengths and limitations of the Arduino? These are only some questions you will want to consider. No doubt you will find others. }}} == The BOE Bot == We will be partially assembling your BOE Bot. Yes, it is more fun assembling it on your own, but we don't have time for everything. So what you should see is something like the BOT on the right (but without the LEDs and resistors): {{attachment:boebot-assembled-1.jpg||width=500}} The Arduino board hangs under the BOE shield (add-on boards to the Arduino are called //shields// - perhaps because that is what they do: they shield the microcontroller from the World). === Getting started with the BOE shield === Have a good look at the BOE shield. This is where you will connect all components. It is the board sitting above the Arduino. The shield contains a number of Input/Output (I/O) pins (black) with numbers. Also present is a white //proto-typing// area which is where all the components will go. We will no go through a series of activities. You must get through these in sequence. * Our first activity will be to [[http://learn.parallax.com/node/172|build and test the LED indicator lights]]. We will learn how to use the BOE shield, the breadboard and LEDs, resistors etc. You may already know much of the information on these websites. If so, skip the bits you know, but make sure you do not miss any important steps or exercises. * Next we start to [[http://learn.parallax.com/node/178|control the servo motors]]. Since these motors have already been built into the BOE Bot, you will not see the servo //horns// move, but rather, you will see the Bot wheels move. Make sure that the Bot does not roll off the table as this will break it! * [[http://learn.parallax.com/node/185|Center the servos.]] * [[http://learn.parallax.com/node/186|Test them.]] * All done? Go to the [[http://learn.parallax.com/node/189|Challenges section]] and see how you fare. You must do exercise 3. The rest are optional. {{{#!wiki important Important '''Assessment''' * Brief description of the steps you have taken and the results of this section. Start with the aims of this section. * Solve the three exercises in the [[http://learn.parallax.com/node/189|Challenges section]]. Your report should include a detailed description of the '''third exercise only'''. This must be in your own words and not a cut-and-paste from the website. * Include any relevant circuit diagrams and programs. Remember to include comments in your programs. }}} === Assemble and Test the BOE Bot === {{attachment:boebot-led-indicators-1.png||width=300}} You are nearly ready for some real robotics, but we first need to test the BOE Bot to make sure all is well. The Bot has already been assembled for you, but it has likely not been tested. Make sure you get through all activities in this section before proceeding. * [[http://learn.parallax.com/node/193|Assembling the BOE Bot]] (SKIP as we have already done the assembly for you) * [[http://learn.parallax.com/node/200|Re-test the Servos]] (a quick test to make sure the servos have been correctly set up) * [[http://learn.parallax.com/node/203|Start, re-set indicator]] * [[http://learn.parallax.com/node/207|Test speed control]] Record and plot the transfer curve data. All done? Take the [[http://learn.parallax.com/node/211|Challenge]]. Solve Exercises 1 and 2. {{{#!wiki important Important '''Assessment''' * The data table and plot of the transfer curve for the servos. }}} {{{#!wiki warning Warning You should have finished all parts to this point by the end of week 1. Have you got: * Data for the transfer curve? * Notes for the elements of the programs so you can describe the working of the programs? * }}} === Navigation === {{attachment:boebot-maneuvers-1.jpg||width=300}} In this section you will learn how to control the BOE Bot using more advanced programming techniques. Work through as many activities as you can (time permitting) and try and understand the programming methods the tutorials explain. By the end of this section you should have a good understanding of functions in C and should be able to get the BOE Bot to maneuver in well-defined ways. * [[http://learn.parallax.com/node/217|Basic maneuvers]] * [[http://learn.parallax.com/node/220|Tuning the maneuvers]] * [[http://learn.parallax.com/node/222|Calculating distances]] Describe the results of this section in brief. * [[http://learn.parallax.com/node/223|Ramping]] Include the code you have used for the ramping procedure. As always, comments are needed! * [[http://learn.parallax.com/node/224|Using Functions]] This is a very important section as you will learn how to use functions here. Provide a concise, but clear description of the final code with a description of how functions work. * [[http://learn.parallax.com/ManeuverFunction|Custom Maneuver Function]] Also very important as this function will be used later. Describe how the maneuver function works. * [[http://learn.parallax.com/node/228|Maneuver with Arrays]] This will introduce you to arrays. Done? Go to the [[http://learn.parallax.com/node/232|Summary and Challenges]]. Do exercise 3 only. {{{#!wiki important Important '''Assessment''' * A description (with a commented program) of functions. In particular the maneuver function. * Include a detailed solution to exercise 3 only. As always, this should include the program and a description (in your own words) of what the program does in each stage. }}} === Maneuver with Tactile Sensors === {{attachment:whiskerbot.jpg||width=200}} This is the stage we have been working up to: An autonomous robot capable of moving around and self-navigating. Go to the [[http://learn.parallax.com/node/235|Tactile Navigation]] page and try out all four activities. Links to these are also provided below: * [[http://learn.parallax.com/node/236|Build and test the whiskers]] * [[http://learn.parallax.com/node/240|Inlcude the LEDs and field-test it all]] * [[http://learn.parallax.com/node/241|Navigate with the whiskers]] * [[http://learn.parallax.com/node/242|A bit of Artificial Intelligence to get out of corners]] Don't forget the [[http://learn.parallax.com/node/244|Challenges]] at the end and do exercises 3 and 4 only. Did you manage to get your BOE Bot to get out of corners? This is probably the hardest thing to get right. Ever seen insects unable to get out of a window? The BOE Bot behaves like that when in a corner. Play around with the code to build in a bit of atrifical intelligence to make it recognise a corner and get out of one. {{{#!wiki important Important '''Assessment''' * A description of the robot and how it senses its environment. * A detailed description of the algorithm used to get out of corners. How does it work? Can you think of a way of improving it? * Solutions to exercises 3 and 4. Relevant parts of the program and a description. }}} {{{#!wiki warning Warning You should have finished or almost finished all parts till here by the end of week 2. }}} === Navigation with visible light sensors === {{attachment:boebot-phototransistors.jpg||width=300}} Navigation with whiskers is neat but not too exciting. It's like walking around blindfolded, with your arms extended out like the whiskers are. You can get around, but it would be nicer to //see// what's around. This is where the phototransistors come in. They allow the BOE Bot to sense light levels around the room and navigate towards the light, or away from it. It is even possible to get the Bot to circle a light - exactly the way phototactic insects like moths circle ceiling lights. We will do all the activities in the [[http://learn.parallax.com/ShieldRobot/LightSensors|Photo-Navigation section]]. These are also listed below. * [[http://learn.parallax.com/lightspectrum|What is a phototransistor?]] Make sure you read this. * [[http://learn.parallax.com/node/255|Activity 1: Navigation with a single phototransistor.]] Get to the stage where your Bot is able to stop under a bright light. Describe the program and circuit you have used to achieve this. This circuit uses a single phototransistor. You can't use only one for real navigation. Also, the way in which this circuit is designed makes it quite sensitive to the light level in the room. Take it to another room with a different light level and it may not work as expected. The next activity fixes this problem. * [[http://learn.parallax.com/node/260|Activity 2: Measure light over a large range.]] This is an important part of this project. Here we use two phototransistors in what is called a //charge-transfer circuit// to allow the Bot to see in a wide range of lighting scenarios. * [[http://learn.parallax.com/node/264|Activity 3: Measure light levels for roaming.]] Here we get to use a neat algorithm to use the outputs of the phototransistors to navigate. This will be tested using a graphical display, which is really quite neat! * [[http://learn.parallax.com/node/266|A light roaming routine.]] The Bot won't move just yet, but you need to get through this step to see what the sketch does. Test it and try to understand how it works. * [[http://learn.parallax.com/node/267|Navigation by Light.]] Finally get the Bot to auto-navigate using light. * [[http://learn.parallax.com/node/268|Challenges]] : Solve project 2: get the robot to seek shade rather than light. {{{#!wiki important Important '''Assessment''' * Describe how you used a single photo transistor to get the robot to detect light and stop under a bright light. Circuit diagram and program needed. * How does a charge-transfer circuit work? What are the principles involved? Circuit diagram needed here. How does the program work? * How do you get the robot to navigate under different lighting conditions? How does the code adapt to differnt conditions? Can you think of any weaknesses in the code? * Provide an example of a graphical display of the light measurement from the two photo transistors. * Provide the code you have used to get the robot to navigate with light. Make sure it is well commented. You may provide the code in sections, with textual descriptions of each section. * Solve project 2: Get the robot to seek shade rather than light. How did you achieve this? Provide a clear explanation. }}} {{{#!wiki tip Tip Final Challenge: Navigation with both whiskers and light sensors Can you now combine the whiskers and phototransistors to allow the robot to navigate with light (using the phototransistors) as well as the whiskers? This is a useful combination when it encounters light reflected off a barrier: the phototransistors alone will cause the Bot to go towards the reflected light, but the whiskers would be able to tell it that it can't get through. You will need to * combine the two circuits. Plan it so that all components fit on the small bread board. * combine the two programs: The navigation with whiskers program will need to be combined with the light navigation program. Since this can be tricky, [[AJMPublic/teaching/arduino-pi/projects/arduino/boe-bot/whiskers-visible-light-code|I have put a sample program here]]. You will find hints included in the program. Feel free to edit it. Bear in mind that this program must be made consistent with the circuit layout you decide upon. Once you are done, show the result to your lab demonstrator. Take a photo of the setup. If you have modified the program, save a copy and include the relevant portion in your report. Make sure you explain clearly what you have done using suitable comments. The code is long so please do not include all of it and try to keep most of it in an Appendix. As with all programs, you need to explain how it works. This needs to be a high-level, algorithmic description. It should not be too long! In your lab report you will need to display a clear circuit diagram of the circuit used (this should be the schematic circuit diagram, not a photo of the circuit! You can sketch the circuit diagram and photograph it, but make sure it is a clear and well-labeled sketch.) for the combined whiskers and phototransistor navigation. }}} {{{#!wiki warning Warning The assessed part of your lab ends here. Proceed to the next step (which is optional!) only if you have completed all parts of above, assessed portion! }}} === Navigation with IR === The final stage in the development of the robot is to get it to navigate with infrared light emmitters and sensors. As we shall see, these behave like long-range whiskers. We will now be able to get the robot to detect the edge of a table (risky and will will instead use black take to simulate the edge) and, optionally, to follow another robot around. If you finish the required parts of this section early, you could attempt to get the robot to navigate a maze (we will have a competition) and perhaps even to follow another robot. We will attempt all activities in the [[http://learn.parallax.com/node/299|Navigating with IR]] section. These are listed here: * [[http://learn.parallax.com/node/300|Infrared light basics]] * [[http://learn.parallax.com/node/301|Build and test the IR detectors]] * [[http://learn.parallax.com/node/303|Field testing]] Here we use LEDs to signal the detection (recall that we cannot see in the infrared so we use the LEDs to indicate a detection). * [[http://learn.parallax.com/node/305|Range-detection measurements]] Can we control the intensity of the IR light to control the range of the IR detection? Make a table of your measurements. Take multiple measurements to get reliable results. * [[http://learn.parallax.com/node/306|Object detection and avoidance]] Notice that this program is very similar to what we had used for navigation with whiskers. * [[http://learn.parallax.com/node/307|High-performance navigation]] Here we improve the code to make it more suitable for naviation with the IR LEDs and sensors. This marks the formal end of this laboratory. All other parts are optional and should be attempted only if you have completed all the essential parts! * [[http://learn.parallax.com/node/308|Drop-off detection]] Get the robot to detect the edge of a table simulated with black tape. Make sure that you do not test this at the actual table edge!!! * [[http://learn.parallax.com/node/311|Challenges]] Attempt project #2. {{{#!wiki tip Tip Maze navigation If time permits (and you get to this stage!) we will have a maze navigation competition. This can be tricky. You will need to really understand what your robot is doing to get it to navigate in the confines of a maze. }}} === IR and visible light navigation (optional) === It is possible to combine the IR and visible light navigation codes and hardware. With this, you could make a robot that used visible light to look for bright (or dark) areas, but which switched to IR navigation if obstacles were detected. (This is optional.) My code for [[AJMPublic/teaching/arduino-pi/projects/arduino/boe-bot/IR-visible-code-1-AJM|IR and visible navigation]] is here. You may want to compare codes. Which one is more efficient and robust? == SKIP THIS == == The Arduino == {{attachment:arduinounotop.jpg||width=300}} You will first need to learn a little about this microcontroller. This is best done by using it to build a few projects: 1. [[http://learn.adafruit.com/adafruit-arduino-lesson-1-blink/overview|Blink]], (dead easy - mainly a way to test to see if your setup works) ([[attachment:adafruit-arduino-lesson-1-blink.pdf|PDF]]) 1. [[http://learn.adafruit.com/adafruit-arduino-lesson-2-leds|Control a single LED]] ([[attachment:adafruit-arduino-lesson-2-leds.pdf|PDF]]), 1. [[http://learn.adafruit.com/adafruit-arduino-lesson-6-digital-inputs|Digital Inputs]] ([[attachment:adafruit-arduino-lesson-6-digital-inputs.pdf|PDF]]). There is more information and more ideas for projects on the [[AJMPublic/teaching/arduino-pi/projects/arduino/getting-started|Arduino page]]. Additionally, you will find links to the C-language reference and other useful information. So have a look there. Try to understand what the programs - called //sketches// in Arduino lingo - do and how they achieve the behaviour. When you are comfortable with those get back the BOE Bot. {{{#!wiki important Important '''Assessment''' * You do not need to describe these experiments in your report. But you do need to (briefly) describe what an Arduino is and how we communicate with it using I/O pins and a sketch. Don't spend too much time on this. The main aim here is to introduce you to the Arduino and the basic elements of programming this microcontroller. }}}