Chapter 6. Autonomous Roaming

In the last chapter, we covered the basic steps for driving a robot using remote control. In this chapter, you have an opportunity to create a service that allows a robot to move around a room unassisted. You will write the service in two versions, and the first version will use a touch sensor to notify the robot of an obstacle collision. In this case, the robot will perform reactively; when a collision occurs, it will back up and move in another direction. The second version of the service will improve upon the first version and utilize a sonar sensor to detect an obstacle before the collision occurs.

In both versions, we will work with one of the Microsoft Robotics Studio (MSRS)–supported robots: the LEGO Mindstorms NXT. This small and affordable robot includes a two-wheel differential drive system and touch, sound, light, and sonar sensors. This easily assembled robot allows you to experiment with the different ways a robot can navigate its environment using the built-in sensors.

Working with the LEGO Mindstorms NXT

LEGO, well known for its line of toys, offers a robotics kit known as LEGO Mindstorms. The latest version of this robot, the NXT, features a 32-bit processor and includes three servo motors and four different sensors. The sensors provided with the NXT include the following:

  • Touch sensor. This simple sensor can function as a bumper for your NXT robot. When the button on the touch sensor is pressed, you can assume the robot has encountered an obstacle and, thus, instruct the robot to either stop or move away from the object. When the button is released, you can assume the robot has cleared the obstacle.

  • Sound sensor. By detecting decibel levels, the sound sensor can determine when the noise level surrounding the robot reaches a certain threshold. This can be useful when there is a need to control the robot using sounds such as loudly clapping your hands or shouting a command.

  • Light sensor. The NXT light sensor is able to detect both reflective and ambient lighting. Reflective lighting occurs when light bounces off an object. The NXT sensor works by using a light-emitting diode (LED) to emit a light. It then uses a receiver to measure the amount of light reflected back. This can be used to detect when the light in a room has gone on or off.

  • Sonar sensorThe sonar sensor for the NXT represents the robots eyes and, interestingly enough, the sensor itself resembles a head with two big eyes. This sensor is used to measure distance in centimeters, and it does this by emitting a high-frequency sound that humans are not able to hear. The sensor works by measuring how long it takes for the sound to echo back. The elapsed time indicates how near the object is to the robot and, thus, can be useful for obstacle avoidance.

The LEGO NXT, which can be purchased online or at local retailers, is a rugged and easily assembled robot that offers an almost endless array of design possibilities. LEGO sponsors a Web site (http://mindstorms.lego.com/nxt/Overview/default.aspx) that provides extensive information about the NXT. The Web site also includes access to an online forum and user community that includes robotics hobbyists of all levels. Do not think that the NXT is simply a toy. It offers an extensible and durable robotics platform that you can use to perform many common robotics tasks.

Tip

Tip

Several third-party vendors offer additional sensors for the LEGO NXT. One such company, Vernier Software and Technology, offers a sensor adapter for the LEGO NXT (refer to http://www.vernier.com/nxt/). The adapter can be used to add one of 32 sensors, such as the Accelerometer, Barometer, Magnetic Field Sensor, Colorimeter, pH Sensor, Relative Humidity Sensor, Soil Moisture Sensor, Sound Level Meter, Temperature Probe, UVA Sensor, and UVB Sensor. The Vernier Web site hosts several movies that showcase what people are doing with the LEGO NXT and Vernier sensors. The NXT services available with MSRS are extensible so that these other sensors can be added.

The example code in this chapter includes two versions: The first version uses the touch sensor to move the robot after an obstacle collision occurs. The second version uses the sonar sensor to detect obstacles before a collision and, thereby, allows the robot to avoid potential damage. Before you begin, you will need to assemble and configure the LEGO NXT. Refer to the configuration instructions in the section titled Configuring the LEGO Mindstorms NXT in Appendix B.

The LEGO NXT allows you to assemble alternative versions of the robot, which includes models resembling vehicles, machines, animals, and humanoids. In this chapter, we will work with a version of the LEGO NXT known as the TriBot. This is the simplest assembly, and the NXT kit includes a quick-start guide, which instructs you how to assemble the TriBot. You will need to go beyond the quick-start guide and assemble the bumper, sound control, and sonar sensors. Instructions for how to add these sensors are included with the documentation installed with your NXT. After you assemble it, your robot should resemble the robot in Figure 6-1.

Note

Note

The bumper sensor depicted in Figure 6-1 is slightly different than the one described in the LEGO NXT assembly instructions. Instead of allowing the bumper to drag above the ground, the bumper is attached to the peg hole within the touch sensor. This allows the touch sensor to work more effectively as a bumper.

Assembled LEGO NXT, which is used in the sample code included with this chapter.

Figure 6-1. Assembled LEGO NXT, which is used in the sample code included with this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.18.109.154