Run the Wander Service

Before running the Wander service, you need to ensure that your LEGO NXT is assembled and configured to work with your development machine. Keep in mind that you must use Bluetooth to connect to your NXT. This is because the interface programs provided with MSRS allow only for a Bluetooth connection. This means your development machine needs to be Bluetooth enabled, or you need to use a supported Bluetooth USB dongle. Refer to the section titled Configuring the LEGO Mindstorms NXT in Appendix B for instructions on how properly to configure the LEGO NXT.

To run the Wander service from Visual Studio, you need to press Ctrl+F5 to start without debugging or press F5 to start with debugging. Either way, you should see a command-line window appear and, within this window, text that indicates the service is being loaded. After it loads successfully, you should hear a beep from the LEGO NXT, and the light sensor should turn on. At this point, you can press the left button on the LEGO brick to start moving the robot forward. You can either push the bumper directly or allow the robot to run into an object that triggers the bumper sensor. When the bumper is pressed, the robot should back up, turn to the right, and then start moving forward again.

Evaluate the Robot’s Behavior

If you have followed along with the chapter, or if you are using a copy of the version 1 Wander service from the book’s companion Web site, then you will see very quickly what problems this version of the Wander service has. For starters, a collision has to occur for the LEGO NXT to move in a different direction.

There are two major problems with using this type of reactive approach. The first problem with the reactive approach is that you are taking a risk that the robot might be damaged. In many cases, robotics hardware is very expensive and not easily replaced. If the robot runs off a high ledge or down a flight of stairs, it could easily be damaged beyond repair. The second problem with this approach is that the bumper sensor will not always trigger a collision. If you take a look at the assembled robot in Figure 6-1, you will see that the touch sensor is triggered by a small T-shaped rod directly attached to the NXT’s touch sensor. It is possible for the robot’s wheels to get hung up on a low-lying obstacle and for the bumper sensor never to be triggered. In this state, the robot could sit there spinning its wheels indefinitely.

Try experimenting with version 1 of the Wander service and see what other potential problems you can see with the code. In the next section, we will make a few changes to the Wander service that enables it to overcome some of these problems.

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

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