Chapter 7. Avoiding Obstacles Using Sensors

In the previous two chapters, we covered wheeled and tracked movement and then legged movement. Now your robot can move around. But what if you want the robot to sense the outside world, so you don't run into things? In this project, you'll discover how to add some sensors to help us avoid barriers.

Mission briefing

We've covered creating robots using a wheeled/track base and robots that can move using legs. In this chapter, you will be introduced to some of the basics of sensors, particularly sensors that can help you avoid objects by alerting you to them.

Why is it awesome?

Your robot will take quite a beating if it continually runs into walls, or off the edge of a surface. Let's help your robot avoid these so that it looks intelligent.

Your objectives

In this chapter, you will:

  • Connect the BeagleBone Black to a USB sonar sensor to detect the world around it
  • Use a servo to change the position of your sensor so that a single sensor can view a large field, eliminating the need for additional sensors

Tip

Downloading the example code and colored images

You can download the example code files and colored images for this Packt book you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Mission checklist

In this chapter, you'll need some sensors. I am going to show you how to interface BeagleBone Black with a sonar sensor. There are other possibilities as well. IR sensors are also available that will detect distance from a target. However, they are sometimes difficult to interface using USB. The advantage of this particular sensor is that it already comes with a USB interface. Here is a image of the USB sonar sensor I like to use on my projects:

Mission checklist

It is the USB-ProxSonar-EZ, and can be purchased directly at MatBotix or on Amazon. There are several models, each with a different distance specification; however, they all work in the same manner.

Also, you may want to detect distance in more than one direction. You have two choices. The first is simply to use a number of these sensors, one in each direction. But in the second section of this chapter, I'll show you how to use a servo to rotate the sensor. This way you can use a single sensor and just turn it to a new direction. To complete this section, you'll need a servo and a way to mount it to your project. Again, I like the Hitec series of servos, and this is ready-made for an HS-311 servo, which should look like this:

Mission checklist

Here is a way to mount the sensor to a 90 degree angle bracket. I used one from a robot kit I purchased on eBay. It can connect to the servo like this:

Mission checklist

However, if you want to get really fancy, you can purchase a pan-and-tilt assembly. These contain two servos and they allow you to rotate your sensor in both the vertical and horizontal axis. They are available from online stores such as www.robotshop.com. You can also construct a pan-and-tilt assembly out of components that you may have if you purchased a legged robot kit.

The finished product with servos looks like this:

Mission checklist

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

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