Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Задани на лабораторные работы. ПРК / Professional Microsoft Robotics Developer Studio

.pdf
Скачиваний:
126
Добавлен:
20.04.2015
Размер:
16.82 Mб
Скачать

www.it-ebooks.info

Chapter 13: Using MRDS with Robotics Hardware

For vision applications, it is important to get the fastest possible connection to the robot. WiFi is at least five times faster than Bluetooth, at 11Mbit/sec for 802.11b, and 25 times faster for 802.11g, at 54Mbit/sec.

The SRV-1 is another one of the robots that is targeted by IPRE for use with Myro.

The authors have updated the MRDS services for the SRV-1 to support the generic webcam contact and reduce flooding effects on the DifferentialDrive service so that the robot can be used with the TeleOperation service in Chapter 4. These updated services are available from the book’s website. Services for the SRV-1b that operate using TCP/IP over WiFi will also be made available.

CoroWare CoroBot

The Corobot from CoroWare (www.corobot.net) is a four-wheeled robot with an onboard PC. Figure 13-10 shows a Corobot with the optional robotic arm attached. It comes with a webcam as standard and there is an optional robotic arm attachment. CoroWare has some sophisticated software that runs under MRDS.

Figure 13-10

Chapter 6 develops a Corobot simulation, which is used again in Chapters 7, 9, and 12. However, there is no coverage of a real Corobot in this part of the book because the authors did not have access to one.

With a price around US$3,000, this robot is probably out of the price range of the average hobbyist and is targeted more at researchers, academics, and the military.

White Box Robotics 914 PC-BOT

The PC-BOT, as its name implies, includes a full-blown PC that runs Windows XP and has a DVD drive, hard disk, speakers, webcam, wireless Ethernet, and so on. It has been available on the market for some time, but at US$8,000 it is not likely to be the first choice for a beginner. The original version came with MRDS installed, as well as all the necessary services and software to support directly programming the robot in .NET applications. See the PC-BOT home page for more information (www.whiteboxrobotics.com/PCBOTs/index.html).

583

www.it-ebooks.info

Part IV: Robotics Hardware

One exciting announcement in late 2007 was that the 914 PC-BOT is also to be sold by Heathkit under the name HE-RObot. Heathkit has a strong reputation in hardware training and educational systems. You can see the Heathkit version of the robot at www.heathkit.com/herobot.html.

At the time of writing, the PC-BOT does not support MRDS V1.5. Services were released for the original V1.0 but the White Box has not updated them. However, it is their intention to support MRDS in the future, so perhaps this will happen with V2.0.

MobileRobots Pioneer 3DX

The Pioneer robot family has been used for years in research institutions. However, a 3DX with a SICK Laser Range Finder costs over US$10,000. MobileRobots sell a whole range of robots, some of which are cheaper, such as the AmigoBots. All these robots are available with WiFi as an option and have an onboard processor, wheel encoders, sonar sensors, and everything that you might expect in a highquality research robot.

The Pioneer 3DX is one of the robots supported in the simulator. The ExplorerSim in Chapter 9 and the VPLExplorer in Chapter 12 use this robot specifically because it has an LRF, which is a very accurate range sensor.

For more information, see www.activrobots.com/ROBOTS/p2dx.html. (The URL is correct — MobileRobots used to be called ActivRobots, and for some reason the P3DX is on a page called p2dx.)

Fundamental Concepts: Sensors, Actuators,

and Controllers

Although you can learn a lot about MRDS simply by working through the Simulation chapters in this book, there is no substitute for using real hardware. Yes, hardware is messy, unpredictable, and often frustrating. It can be complicated to build and sometimes it doesn’t do exactly what it is commanded to do. However, nobody will ever believe that you are a true roboticist unless you have experience with real hardware.

This section briefly addresses the various components of a robot. The key points to note are that hardware is often nonlinear and that it has limitations. It should be obvious that interfacing a computer with a robot requires specialized hardware.

A robot requires input data, which is collected from its environment. This data comes from sensors (also called transducers). Without sensory input, the robot would drive around blind and bump into things — not a very useful outcome.

Once the robot has received some inputs, it needs to process this data to make decisions. Based on these decisions, it can then take some action. A controller does the work of making decisions. Usually the controller is given some task to perform. Depending on the type of controller, it might be a low-level task such as driving in a straight line, or a high-level task such as finding victims after a disaster.

584

www.it-ebooks.info

Chapter 13: Using MRDS with Robotics Hardware

Regardless of the task to be performed, the robot needs to interact with the real world, and for this it needs actuators. Actuators take a variety of forms, but two are very common: the differential drive, consisting of two independently driven wheels, and the joints in robotic arms, which are based on servo motors. In addition to actuators, there might be other output or display devices. Status information is commonly displayed using LEDs.

One important distinction between various types of sensors and actuators is whether they are digital (binary values — usually represented as a bool) or analog (a continuous range of values — usually stored as a double). Obviously, switches and lamps are digital devices because they can only be on or off. Analog input devices require an analog-to-digital converter (ADC) to convert quantities such as voltages, temperatures, pressures, and so on, from the real world into numbers inside a computer. A digital-to-analog converter (DAC) does the opposite and can be used to convert a number, such as a speed, to an output, such as a voltage to control a motor.

The sensors, controller, and actuators are usually connected in a feedback loop or control loop (sometimes also referred to as closed-loop control). One of the most commonly used types of feedback controllers is the Proportional-Integral-Derivative (PID) controller, which is explained in a little more detail below.

One of the objectives of MRDS is to create abstract versions of the various sensors and actuators and then connect to the real devices at runtime by defining partners in a manifest. For this reason, MRDS defines generic contracts for a variety of sensors and actuators. When you build a new MRDS service, you can use these generic contracts so that your service can connect to a variety of devices at runtime. For example, an Analog Sensor service included in MRDS can be used to build a service for any sensor that outputs an analog signal (usually a voltage), as opposed to a digital (or binary) signal.

The following three sections discuss sensors, actuators, and controllers in more detail. There is no attempt to cover all types of sensors and actuators, but rather to discuss the ones that you will commonly encounter when using MRDS. If you have experience with robots, then you might want to skim through these sections because they are background material.

Sensors

There are two types of sensor data: proprioceptive and exteroceptive. These terms just mean internal and external, respectively.

Internal information could include things such as the battery voltage, which a robot needs to monitor to prevent it from running out of power and to signal the need for a recharge. MRDS includes a Battery service. Other examples include temperature sensors to ensure that the robot is not overheating, and stall sensors on the motors that detect when the robot is stuck and can be used to shut down the motors to prevent them from burning out.

External information is obtained from the world around the robot, such as the distance to the nearest obstacle, a GPS location, the current compass heading, the ambient temperature, or even images from a video camera. Notice that in most cases the sensor information can be represented by a single number that has a minimum and a maximum value. The Webcam service is the obvious exception because it provides an array of pixel values.

The following sections discuss various types of exteroceptive sensors.

585

www.it-ebooks.info

Part IV: Robotics Hardware

Contact Sensors

The simplest of all sensors is a contact sensor, also called a bumper. A bumper is just a switch that senses when the robot runs into something, so it only has two states: pressed or not pressed. The LEGO NXT has a touch sensor that is a bumper. Some robots, such as the Boe-Bot, have “whiskers,” which are thin pieces of wire that flex when the robot runs into something, causing an electrical contact to close.

Bumpers are called contact sensors because the robot actually makes contact with (bumps into) the obstacle. If this obstacle happens to be a human, then it could be harmful to the human! If it is a wall, then it might damage the robot. Either way, this is not a good sensor to use for general navigation. Therefore, bumpers are usually used as a last resort in case the other sensors have failed to detect an obstacle. Even expensive robots such as the Pioneer 3DX have bumpers on the front and back as

a fail-safe measure. In the case of the 3DX, there are several bumpers, which MRDS refers to as a bumper array.

It is also possible to have virtual bumpers that don’t involve physical contact. In Chapter 17, for example, the Integrator robot has an infrared sensor that detects obstacles, but the output of the sensor is a binary value — on or off.

Range Sensors

Obviously, it is much better if the robot can sense obstacles from a distance, rather than bump into them. Several types of sensors, usually referred to as range sensors, can provide distance information. Examples include infrared (IR) detectors, sonar sensors, and laser range finders. These are also commonly called time of flight sensors because they send out a signal (infrared light, ultrasound pulse, or laser beam) and wait for a reflection to come back. The time required for the echo is a measure of the distance. You have probably seen movies involving submarines and have heard the “pings” sent out as the sonar searches for enemy ships.

Infrared Sensors

On many hobby robots, infrared sensors are the preferred type of sensor because they’re cheap. However, they’re noisy and nonlinear, meaning that they do not always produce reliable readings and the values from the sensor are not directly correlated to the robot’s distance from an obstacle. (See Chapter 17 for a graph showing the response of IR sensors on a Hemisson robot.) They are also susceptible to interference from strong sunlight (so they might not work at all outdoors), and they work over a very short range (typically 5 to 50cm).

Passive IR sensors just look for reflected infrared signals, which are all around us (but we can’t see them). Active IR sensors work by sending out pulses of infrared light at a fixed frequency and then watching to see whether there is a reflection. Both of these types of sensors are effectively on/off sensors, or what MRDS refers to as “bumpers” although in this case there is no physical contact.

The cheapest IR sensors only indicate that an obstacle is somewhere within a fairly narrow range of distances. The exact range depends on the frequency of the IR pulses. In this case, the input signal is digital, i.e., 0 or 1. Many people do not realize this when they first start working with hobby robots. The absence of range data means that it is not possible to build reliable maps of the surrounding environment. It is also possible to miss obstacles if they are too close to the robot, such as a foot if a person suddenly steps in front of the robot.

586

www.it-ebooks.info

Chapter 13: Using MRDS with Robotics Hardware

The frequency and sensitivity can be adjusted to change the distance at which the sensor is triggered by an obstacle. This is usually done by changing a resistor or adjusting a potentiometer. An approach used in the Boe-Bot documentation is to change the frequency of the IR signal. A sweep of multiple frequencies enables the distance to an obstacle to be determined, but only in very rough bands. (MRDS does not use this method.)

More expensive IR sensors give an actual measurement of the range. There are usually several sensors located around the outside of the robot so that it can see in many directions simultaneously. For example, the Stinger robot in Chapter 16 uses three Sharp sensors across the front. These can measure distances from 10 to 80cm. An example of a Sharp GP2D12 IR sensor is shown on the left in Figure 13-11; shown on the right is its response to obstacles, sometimes referred to as the measurement model.

(a)

Figure 13-11

 

 

Analog Output Voltage vs. Distance to

 

 

3.0

 

 

Reflective Object

 

GP2D12

 

 

 

 

 

 

 

 

 

 

 

 

Draft

Reflectivity

 

2.8

 

 

 

 

 

 

 

 

 

White

 

90%

 

 

 

 

 

 

 

 

 

Vo (V)

2.4

 

 

 

 

Gray

 

18%

 

 

 

 

 

 

 

 

 

2.0

 

 

 

 

 

 

 

 

voltage

 

 

 

 

 

 

 

 

1.6

 

 

 

 

 

 

 

 

output

1.2

 

 

 

 

 

 

 

 

 

 

 

 

 

Gray

 

 

Analog

 

 

 

 

 

 

 

0.8

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0.4

 

 

 

 

 

White

 

 

 

 

 

 

 

 

 

 

0

10

20

30

40

50

60

70

80

 

0

(b)

 

Distance to reflective object L (cm)

 

 

 

 

 

 

 

 

 

 

Sonar Sensors

Sonar sensors use ultrasonic “pings” to sense obstacles, usually at a frequency around 40 kHz. This is high enough that most people cannot hear the pings. It is unlikely to bother your dog, either, even though dogs can hear higher frequencies than humans. The measurement range for sonar sensors is from a few centimeters up to several meters, and they are usually accurate to within a centimeter or two. More important, modern sonar sensors are linear, so no processing is required to convert the input value to an actual range (this is usually done on the sensor circuit board).

587

www.it-ebooks.info

Part IV: Robotics Hardware

Shown on the left in Figure 13-12 is the PING))) sensor manufactured by Parallax. A typical “beam” footprint (top-down view) from a sonar sensor (on the right) shows concentric circles, which represent distance from the sensor, with the numbers around the outside of the figure representing angles in degrees from the axis of the sensor.

The outline in Figure 13-12 (on the right) shows the point where the reflected signal can no longer be detected — that is, the maximum range of the sensor. Notice that it is not a narrow beam. The range returned by the sensor is the distance to the nearest obstacle (according to the concentric circles) that falls inside the outlined area. If multiple obstacles are inside the outlined area, the distance measurement will be the range to the closest one.

 

0

330

30

300

60

270

90

240

120

210

150

180

(a)

(b)

Figure 13-12

It might seem like sonar is a much better option than IR; but as with all sensors, sonar has several deficiencies and failure modes. Because a sonar beam is based on sound, it spreads out in a cone shape the farther it travels from the sensor. This means that a reading only gives an indication of the closest obstacle within an arc of several degrees (up to 60 degrees in the right image in Figure 13-12), and it is not possible to tell the exact direction to an obstacle. Some materials can also absorb sound, so there might not be sufficient reflection to get a reading. Lastly, if the sensor is at an angle to a wall, then it is possible for the reflection off the wall to bounce away from the sensor, not back toward it. In this case, the sensor records a maximum range value, which is a “miss.” Obviously, this is a serious problem if the robot then charges ahead at full speed thinking that nothing is there!

Sonar sensors are usually arranged in a sonar ring, equally spaced around the robot, often with 12 or even 24 sensors. They can’t be located too close together because of “cross-talk” between the sensors — that is, one sensor sees the reflection of the signal from a different sensor and therefore registers the wrong range.

MRDS does have a generic sonar contract, but the latest version of the LEGO NXT services uses the analog sensor contract for the LEGO sonar sensor.

588

www.it-ebooks.info

Chapter 13: Using MRDS with Robotics Hardware

Laser Range Finders

Much of the recent research into robotics has used laser range finders (LRFs), which are far more accurate and have a much larger range compared to IR or sonar. However, a LRF costs thousands of dollars, whereas a sonar sensor costs less than $50.

A LRF uses a low-power laser beam, which is often a red beam, but newer devices use infrared. The LRF scans the beam across a wide arc using a rotating mirror and captures a range scan consisting of an array of measurements at fixed angles, often one degree apart.

Typical LRFs have maximum ranges from 8m to over 100m and they usually have a field of view (the spread from first value to last value on the right in Figure 13-13) between 100 and 180 degrees. The SICK LMS200 LRF, shown on the left in Figure 13-13, is a popular model. Although it is very expensive compared to IR or sonar sensors, it is highly accurate, with a 180° field of view, resolution of 10mm

±15mm, and a maximum range of 10m.

LMS200/LMS221/LMS291

last value

 

first value

 

Scanning angle 180

(a)

(b)

Figure 13-13

The simulated Pioneer 3DX robot has a LRF and you can see red dots appearing on obstacles a couple of times per second. With a range of 10m or more, a LRF in an indoor environment can nearly always see obstacles. Only long corridors result in a maximum range reading being returned.

Light Sensors

The Boe-Bot kit comes with a couple of light-dependent resistors (or photoresistors). These detect the amount of light falling on them, and their resistance varies accordingly. When incorporated into a circuit, they can be used to build a robot that either seeks out light (a photovore) or avoids light (a photophobe). With appropriate programming, the robot can be made to follow a flashlight or hide in the shadows like a cockroach.

The LEGO Mindstorms NXT kit also includes a light sensor, which incorporates an LED that can be turned on to illuminate the target so it can operate in either a passive mode (using ambient light) or an active mode. A color sensor is also available, which uses colored LEDs to illuminate the target and return a number that represents a code for the particular color.

589

www.it-ebooks.info

Part IV: Robotics Hardware

These types of sensors just detect the presence of light, or the color of the light. They cannot be used to “see” because they don’t construct an image.

Video/Image Sensors

Cameras have become popular input devices in recent years as the price of digital camera sensors has dropped dramatically and the resolution has continued to increase. MRDS supports both Internet Protocol (IP) cameras and webcams (which usually attach via a USB connection). Image sensors provide an array of pixel values whereby each pixel usually consists of red, green, and blue (RGB) components.

In effect, a camera is the equivalent of thousands or millions of individual light sensors. In Chapter 12, downward-facing simulated webcams are used as light sensors for the line-following example by averaging small areas of the input images and coming up with values for “lightness.” In reality, nobody would waste a webcam for this task because it can be done with much cheaper sensors.

Processing video images is a complex task. It is not easy to obtain range measurements from a video image because of factors such as perspective. Cameras have therefore tended to be used to recognize objects, people, and places by performing what is called feature (or blob) extraction. For instance, robot soccer relies on the soccer ball being a bright color, like orange, so that the robot can easily locate it in the image. (See the FollowBall example in Chapter 12.) Using blob tracking, the robot can then follow the ball. MRDS V1.5 includes sample calibration and blob-tracking services.

The simulated Pioneer robot has a camera mounted on top of it. You can see the view from this camera by pressing F8 in the simulation window or selecting it from the Camera menu. If you use the Dashboard or TeleOperation services (located in the ProMRDS\Chapter4 folder), then you can select the camera from the list of services and the video will be displayed in a separate window that automatically maintains the correct aspect ratio. This Dashboard also works with real webcams if you include a Webcam service with your robot.

If you are interested in computer vision, you should download RoboRealm (www.roborealm.com). It works with MRDS and is fairly easy to set up.

Other Sensors

Several other types of sensors are commonly used on robots. This is not a complete list, but it does provide some idea of what is available. Many of these sensors are available for the LEGO NXT, which is why they have been included here.

Global Positioning System Sensors

A GPS (global positioning system) sensor provides an estimate of the robot’s location to within an area of several meters. Unfortunately, the signals from the GPS satellites are extremely weak, so a GPS receiver does not work indoors. Moreover, the accuracy of the position fixes is so poor that the robot might believe that it is in the room next door. MRDS includes services for the Microsoft GPS.

Compass Sensors

The robot’s orientation is one of the most important pieces of information for navigation. If the robot becomes disoriented, either by bumping into obstacles or due to wheel slippage, then it can quickly

590

www.it-ebooks.info

Chapter 13: Using MRDS with Robotics Hardware

become lost. A compass is valuable because it provides an absolute reference, i.e., errors do not accumulate over time.

Compass sensors work off the Earth’s magnetic field. The HiTechnic compass sensor (www.hitechnic

.com) for the LEGO NXT can measure bearings to the nearest degree, but the NXT only uses a single byte to represent analog values, so the readings are divided by two, resulting in a resolution of two degrees. The compass sensor can be read in the same way as an Ultrasonic (sonar) sensor because it just provides an analog value.

Just like a real compass, a compass sensor can be affected by large metallic objects and magnetic interference caused by motors and computers. Therefore, the compass sensor must be placed some distance from the LEGO NXT motors and even the NXT “brick.” (The Tribot shown in Figure 13-3 has a compass mounted on a “stalk” at the back of the robot for this reason.) A compass must also be kept level or it produces incorrect readings. The effectiveness of compasses is reduced indoors, but they do work inside most buildings.

Acceleration/Tilt Sensors

Acceleration/tilt sensors can be used to measure changes in speed and orientation. This type of sensor is available for the LEGO NXT (from LEGO or HiTechnic). Tilt sensors are useful to determine whether the robot is driving uphill, or for a legged robot to realize when it has fallen over so that it can get up again.

Sound Sensors

Sound sensors vary in their capabilities. Because sounds can contain high frequencies, it is not usually feasible to measure them in real time if the robot is remotely controlled. Therefore, sound sensors tend to produce an output that is proportional to the volume of noise, or they selectively filter (listen for) particular frequencies.

Obviously, a microphone is a form of sound sensor, but it requires a high sampling rate to obtain useful information. Microsoft provides a Speech Recognition service as part of MRDS V1.5. For this to work, the microphone must be attached to the PC running MRDS, not to the robot if it is remotely controlled. Of course, if there is a PC on the robot and it has sufficient processing power, then it might be able to do both speech recognition and speech synthesis — that is, it could actually talk to you!

Wheel Encoders

A wheel encoder measures rotations of a wheel so that you can determine how far a robot has traveled, assuming that you know the radius of the wheels. Wheel encoders are usually rated in terms of the number of “ticks” per revolution of the wheel. An encoder might give 1200 ticks per rotation, or even 3600 ticks. The encoders built into the LEGO NXT motors, however, can only measure 360 ticks per revolution, or, even worse, in low-resolution mode only 9 ticks.

Wheel encoders, also sometimes called odometers, are notoriously unreliable. If you rely only on

input from wheel encoders to keep track of your position, a process called dead reckoning, then you will invariably get lost. This happens because the wheels slip against the ground as the robot moves;

it bumps into objects, which makes the wheels jump off the ground momentarily; or a variety of other reasons.

591

www.it-ebooks.info

Part IV: Robotics Hardware

However, wheel encoders are essential if you expect to make accurate turns using the RotateDegrees request for a Differential Drive service, or move precise distances using DriveDistance. Even then, the small errors that occur on each request will accumulate over time.

Actuators

Actuators are output devices that affect either the robot or the real world in some way. The obvious examples are motors (and wheels) that enable robots to drive around. Robotic arms have grippers to pick up objects. A bomb-disposal robot might have a rifle to shoot bombs, although you might imagine that this actuator would only ever be used once.

The main point about actuators is that they have an operating range: motors have a maximum speed; joints have minimum and maximum bend, or rotation angles; and so on.

Motors

You are probably familiar with electric motors that run continuously when power is applied to them. By adjusting the voltage, the speed of the motor can be varied. Reversing direction requires the polarity of the power to be reversed.

Motor control is usually done using a circuit board called an H-bridge. This board must be able to handle the large currents, sometimes several amps, that are necessary to drive a motor. In contrast, the typical circuitry inside a computer operates at a low voltage (5V or 3.3V) and low current (a few milliamps or even less). The H-bridge, therefore, translates the small signals from the computer to much larger signals for the motors, and it can also handle polarity reversals.

Servo Motors

Servo motors are designed to move to a particular position and then hold that position. The position information is encoded in the signal sent to the servo motor. Typical servos operate on a pulse width modulation (PWM) system, with pulses being repeated 50 times per second. As long as the servo is receiving pulses, it resists any change to its position, which effectively locks it in place. This makes servos perfect for use in a robotic arm that has to lift loads of different weights, or for grippers.

A servo has an internal encoder to measure the angle of the motor shaft. This is usually a potentiometer. Most servos operate over a range from 90 degrees to 90 degrees and have physical stops at the extremes of their travel. Trying to drive a cheap servo beyond its range can damage it.

Just to confuse you, some hobby robots use servo motors for the wheels. By deliberately disabling the positional feedback circuit inside the motor, it can be made to rotate continuously (always searching for the desired position). The Boe-Bot uses continuous rotation servos. There are many advantages to using a small servo motor instead of a conventional electric motor, including cost and lower rotational speed.

Digital Outputs

Some types of actuators take a binary signal, such as light-emitting diodes (LEDs) or buzzers. You can turn these actuators on or off.

592