Topics
Check out America’s #1 technology camp. During this weeklong, day and overnight program, ages 7-17 build robots, create video games, design websites with Flash®, film digital movies, learn programming and more. With one computer per student and an average of six students per staff, students are given the attention they need to excel and take home a project at the end of the weeklong course. Programs are located at over 50 prestigious universities in 23 states, including Stanford, Brown, Columbia, MIT, Northwestern, Georgetown, Emory and more. Special Teen programs include: iD Gaming Academy iD Film Academy and a Study Abroad program in Spain. Spaces fill quickly so visit www.internalDrive.com <http://www.internaldrive.com/> for more details and online specials. You can also call 1-888-709-TECH (8324). Mention promo code WD43 to save.
Educational Robotics: Article 2 – “What makes a Robot a Robot?”
by James Isom
-->Article 1: "Building Eddie"
Are you LEGO® Smart™? Are your students? Being LEGO Smart is more than building with LEGO® bricks. It’s having the ability to work in teams, solve problems, and create solutions. It means understanding key science, technology, engineering, and math concepts – not just on paper, but through demonstration. LEGO Smart students don’t just know it, they DO it. The sets, software, and curriculum designed by LEGO Education harness the power of the LEGO brick and combine to create learning opportunities for students that will help develop the skills needed for a lifetime of creating, solving, and contributing to a global society. Be LEGO Smart – be the future.
This month we are going to explore a little about what makes a robot a robot. We’ll add our first sensor to Eddie and learn how to write a program that allows Eddie to roam around the room by itself.
What makes a Robot a Robot?
Robots surround us. You most likely encounter a robot or some kind of robotic system almost everyday in your normal wanderings. They’re at the grocery store opening doors for you, at the bank spitting out money or in outer space roaming around alien terrain (OK maybe you won’t run into that one). Movies have made them famous and left most people with the impression that a robot must be a gilded android or a patchwork painted garbage can on wheels that bleeps and whistles and is somehow highly coveted by little hooded grumpy men with glowing eyes! Boo-tee-nee! It leaves us to wonder what exactly is a robot anyway.
There is quite a bit of debate over this subject and no definite answers. There have been so many things over the years called robots that everyone has a different opinion of what one should be. In my opinion, I think the best definition is the following:
Ro-bot (n.)
An automated machine that senses the environment around it and uses that information to make decisions based on its program to react appropriately.
The process a robot goes through in order to sense and react to its environment can be broken down into three simple steps:
When designing and building a robot it is important to keep these steps in mind.
How is the robot going to sense its environment? What should it do when it senses something? What instructions do we need to give it to carry out its goal?
We’ll go over this all again in more detail in a bit when we start to program, but first we need to build our first sensor for Eddie.
A touch sensor, as the name implies, tells the robot when it is touching something. They are often used on robots in bumpers, grippers or counting devices. A touch sensor consists of simple mechanism, in our case a button, that when pressed sends a signal to the RCX. This is called a “binary” sensor because it has two states, “on/off, in/out, open/closed, 0/1, you get the picture.
How it works: When the touch sensor is pressed in completes a circuit that allows an electrical signal to flow back to the RCX. This electrical signal indicates that the touch sensor is pressed in.
Now that we know how a touch sensor works let’s build one (actually two that we will use as one) for Eddie. Follow the steps below to build the sensor. As always parts from previous steps are turned white to help distinguish where new parts should be placed. I’ll see you on the other side where we will learn how to program.
Step 1: Place the two axle pins in the first and last hole of the 1 x 12 beam.
Step 2: Arrange the 1 x 2, 2 x 2, and 1 x 6 plates as shown in the picture. Make sure that one stud of the 2 x 2 and 1 x 2 plate is hanging off the beam.
Step 3: Place the touch sensor on top of the 1 x 2 and 2 x 2 plates.
Step 4: Attach what you’ve built so far to the side of Eddie by placing the two axel pins sticking out of the beam into the green cross hole bricks above the two tires.
Step 5: Attach a short wire to the 4 studs closest to the touch sensor button. Attach the other end to port 2 (the center grey sensor pad) on the RCX.
Step 6: Place a 2 x 2 plate on top of the wire connector. Connect to 1 x 6 plates to the top of a 2 x 6 plate and place the assembly on top of the 1 x 12 beam that runs the length of Eddie.
Step 7: Place one more 2 x 6 plate on top of the stack of plates from the previous step.
Step 8: Place the 1 x 8 beam on the left edge of the stack of plates. Insert a 3/4 pin short side out into the 3rd hole from the front in the top most beam and the in the beam just over the front tires.
Step 9: Slide the straight end of a double bent lift arm into the gap between the stack of plates and the beam below and secure it by placing a 1 x 5 lift arm onto the two 3/4 pins.
Step 10: Insert a black friction pin in the fourth hole from the front of both beams on either side of the new lift arm and place a gray technic pin in the last hole of the yellow double bent lift arm. String a white rubber band between the two black friction pins so the front part of the band pushes the pin against the 1 x5 lift arm.
Step 11: Insert a 1 x 6 axle in the bottom cross hole of the yellow lift arm.
Step 12: Place a 1 x 3 lift arm on either side of the 1 x 6 axle and insert the final 1 x 8 axel in the bottom cross hole.
Step 13: Mirror the process for the other side of the robot. Place the wire connector from the sensor on top of the connector already attached to sensor pad 2.
Step 14: Attach the two sensor mechanisms together by placing a piece of tubing between the two inside ends of the 1 x 6 axles.
Congratulations you’re finished, at least for the moment. We have taken a rather lengthy route to make a single touch sensor for Eddie. The reason for doing this is because I want to cover both single and double touch sensor programming in this article and as you shall soon see with a minimum amount of reconfiguring we can easily switch from a single to a double sensor robot. So let’s get to it.
Programming your robot:
There are many ways to program a robot. The RCX alone has over a dozen programming languages available for it, ranging from the software that comes with the retail version of the Robotics Invention System (commonly called RIS 2.0) to more traditional environments like C, Forth, and JAVA. For more information about programming options available for the RCX have a look at the Downloads and Links pages on my website at: http://www.legoedwest.com.
I will be using Robolab for these tutorials. Robolab was developed at Tufts University and is sold by the LEGO’s educational division - Pitsco here in the U.S. Robolab is a symbolic programming language that uses icons instead of syntax, allowing the first time programmer to concentrate on the logic of the program without the need to learn confusing syntax. I like it because it’s easy to use, cross platform (Mac and PC), affordable, and after a couple of year’s of teaching with it I’m still learning cool new stuff about it.
Our goal is to write a simple program that allows Eddie to roam around a room avoiding obstacles. To do this we need to tell our robot what to do when it runs into an object. We already know that when a touch sensor is pressed in it sends a signal to the RCX. Previously we said that it was important to remember three steps. Input, Program, Output. Our input is the signal from the touch sensor. Our program will watch for this input and then change the direction of our outputs (the motors – sometimes called “actuators”) to run an escape routine.
So what’s program? A program is the set of steps the robot needs to follow in order to complete its goal. All programs from the computer games you play to the one that tells the Mars rover to examine a specific rock are all just a series of steps. These instructions are sometimes called an “Algorithm”. It helps when designing a new algorithm for our robot to write it out first before we start programming. To start we could make a brief outline of the steps.
This isn’t very specific but it has the essential set of instructions that our robot needs to achieve its goal. We can get more specific by looking at where our sensors and motors are attached to the RCX. Our touch sensors are connected to sensor port 2 and we have motors connected to power ports A and C. So given that information out outline might look like:
or different still…
turn on motors A and C
if (touch sensor_2 = pressed) then
turn on motors A and C backward for 1 second
turn on motors A and C in opposite directions for 1 second
else
repeat forever
This is all called “pseudo code” and is often used by programmers to get their idea for a program down quickly.
Another way to do this is with a flow chart sometimes seeing your program makes it easier to understand.
The blue diamond is a decision structure; by answering the question inside of it the program decides to do one of two things. If the answer is “NO” it goes back to the beginning and keeps going forward. If it’s “YES” it performs an escape routine by backing up and turning before wrapping back around to go forward again.
In Robolab there are two levels that we are going to be initially concerned with – PILOT and INVENTOR. PILOT programming is based on a series of templates that represent steps in a program. If this is your first time using Robolab take some time and go through the tutorial exercises that come with the program to learn the basics of using the system. When you’re ready open up PILOT level 4 and let’s get started.
According to our pseudo code our first step is to have the robot go forward until the touch sensor on port 2 is pressed in. Our first step would look like this:
After the touch sensor is pressed in the program proceeds to Step 2 which is to back up for one second.
After the one second driving the motors backwards it’s time to make our turn.
Look at Step 3, the pink arrow with the line following it
towards the bottom of the screen means the program will run from the green light to the red light and stop. If we were to download and run our program now it would encounter its first object, back up, turn then stop. We need to change the program so that when it reaches the end of our program it returns to the beginning.
Click on the “run once” arrow and change it to ![]()
“run continuous” . Now when our program reaches the red light it will return to the green light and start all over again.
Download your program. Congratulations, you’ve made a robot that can roam around the room on its own.
After watching Eddie roam a bit you will notice that he always turns the same way. This usually works to get him out of a tight spot but wouldn’t it be better if we used both sensors so that if the right one was hit he would back up and turn left and visa versa. Remove the tubing that connects the two bumpers, looking at the front of Eddie move the right side touch sensor’s connection from sensor pad 2 to sensor pad 1. Do the same for the left side but move the wire from pad 2 to pad 3. We now have a double touch sensor robot.
Your robot should look like this:
Let’s take a quick look at what the pseudo code might look like for this new program.
go forward
if touch sensor 1 is pressed then
go backward for 1 second
turn left
if touch sensor 3 is pressed then
go backward for 1 second
turn right
repeat forever
The flowchart would look like this:
Open up Inventor Level 4 and build the following program:
Notice this looks a lot like out flow chart. Download and run the program. Eddie now bounces off each object and turns away from it. Congratulations! You have made a more efficient navigation program. Programmers love efficiency and are always trying to do the most work with the simplest program. Do you see a way to make our program more efficient? Can you use fewer icons or simplify it even further? Give it a try and send me your results.
Next time, we’ll take a look at light sensors and tackle some more advanced programming techniques.
Links:
How Robots Work:
http://electronics.howstuffworks.com/robot1.htm
Robolab at Tufts University:
http://www.legoengineering.com
LEGO Education:
http://www.legoeducation.com
Definitions:
Actuator (nj.): A mechanical device that makes something move. Motors, servos, pneumatic and hydraulic cylinders are all examples of actuators.
Algorithm (n.): A set of steps that define a procedure that achieves a goal or solves a problem. This term is often used in Math and was first coined by the Iranian
mathematician, Al-Khawarizmi (813-840 C.E.) the father of modern day Algebra.
Binary (adj.): Consisting of two states.
Pseudo code (n.): A simple form of writing down the logical steps to a program using natural language instead of programming language syntax.
[This article was originally printed in SERVO Magazine April 2004
http://www.servomagazine.com/]■