If you saw any of the "Star Wars" movies, you probably remember Jedi knights like Luke Skywalker or villains like Darth Vader using "The Force" to lift, crush, and throw objects. Have you ever wished you could use an invisible force to move objects around in the real world? In this project, you will! Well, not just any object. First, you will have to build and program a robot that will respond to an "invisible force" from your hand. The invisible force will let you push and pull the robot back and forth without actually touching it! Watch this video of the demonstration robot we built at Science Buddies.
This project relies on a few key parts in the LEGO Mindstorms kit. First, you will need to use motors with wheels to build a robot that can move forward and backward. You will also need to use the NXT's ultrasonic sensor. An ultrasonic sensor measures the distance to an object by bouncing sound waves off it. First, the sensor emits a sound wave that travels forward at the speed of sound, away from the sensor. When that sound wave hits an object, part of it bounces back and eventually returns to the sensor. The farther away an object is, the longer it takes sound to bounce back and return. So, by measuring the amount of elapsed time from when the sound is emitted to when it returns, the sensor can determine how far away an object is, as Figure 1 illustrates.
Figure 1. The farther away an object is from the ultrasonic sensor, the longer sound has to travel to reach the object and then bounce back — which takes more time. This is how the ultrasonic sensor uses sound to measure distance.
Just building a robot with motors and an ultrasonic sensor won't be enough, however. You need to write a computer program to tell the robot what to do. The program you will write for your NXT robot in this project is based on this equation (this equation is called a proportional controller - see the Technical Note at the end of this section for more information):
To help you understand this equation, let's use some examples. Say you pick a value for constant = 2 and desired distance = 30 centimeters (cm). So, your equation is:
Now, think about what happens in three cases:
We'll use the first case as an example. Let's pretend your hand is 10 cm from the robot. So, you plug 10 cm into Equation 2 for the measured distance:
The answer is negative 40 — and a negative number means the robot will move backward, away from your hand. The robot "knows" that it is too close — it should be exactly 30 cm away. Can you use Equation 2 to figure out what will happen if your hand is exactly 30 cm from the robot, or more than 30 cm from the robot? Figure 2 shows what will happen — but make sure you can explain it using Equation 2!
Figure 2. This shows how the robot will behave if the desired distance in Equation 2 is set to 30 cm. If your hand is too close to the robot, it will back up, and if it is too far, the robot will move forward. If your hand is exactly 30 cm from the robot, the motor power will be 0, so it will stop.
Do you understand how the program will work? If not, go back and watch the video again — does it make more sense this time? Once you think you understand how you will be able to push and pull the robot, you are ready to move on to the Procedure section and start building.
Note: Understanding the information in this box is not required to complete the rest of the project — we include it just in case you are curious!
Equation 1 is called a proportional controller, because the control input is proportional to the error. In Equation 1, the control input is the motor power, and the error is the difference between the measured difference and the desired distance. The desired distance can also be referred to as the set point. The constant that multiplies by the error is called the proportional gain. So, you can write a more general equation:
Equation 4.
|
This type of equation is used all the time in robotics and engineering. For example, you could also use it to control the angle of one of the motors in your NXT kit — this time the error would be based on your desired angle, and the measured angle from the NXT motor's built-in angle sensor. A more advanced version of the equation can even be used for things like cruise control in a car, or autopilot in an airplane! We don't have room to explain it all here — but if you are curious, you can do an Internet search for "PID control" or "proportional integral derivative control."