Mechatronics 14 (2004) 491–514
Design and development of an autonomous mobile smart vehicle: a mechatronics application B. Gopalakrishnan *, S. Tirunellayi, R. Todkar Department of Industrial and Management Systems Engineering, West Virginia University, P.O. Box 6070, Department IMSE, WVU, Morgantown, WV 26506, USA
Abstract Mechatronics is a synthesis of mechanical and electronic domains that overlap in the design of complex systems. It represents the multidisciplinary technological backbone of today’s smart products. An autonomous mobile robot is a smart product that has mechatronics blended into its design configuration. The research describes the design and development of an autonomous mobile vehicle that can exhibit intelligent behaviors such as obstacle avoidance, and response to light and sonar inputs so as to exist and behave as an intelligent entity that accommodates its changing environment. The paper also focuses on the behavior characterization of various analog and digital transducers, such as infrared, sonar, and light sensors. 2003 Elsevier Ltd. All rights reserved. Keywords: Mechatronics; Sensors; Mobile robots; Artificial intelligence
1. Introduction Mechatronics, which focuses on the synthesis of mechanics and electronics, has gained much ground in recent years and is vital for the building of smart products. Intelligence and flexibility are two essential features in a smart mechatronics product such as an autonomous mobile robot. Mobile robot research addresses many problems in robotics such as sensor integration, real-world modeling, actuator and sensor control, path planning and navigation, task-level planning and execution, and the control of the robotic system as a whole. Moreover, building autonomous mobile robotic vehicles provides a stringent test bed for new concepts and approaches in
*
Corresponding author. Tel.: +1-304-293-4607x3709; fax: +1-304-293-4970. E-mail address:
[email protected] (B. Gopalakrishnan).
0957-4158/$ - see front matter 2003 Elsevier Ltd. All rights reserved. doi:10.1016/j.mechatronics.2003.10.003
492
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
both hardware and software. This paper concentrates on the design and development of an autonomous platform, using mechatronics to implement intelligent behaviors, with the help of a microcontroller interfaced with sensors. Mechatronics is defined as ‘‘the synergistic integration of mechanical engineering with electronics and intelligent computer control in the design and manufacture of products and processes’’ [4]. Mechatronics can also be defined as an application of the concept of ‘‘Concurrent Engineering’’ to the design of electro-mechanical systems [7]. This design philosophy can be further exemplified by an interdisciplinary and integrated design approach where electrical, electronic, computer, mechanical and instrumentation systems are simultaneously designed to function as an integrated system. Thus, mechatronics can be viewed as a concurrent engineering framework in the process of designing complex machines [8]. 1.1. Mobile robots––a mechatronics perspective Mechatronics essentially describes the integration of mechanical and electronic engineering. Going by this definition robots and specifically mobile robots can be considered as products of mechatronics engineering. The mechanical aspects of a mobile robot include appropriately designed chassis/base, steering and drive mechanisms. The design issues [5] affecting these are maneuverability, traction, stability, navigation, shape and size, and controllability. The characteristics of the sensors and their operation are crucial for the practical application of the mobile robot. The general issues [5] concerning the application of sensors in mobile robots are the field of view and range of operation, accuracy and resolution, real-time operation, ability to detect all objects in the environment, be concise and enable easy interpretation of data, power consumption. The components of a mobile robot are a controller, control software, sensors and actuators. The controller is generally a microprocessor, embedded microcontroller or a personal computer (PC). Mobile control software can be either assembly level language or high-level languages such as C, C++, Pascal, Fortran or special real-time software [3,12]. The sensors used are dependent upon the requirements of the robot. The requirements could be dead reckoning, tactile and proximity sensing, triangulation ranging, collision avoidance, position location and other specific applications.
2. Integrated system development Fig. 1 illustrates the systems approach to the testing of the design intent of the mobile robot behavior in the real world [13]. The behavior algorithms are coded on a host computer using Interactive C. The programs contain necessary functions to invoke the sensor readings and the logic of motor outputs based on the sensor data and control logic. These programs are then downloaded to the Handy Boarde which is placed on top of the vehicle through the RS232 serial interface cable. If any compiling errors are present, the downloading stops. Once errors have been elimi-
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
Download Programs
Sensors
493
Host Computer
TM
Handy Board Vehicle
Vehicle HANDY Operation BOARD
Design Intent Satisfactory ?
No
Yes Stop Fig. 1. System diagram.
nated and the programs are successfully downloaded, the vehicle is set into operation and the behavior tested in the real world environment. The Handy Boarde version 1.2 is a single board computer optimized for controlling DC, stepper and servo motors and receiving data from a host of digital and analog sensors. Its miniature size, low power operation and programmable nature make it an ideal choice for the control of small mobile robots if needed. It communicates with a desktop computer over a standard serial cable, making it suitable for PC based control [12]. Fig. 2 represents the block diagram of mobile vehicle completely integrated with all the sensors and the smart behaviors. The description to follow will discuss in detail the various steps in the hardware design of the integrated system. The base vehicle used in this research is Black Phantom IIe, a toy truck manufactured by Radio Shack . It was decided not to fabricate the mobile platform in-house due to the high torque output needed at the wheels to propel the vehicles saddled with the Handy Boarde and sensors. After considering several remote controlled cars, the Black Phantom IIe was chosen for the following reasons. • Driving and Steering motors require 9.6 V power supply, which is ideal for the Handy Boarde. • The car has motors capable of withstanding sudden load fluctuations and abrupt speed variations. • Sturdy spring dampers in the front and rear making it ideal for all terrains. • Easy accessibility of the Black Phantom II’s technical documentation [1].
494
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514 Position Feedback from Wheels
Steering Motor
Infra Red System
Interactive C TM Handy Board
Light Sensors
Reflectance Sensors
Sonar System
Bump Switches Drive Motor
Smart Behaviors Obstacle Avoidance Light Seeking
Fig. 2. Integrated system and behaviors.
Fig. 3 shows the autonomous mobile smart vehicle with the layout of the various sensors. The steering mechanism consists of a servomotor, gearbox, servo spring and tie-rods [1]. The tie-rods are non-repairable and are attached to the servo springs at one end. The other end of the tie-rods is connected to the wheels through stops. On powering the servomotor, the tie-rods rotate either direction until they hit the stops. This way the wheels can be turned to the left or right. The electronic circuitry consists of transmitter and receiver printed circuit boards (PCBs). The transmitter circuit controls the remote controller and the joystick and can send signals at 4 band frequencies. The receiver decodes the transmitting signal and drives the motors forward or backward and left or right. The drive motor is powered by the H-bridge that is built in to the vehicle. The transistors present in the H-bridge were rated for minimum 10 A and 50 W [1]. The front bumpers were removed and a special attachment was fabricated. The top portion was cut and then tungsten inert gas welded to the bottom of the plate. Holes were drilled along the circumference of the welded part to hold the bump switches. Holes were also drilled on the end of the plate and the setup screwed to the base of the vehicle. An attachment with spring dampers was developed to reduce impact due to collisions. 2.1. Motor control circuitry Table 1 shows the motor current and power ratings for both the steering and drive sections. The transistors on the H-bridge that control the motor are rated for very high current and power (10 A, 50 W) [1]. 2.1.1. Steering control The Handy Boarde motor driver chips SN754410e, manufactured by Texas Instruments Inc are rated to drive motors with a maximum current requirement of
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
495
Infrared Emitter (LED) Bump Switches Light Sensors Infrared Detectors
Sonar
Transducers
Left Wheel (Front)
Right Wheel (Front) Reflectance Sensors
PCB
Handy Board
Handy Board Light Sensor
Left Wheel (Back)
Spring Damper
Right Wheel (Back)
Fig. 3. Top view of sensor layout in the SMART car.
1 A and can supply 6–12 V power. As the current requirement of the steering section was quite less, it was decided to power the steering servomotor through the Handy Boarde. The existing steering control was completely removed and new leads soldered from the ground, power and signal, terminals of the motor to the Handy Boarde motor header. To accurately turn the wheels, a feedback control was designed by tapping the potentiometer leads. The potentiometer attached to the servomotor gives out an analog signal depending on the amount and direction of the turn. By knowing the value of the potentiometer, the position of the servomotor and
496
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
Table 1 Motor ratings Section Motor section Current drain Power supply Motor section Current drain
Forward (no load) Backward (no load)
Nominal
Limit
1.0 A
1.5 A
9.6 V Right turn Left turn
Power supply
230 mA
350 mA
9.6 V
consequently the position of the wheels can be ascertained. The potentiometer leads were then plugged into the analog port of the Handy Boarde. Thus, with the information from the analog port, the wheels could be positioned in three different ways namely extreme left, straight and extreme right. 2.1.2. Drive motor control The proprietary IC chip and crystal oscillator were removed from the receiver PCB to completely eliminate the remote control functions. As the drive motors could draw current more than 1 A that the Handy Boarde motor drivers could not provide, it was decided to power the motors through an external battery of 9.6 V. The H-bridge transistors were also rated for 10 A, so this part of the circuit was utilized. A new logic gate circuitry for the H-bridge was designed, using a Quad 2 input AND gate. The logic gate circuitry was necessary to turn on the forward and reverse directions separately through the Handy Boarde. This way the power switch was completely eliminated and the external battery could power the drive motors, with the Handy Boarde providing only the direction control of the drive motors. One motor driver chip had to be removed from the Handy Boarde and a matching socket installed in its place. 2.2. Infrared sensory system The infrared system consists of a near infrared light emitting diode (LED) coupled with Sharp IS1U60 detectors. The infrared system acts as a proximity sensor in detecting obstacles that are close to the robot. The Handy Boarde has a built-in oscillator that operates at 40 KHz frequency. Fig. 4 shows the wiring of the infrared LED. A resistor was added in series with the LED to limit the current flow through the LED. The LED has a viewing angle of 45 and a maximum power output of 16 mW at 100 mA. The Sharp detector IS1U60 is basically a demodulator and can detect frequencies around 38 KHz. A low digital signal is generated whenever the frequency is close to 38 KHz and a high signal at all other times. Fig. 5 shows the wiring diagram for the Sharp detectors. The LED emitter with 45 angle was ideal for the robot because 60– 180 causes too much splatter and collimating them or using 5–10 viewing angle
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
497
Anode
Cathode Resistance R
Fig. 4. Infrared LED wiring diagram.
Signal
GND
+ 5 Volts
Fig. 5. Sharp IS1U60 wiring diagram.
would require several LED’s placed all around the front portion of the vehicle. With 45, two detectors were enough to detect obstacles in the front and to the sides. The LED was plugged into the IR OUT port of the Handy Boarde and the detectors connected to the IR IN port and the first digital port on the right. 2.3. Ultrasonic ranging system Ultrasonic echo ranging is a useful technique [6] to determine the ranges of obstacles or surfaces. The principle of this technique as described in [5] is to electronically generate a short burst of ultrasonic energy followed by amplification and then transmitted by a transducer. The signal travels through the medium, reflects from the target object and returns to the transducer. The signal is received, amplified and processed by the system electronics. The time elapsed between transmitting and receiving the return signal is proportional to the distance traveled. By knowing the speed of sound, the distance to the object can be calculated. The ultrasonic echo ranging system used in this research was purchased from Polaroid Corporation and is composed of two parts, namely the transducer and the electronics module. The transducer is an electrostatic type, which is used to transmit the signal and to receive the echo [11]. It consists of a very thin, Kapton film diaphragm vacuum coated with gold to form the negative electrode. The positive electrode is a coined aluminum backplate, which also provides resonant structure to the diaphragm. The transducer is designed to transmit the outgoing signal and also function as a microphone in order to receive the reflected signal (echo). The sonar system electronics are integrated onto a single module utilizing integrated circuits to perform several analog and digital functions, and packaged with all
498
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
discrete components on a single PCB. The ranging board electronics control the operating mode of the transducer. Powered by a 5 V DC supply the board is compact and easy to interface with the Handy Boarde. 2.4. Bump switches Bump switches are basically push button switches and were incorporated to detect collisions with walls and obstacles. Holes were drilled on the circumference of the front plate of the vehicle to hold seven bump switches. Due to constraints on the ports of the Handy Boarde and to reduce the wiring, switches S1 and S2 were connected in parallel, S3, S4 and S5 as a parallel set and S6 and S7 as another parallel set. This way collisions in the front, right and left directions can be detected. 2.5. Light sensors Cadmium sulphide (CdS) photocells are used to detect the intensity of light sources. CdS cells are basically variable resistors that can be controlled by ambient light or other light sources. In the setup, the light sensor becomes a part of a voltage divider circuit. The voltage output at the signal varies as to the ratio between the fixed internal resistance and the varying photocell resistance. When the photocell resistance is small (when brightly illuminated), the signal voltage is close to 0 V and when the photocell is in dark, the resistance is large and signal voltage is close to +5 V. The arrangement was then plugged into analog ports, with two photocells mounted on the front plate. Two more photocells were fixed on the rear bumper. The sensors recorded low values (around 10) when illuminated and high values (around 235) when in dark. It was also observed that the range or responses given depends greatly on the ambient room light. With this setup, the output from the light sensors was ideal to be used to simulate light seeking behavior of the vehicle.
3. Logic for the selection and integration of behaviors The behaviors selected for the mobile robot was based on rendering as much intelligence as possible to the vehicle. The intention was to enable the robot to function as a stand-alone entity in an environment that may be continually changing. The elements of change include environmental light levels, obstacle positions, and vehicular control aspects. The vehicle should be able to navigate towards lighted areas and in this context be able to avoid obstacles and if in a complication position to be able to extricate itself using defined approaches in terms of altering its relative position with respect to the obstacles. These obstacles could be in any relative direction with respect to the movement of the robot. Hence the logic for the selection of the behavior of the mobile robot is based on the above-mentioned objective in terms of the robot movement and navigation. The research described in this paper attempts to describe how these essential behaviors are fused and then tested and refined for the effective operation of the vehicle. The following sections describe the
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
499
Table 2 Sensors and behaviors Behaviors
Infrared
Sonar
Light
Bump
Reflectance
Obstacle avoidance Light seeking
Yes Yes
No No
No Yes
Yes Yes
No No
design of the respective control approaches in terms of the codes that drive individual modules. 3.1. System behavior design The various behavior algorithms and the sensing and actuator subroutines that enable the vehicle to exhibit a certain degree of intelligence and smartness are discussed in this section. Table 2 shows the behaviors and the corresponding sensors used to achieve those behaviors. These are some basic sensing and actuator control program modules that are used in the behaviors. These modules are frequently called in the behavior algorithm according to a planned logic to guide the robot safely to its goal. This section introduces the software control procedures for the basic program modules. 3.2. Drive motor control As discussed earlier, an external battery powers the drive motor and the Handy Boarde just provides the direction and power level control. The DC motor can be set in both the forward and backward directions. The power level of the motor is controlled by the pulse width modulation (PWM) technique. The PWM is a method used to reduce the amount of power delivered to a DC motor. Instead of reducing the voltage operating the motor, the motor power supply is rapidly switched on and off. The percentage of time that the power is ON determines the percentage of the full operating power that is delivered. The command motor(int m, int p) in Interactive C, allows control of the power level of the motor numbered Ôm’ and of power level Ôp’. Powers range from 100 (full forward) to )100 (full backward). The system software actually controls motors to seven degrees of power, but any integral argument between +100 and )100 can be used. Alternatively, the motor can be switched off by issuing the command motor(int m, 0) or off (int m) or alloff( ). 3.3. Steering motor control The vehicle’s steering wheels may be in a random position before power is turned ‘‘on’’. By tapping the value of the potentiometer, the present wheel position can be known and subsequently, the wheels can be turned to a new position. The power levels of the servomotor are also controlled by the PWM technique. The partial subroutine for straightening of the steering wheels is listed in Table 3. The steering motor potentiometer position is read by calling the position analog(0). The value
500
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
returned by analog(0) is then saved to the variable pot, then they are returned at full power. The if loop first checks if the wheels are already straight. If the wheels are not straight, they are turned until they become straight. This process is done in the while loop. If the wheels are closer to being straight, the speed of turn is at a power level 50. But, if the wheels are at extreme positions, the wheels are turned at full power. In the left turn and right turn modules, as shown in Tables 4 and 5, the stopping position depends on the starting point. The variable pot is constantly checked by calling the inherent function analog(0). The if loop again checks if the wheels are already at extreme positions. When the potentiometer readings are less than a threshold value of 115 for right turn and greater than 145 for left turn, the stopping position commands are issued. Otherwise, a different stopping position command is issued. Then, the wheels are turned at full power or at half power depending on the value of variable pot. This process is done in the while loops. Turning continues until Table 3 Wheel straightening code pot ¼ analog(0); /*read potentiometer position*/ if((pot < ¼ 133)&&(pot > ¼ 128)) r ¼ 0; /*wheels are already straight*/ else r ¼ 1; while((pot > ¼ 133)k(pot < ¼ 128)) { pot ¼ analog(0); motor(1,mdir); if(pot > ¼ 132) {mdir ¼ )50;f ¼ 1;} /*slow speed as wheel is closer to straight*/ if(pot > ¼ 152) mdir ¼ )100; if(pot < ¼ 128) {mdir ¼ 50;f ¼ )1;} if(pot < ¼ 108) mdir ¼ 100; /*full speed as wheel is far away from straight*/ }
Table 4 Left turn module code pot ¼ analog(0); /*read potentiometer position*/ if(pot > ¼ 145) stop ¼ 90; /*stopping position depends on starting point*/ else stop ¼ 80; while(pot > stop) { motor(1,mdir); pot ¼ analog(0); if(pot > ¼ stop) mdir ¼ )50; else mdir ¼ 0; if(pot > ¼ (stop + 15)) mdir ¼ )100; }
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
501
Table 5 Right turn module code pot ¼ analog(0); /*read potentiometer position*/ if(pot < ¼ 115) stop ¼ 160; /*stopping position depends on starting point*/ else stop ¼ 170; while(pot < ¼ stop) { motor(1,mdir); pot ¼ analog(0); if(pot < ¼ stop) mdir ¼ 50; else mdir ¼ 0; if(pot < ¼ (stop ) 15)) mdir ¼ 100; }
Table 6 Reverse braking module code motor(0,)30); sleep(0.01) motor(0,0);
/*)30 for right turn module*/ /*+30 for left turn module*/
the variable exceeds the stopping position as recorded in the variable stop for a left turn and when pot is less than stop for a right turn. The starting point of the turn determines the speed attained as well as the stopping point. The exact values for the stopping points were determined after extensive experiments with the steering wheels. It was frequently noticed that once the stopping point was reached, the wheels were turned more than what was required. So, to compensate for this excessive turn a reverse braking subroutine as shown in Table 6 was developed. The wheels turn in the opposite directions at a power level of 30 for 10 ms. The command sleep(0.01) forces the microprocessor to stay idle for 10 ms. Thus, with the program modules, the wheels could be positioned in the left, right and straight directions. Alternatively, the wheels can also be turned in steps, instead of complete left turn or right turn. This way, more precise control of the wheels can be obtained. The Interactive C codes for step turning of the wheels are shown in Table 7. In the extreme left position, the potentiometer reads a value around 80–90. In the extreme right position, the potentiometer readings are around 160–170. So, as long as the turning is done within the extreme values, the wheels can be turned left or right in steps of 20 or higher. 3.4. Infrared obstacle detection module The sharp infrared detector outputs a low voltage digital signal when it detects reflected infrared energy and a high digital signal when nothing is detected. The obstacle detection program has been developed using this principle. The infrared
502
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
Table 7 Step turning of steering wheels code pot ¼ analog(0); step ¼ 20; /*decrement step turn*/ if(pot > 90) &&(pot < 150) { stop ¼ pot-step; /*turning to the left*/ while(pot < ¼ stop) /*turn till stop is reached*/ { motor(1,mdir); mdir ¼ )50; pot ¼ analog(0); } }
Table 8 Infrared obstacle detection module code for(i ¼ 0;i < 5;i++) /*Repeat 5 times to eliminate false readings*/ { bit_set(0 1000,0 40); /*turn LED ON at 40 KHz*/ sleep(0.0005); /*turn it ON for 500 ls*/ val_on ¼ peek(0 1000); /*get detector reading when ON*/ bit_clear(0 1000,0 40); /*switch OFF the LED*/ sleep(0.0005); /*sleep for 500 ls*/ val_off ¼ peek(0 1000); /*get detector reading when OFF*/ if((val_off&val_on&4) ¼ ¼ 4)r[i] ¼ 1; /*bit-wise AND*/ else r[i] ¼ 0; if((val_off&val_on&2) ¼ ¼ 2)1[i] ¼ 1; /*bit-wise AND*/ else 1[i] ¼ 0; } for(i ¼ 0;i < 5;++i) { right ¼ right + r[i]; /*right detector readings*/ left ¼ left + 1[i]; /*left detector readings*/ } if((right ¼ ¼ 5)&&(left ¼ ¼ 5))ir_output ¼ 1; /*both detectors sense obstacle*/ else if(right ¼ ¼ 5)ir_output ¼ 2; /*obstacle is in right*/ else if(left ¼ ¼ 5)ir_output ¼ 3; /*obstacle is in left*/ else ir_output ¼ 0;
LED is turned ON for 500 ls and the detector readings recorded. After the time has elapsed, the LED is turned OFF and the detector readings recorded. Thus, from the two detector readings, the presence or absence of the obstacle can be determined as shown in the code in Table 8. The command bit_set(0 · 1000, 0 · 40) turns the infrared oscillator of the Handy Boarde ‘‘on’’ to transmit infrared signals at a frequency of 40 KHz. The microprocessor stays idle for 500 ls, while the signal is being transmitted by issuing the command sleep(0.0005). The contents stored in the memory address location 1000, is then copied onto the variable val_on. This is the reading of the detector
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
503
with the LED being ON. The LED is switched off by calling the function bit_clear(0 · 1000,0 · 40). The microprocessor stays idle again for a period of 500 ls and the detector reading is noted by reading the memory address 1000 onto the variable val_off. This is the reading of the infrared detector with the LED turned OFF. The variables are then bitwise added with the corresponding ports and the value of the array variable r½i is recorded. When the detector receives a signal during this process, val_off reads logic high, i.e. 1 and val_on also reads 1 or logic high. By ‘‘AND’’ operation with 4, the value of the third bit is calculated and checked with the port number. When the detector receives no signal, the Boolean operation results in zero and r½i is assigned zero. This whole process is repeated five times by using the for loop at the beginning of the program. At the end of five times, the right and left detector readings are summed up and stored as right and left variables. When both the right and left detectors record values of 5, the obstacle is present in front of the vehicle and the ir_output variable is assigned the value 1. When only the right detector records hits all the five times, the obstacle is present to the right of the vehicle and the ir_output variable is assigned the value 2. Similarly, when only the left detector sees the obstacle, the ir_output is assigned value 3. When no obstacles are detected, ir_output is assigned the value 0. It was observed during experiments that fluorescent lights output a lot of noise to which the infrared detector is sensitive and false readings could be recorded. Using the turn-on, turn-off strategy, as highlighted above, spurious obstacle detection can be eliminated. Alternately, the infrared frequency could have been modulated at 100 or 125 Hz before transmission by using the Interactive C special built in functions [12]. The detectors could also have been set to receive modulated signals. Modulation helps in eliminating a lot of spurious readings recorded by the detector. However, the method discussed works very well in detecting obstacles within the range of 10–11 in., which is sufficient for the vehicle to avoid collisions. 3.5. Collision detection module The vehicle employs bump switches to detect collisions with obstacles. As discussed earlier, there are three parallel sets of switches mounted on the front portion of the plate. When the vehicle collides with an obstacle, one or more of these parallel switches close and the corresponding digital sensor reading, digital (11) or digital (13) or digital (15) reads 5 V or logic high. By noting the variable bump_on as shown in Table 9, collisions can be recorded and safety actions can be taken. Table 9 Subroutine for collision detection int bump_on; void bump( ) { if(digital(11)kdigital(13)kdigital(15)) bump_on ¼ 1; else bump_on ¼ 0; }
504
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
3.6. Light detection module The CdS photoreceptors mounted on the front and back of the vehicle can determine the intensity of light in the front, left, right and back directions. The intensity of light falling on the sensor generates a corresponding fluctuation in voltage level and this fluctuation, is passed through an internal resistor and mapped linearly onto the numerical range 0–255 by the A/D converter. The algorithm shown in Table 10 determines the direction of the brightest light by checking with the ambient threshold and the sensitivity of the light sensors. The threshold values for the ambient and the sensitivity values were chosen after performing many experiments with the light sensors in different environments with various light sources. 3.7. Ultrasonic distance ranging The distance of obstacles and targets are determined by operating the Polaroid sensors in a single echo mode. In this mode of operation, after applying the power, the initiate signal line (INIT) goes high and a pulse train is triggered. Sixteen pulses at 49.4 KHz with 400 V amplitude excite the transducer during the transmission of the pulses. In order to help the transducer from misinterpreting the ringing as a return signal, the internal blanking signal (BINH) goes high for 2.38 ms after the initiate signal goes high. Once the transmitted signal returns after being reflected by the target, the ECHO output latches high. The time between the INIT signal going high and the ECHO output going high is proportional to the distance of the target from the transducer. The timing diagrams for the 6500-Series Sonar ranging Module executing a single-echo mode cycle is illustrated in Fig. 6 [11]. The distance can also be measured by firing the sensor in a multiple echo mode, where a single transmission detects multiple echoes [11]. The time of flight is calculated using the input-capture function of the 68HC11 timer architecture. When a selected high edge of the return signal is detected at the timer input pin, the time is instantaneously latched onto the 16-bit input-capture register [9,10]. An estimate of the distance of the obstacle can be made by keeping track of when the transmission began and the time of echo returned. One can then Table 10 Subroutine to detect direction of light 1_light ¼ analog(3); /*left light sensor*/ r_light ¼ analog(1); /*right light sensor*/ b_light ¼ analog(6); /*back light sensor*/ sensitivity ¼ 9; /*set the sensitivity*/ ambient ¼ 25; /*set the ambient threshold*/ diff ¼ (1_light-r_light)* (1_light-r_light) /*square difference in reading*/ if(diff < sensitivity)&&(r_light < ambient) /*light on front*/ else if(1_light > r_light)&&(r_light < ambient) /*light on right*/ else if(1_light < r_light)&&(1_light < ambient) /*light on left*/ else if(b_light < 25) /*light on back*/ else light_flag ¼ 0; /*no light detected*/
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
505
Transmit (INIT)
Pulse Train
16 Pulses
Internal Blanking (2.38 msec)
Echo
Fig. 6. Timing diagrams for single-echo mode.
Table 11 Sonar module code int dist; void radar( ) { ping(0); /*transmission and reception of sound pulses*/ msleep(35L); dist ¼ sonar_time/150; /*calculation of distance in inches*/ msleep(150L); }
estimate the distance of the obstacle. The sonar distance ranging module is based on Kent Farnsworth’s algorithm for the Polaroid Sensor [12]. The program is coded in assembly language and incorporated with Interactive C as an Interactive C Binary Program (ICB) File. The sonar module code shown in Table 11 is called whenever the target/obstacle distance has to be calculated. The function ping( ) executes the transmission and reception of the signals through software. The factor 150 used for the calculation of distance is based on the time of travel of the transmitted signal per foot and timing errors of the sonar ranging board and the 68HC11 microprocessor. 3.8. Obstacle avoidance behavior With this behavior, the vehicle has the ability to roam about in cluttered environments, avoiding obstacles in its path. The vehicle possesses intelligence to know that it has been trapped in certain situations and has the ability to escape out of such traps. The infrared sensors help the vehicle in detecting obstacles and the bump switches trigger safety measures when it collides with obstacles. The vehicle initially exhibited certain repetitive behaviors. These behaviors were detrimental to the robot’s performance and severely constrained the vehicle from
506
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
escaping out of entanglements. For instance in case (a), the vehicle goes forward, sees an obstacle, backs up until it cannot see the obstacle anymore, and then goes forward and the cycle repeats endlessly. Similar scenarios were noticed when one of the infrared sensors detect an obstacle, actuates the vehicle to turn, but when the vehicle does not have enough force to push its way through the obstacle, it is rendered immobile. In order to make the robot know that it has run into a repetitive situation and that it must extricate itself out of the trap, a variable ‘confused’ was included in the algorithm. This way, the program kept track of the value of the variable and whenever it exceeded a threshold value, the escape behavior was triggered. After performing many experiments with the vehicle a threshold of 8 was found to be sufficient for the robot to know that it has been entangled. The variable ‘confused’, true to the name indicated that the robot has reached a confused state of mind and needs to pull itself out of the quagmire. In order to determine how much time the vehicle must spend when the infrared sensors failed to detect an obstacle, investigations were carried out by placing the robot in many such situations. Finally, it was decided to have a simple for loop count 0–50, to calculate the time the robot is stuck. A variable speed was used to reduce the speed of the vehicle when it exceeded 15. Once the vehicle has realized that it has been trapped, extricating processes have to be carried out. The escape behavior included in the algorithm enables the vehicle to turn to a completely new orientation and start the whole process again. Experiments with the robot revealed that letting the vehicle turn by 90–100 from its original position gave it a more or less new route. The escape subroutine code is shown in Table 12. Before escaping, the vehicle plays a musical tune, when the function looney_tune( ) is invoked. The reset_system_time( ) sets the clock to zero and the while loop turns the car backward for 3 s. Inside the while loop, the vehicle turns left or right depending on which function tright( ) or tleft( ) is invoked and then backs up for 3 s. Table 12 Subroutine code to escape from trapped situations void escape( ) { a0(0); looney_tune( ); /*play music before escaping*/ reset_system-time( ); /*set the clock to zero*/ while(seconds( ) < ¼ 3.0) /*do for 3 sec*/ { if(analog(0) < ¼ 125) tleft( ); else tright( ); motor(3,)12); } a0(0); }
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
507
3.9. Light seeking behavior The light seeking behavior has been programmed based on the subsumption architecture, and uses the multitasking facilities of Interactive C. Obstacle avoidance by infrared sensors and collision detection by the bump switches have been added to facilitate the robot in its light seeking goal. Brooks’s [2] subsumption approach provides a way of combining distributed real time control with sensor triggered behaviors. Fig. 7 illustrates the subsumption architecture for the light seeking behavior of the vehicle. The sensors used are the light sensors, infrared sensors and bump switches. The behaviors are cruising, follow light, avoid obstacle and escape after collision. The obstacle avoidance behaviors are the high level behaviors and can subsume the low-level behaviors like cruising and following light. The behaviors are prioritized by the arbitrator and the winner takes control of the motors. In this method, only one behavior is the winner and outputs from other behaviors are simply ignored. The multitasking facility of Interactive C has simplified the use of subsumption architecture for the vehicle. The sensing modules are programmed as continuous C functions, interacting with each other through global variables. These global variables are assessed in the arbitrator algorithm, where they are prioritized and high level behaviors subsume the output of the low level behaviors. The winner issues the motor commands, which is coded in the motor control algorithm. The arbitrate function implements message passing between other processes. The function implements wiring instructions through an ordered list of statements as shown below. When multiple outputs are directed to the same output, those occurring later in the list of connections subsume the earlier ones. The modules are programmed as separate processes and are executed for a certain number on. This is done during the process inception in the MAIN program. This way, modularity is maintained in the program and it is relatively easy to add new behavior layers.
Bumper
Escape Collisions
IR Detector
Avoid Obstacles
Light Sensors
Follow Light
S
Cruise
Motors S
Indicates suppression
Fig. 7. Subsumption architecture for the vehicle.
S
S
508
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
In the cruise module code shown in Table 13, cruise_on and cruise_flag are the two global variables that are used to communicate with other processes. The remaining part of the program is closed within a while (1) loop. This way, the process functions for an indefinite period of time. But due to time slicing, the module is called and operated for only a particular time slice. Then, the control is passed to the next process in stack. The defer( ) function passes control to the next process without wasting any time if the time slice for that process is not yet complete. The arbitrator subroutine (Table 14) sends the variable motor_in as the global output. The program is also enclosed within the while (1) loop which runs the process for an indefinite period of time. When the process output flag becomes true, the motor command is issued the value of the process output. For instance, when the light detection program detects the light, the variable light_flag is true and thus motor_in is assigned the output value of light_com. The variable light_com could indicate the presence of a light source in the left, right, front or back directions. As higher level behaviors are invoked, the previously issued motor commands are overwritten and motor_in takes the value of the highest invoked process output. This way, low-level behaviors are subsumed by the higher-level behaviors and the winner passes the command to the motor controls. Table 13 Cruise module code int cruise_com; /*global variable*/ int cruise_flag; void cruise( ) { while(1) /*continuous program*/ { cruise_com ¼ 100; cruise_flag ¼ 1; defer( ); /*goes to the next process*/ } }
Table 14 Arbitrator subroutine code int motor_in; void arbit( ) { while(1) { if(cruise_flag ¼ ¼ 1) motor_in ¼ cruise_com; if(light_flag ¼ ¼ 1) motor_in ¼ light_com; if(ir_flag ¼ ¼ 1) motor_in ¼ ir_com; if(bump_flag ¼ ¼ 1) motor_in ¼ bump_com; defer( ); } }
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
509
Table 15 Process inception module code int pid[6]; void main( ) { sleep(1.5); tone(1000.0,1.0); tstr( ); sleep(1.0); /*assigning process ID’s to all*/ pid[0] ¼ start_process(collide( )); pid[1] ¼ start_process(obstacle( ),30); pid[2] ¼ start_process(light( ),50); pid[3] ¼ start_process(cruise( )); pid[4] ¼ start_process(arbit( )); pid[5] ¼ start_process(mot_con( ),100); }
All the processes are started in the process inception module (Table 15) by calling the start_process( ) function. The variable pid[6] is an array of integers that hold the process identification numbers of all the processes that are created in this module. The processes have been assigned different time slices in the start_process( ) command. For example, start_process(light( ),50) assigns 50 ms as the time slice for light detection module. The processes have been given process identification numbers, so that they can be eliminated and/or started dynamically during the running of the program. The obstacle avoidance process has been assigned 30 ms, the light seeking 50 ms and the motor control process 100 ms of the time slice. Other processes are using the default 1 ms to perform their functions. The number of ticks for these processes was arrived at after extensive investigations and research with the time slicing technique. The defer statement stops the current process from executing further and goes onto the next process in stack.
4. System implementation and testing The various program codes developed for the robot’s behaviors are loaded into the memory of the Handy Board’se microprocessor using appropriate downloading facilities with a PC interface. Once the programs are downloaded, the vehicle was able to operate under their influence and the response of the various sensors was tested. 4.1. Sensor characteristics The sensors employed on the vehicle were independently tested for their behavior performance under different environmental conditions. This section discusses the variations in the sensor’s output with some specific environments such as reflecting
510
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
surfaces, obstacle arrangements and ambient light conditions. The tests were conducted under specific conditions and all the sensor characterization results are dependent on the test settings. The sensor characterization was carried out for the infrared reflectance sensor, sonar sensor, infrared sensor and the CdS light sensor. 4.2. Infrared reflectance sensor characteristics The reflective sensor QRB114 purchased from DIGIKEY was tested for the variation in reflectivity of surfaces. The focused reflective sensor assembly consists of an infrared emitter and a detector. The emitted radiation follows a diverging pattern rather than a straight line through its center and the detector views a converging pattern rather than a straight line through the center. The sensor was plugged into the analog port and different surfaces were placed underneath the sensor. The values recorded by the A/D converter were noted and the following observations were noted. • Shiny metal surfaces like aluminum foils gave the best reflectance. • Waxed floors and white bond sheets were also good reflectors. • Graphite pencil shades on white paper gave relatively small changes compared to plain white paper. The reason could be that the smeared shiny graphite improves reflectivity by filling the pores of the paper. • Colored tapes gave little differences in the readings. • Plastic surfaces do not reflect as well as polished surfaces. • 3 M black duct tape that was shiny reflected well even though the color was black. • 7 MIL vinyl electrical tape recorded very high values and was found to be an excellent non-reflecting surface. • Ordinary white tape sprayed with black enamel paint also served as good non-reflecting surface. 4.3. Infrared detector characteristics The Sharp IS1U60 infrared demodulator was subjected to extensive testing with different materials and the following observations were seen. • The Sharp demodulator gives a low digital signal whenever a 38 KHz frequency infrared beam falls on its receiving surface. • All other times the detector recorded a high digital signal. • The sensor picked up stray signals from the emitter LED and had to be properly shielded. • Obstacles covered with aluminum foils were easily detected compared to uncovered obstacles. Obstacles covered with white paper were also easy targets. • The sensor often missed plastic obstacles like waste paper boxes. • Narrow and thin obstacles like chair legs could not be easily detected.
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
511
4.4. Sonar sensor characteristics The Polaroid sensor was subjected to many tests based on the orientation of the obstacles. The sensor recorded inaccurate readings for some specific arrangements that are discussed in detail in this section. The sensor was very effective in detecting various kinds of obstacles like walls, boxes, plywood, sponges, towels, and chairs. The distance range that the sensor could detect was around 17 in. to 15 ft. and significantly less than that specified by the Manufacturer (6 in. to 35 ft.) [11]. In the arrangement shown in Fig. 8, the reflected beam did not return back to the transducer. Hence, the sensor was unable to detect the wall. Studies by Everret [5] have postulated that when the angle of incidence of a sonar beam decreases below a certain critical value, the reflected energy does not strike the transducer. This critical angle depends on the operating frequency chosen and the topographical characteristics of the target surface. For the Polaroid electrostatic transducer, Everret [5] found the critical angle to be approximately 65 for a flat surface made of unfinished plywood as shown in Fig. 9. The error in the sensor reading is due to the phenomenon of specular reflection. Below the critical angle, insufficient reflected energy is returned to strike the transducer. This occurs because most of the targets are mirror smooth at the 0.25 in. wavelength of ultrasonic energy. In specular reflection, angle of reflection equals angle of incidence. However, in diffuse reflection, energy is scattered in various directions by surface irregularities. In a similar arrangement shown in Fig. 9, the
b
A =65°
a
Wall
Fig. 8. Critical angle for the polaroid transducer.
C
Ranging System
A
Obstacle
B Obstacle
Fig. 9. False reading by the sonar sensor.
512
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
sensor recorded the distance for the round trip through A, B, and C as opposed to just A and B. Many such false readings were recorded as the test arena for the sensor was a room cluttered with obstacles. 4.5. Light sensor characteristics The characterization of the CdS photoresistor was accomplished by taking readings from two light sensors at 6-in. intervals and shining a flashlight in a completely dark room and in a room illuminated with fluorescent lights. Fig. 10 illustrates the response curve in the dark room. Fig. 11 represents the response curve for the case where the room is lit with fluorescent lights. The ambient light was powerful and the sensors recorded a value of 8 and 9. In the dark room, the sensitivity reduces as the sensor is unable to detect small changes in the illumination levels and maps them to a high value (180). Although the curves are not exactly linear, certain sections can be approximated as linear. Moreover, the graphs indicate how close the two sensor readings are in their response. This verifies a good repeatability from sensor to sensor.
Sensor Readings
Response Curves In A Dark Room 80 70 60 50 40 30 20 10 0 6
12
18
24
30
36
42
48
54
Distance in Inches
Fig. 10. Response curve of light sensor in a dark room.
Sensor Readings
Response Curves In A Well Lit Room 9 8 7 6 5 4 3 2 1 0 12
18
24
30
36
42
Distance In Inches
Fig. 11. Response curve of light sensors in a well lit room.
48
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
513
4.6. Testing of behavior algorithms The vehicle behaviors were tested in a room cluttered with various kinds of obstacles. A flashlight was used to control the vehicle’s behavior in terms of following light. The vehicle performed exceptionally well in detecting obstacles and avoiding them. There were instances where it got stuck in repetitive situations, but the intelligence programmed into the algorithms helped it to extricate itself from the situations. Several micro-tests were performed to track the exact behavior of the vehicle. For instance, the vehicle path was completely blocked with boards forcing it to choose alternate paths. Sometimes, the blocked path would be suddenly removed and the vehicles’ instant reaction was noted. These tests proved that the vehicle is smart and intelligent enough to respond to changing environments.
5. Conclusion A mobile autonomous smart vehicle was developed which can exhibit specific behaviors in terms of obstacle avoidance and light seeking. The Handy Boarde was used as the robot controller for the vehicle. Sonar, infrared, light, reflectance and bump sensors were interfaced with the Handy Boarde and the vehicle to achieve the smart behaviors. The behavior algorithms were coded using Interactive C. The sensor characteristics were studied and some interesting observations were highlighted. The system provides facilities for immediate testing of the behaviors by downloading it onto the vehicle. Thus, rapid prototyping of the vehicle’s behavioral design intent can be verified. In today’s environment the necessity for international security and public safety can not be over emphasized. In this context and in many other industrial applications, the design and development of an autonomous mobile robot that exhibits smart behaviors can play a large role in increasing the effectiveness of problem solving approaches.
References [1] Black Phantom II Technical Specifications. Copyright Radio Shack Corporation, 1995. [2] Brooks RA. A robust layered control system for a mobile robot. IEEE J Robot Automat 1986;RA2(1):14–23. [3] Brooks RA. Elephants don’t play chess––designing autonomous agents. J Robot Automat Syst 1990:12–23. [4] Dinsdale J, Yamazaki. Mechatronics and ASIC’s. Annals of CIRP 38, 1989. [5] Everret HR. Sensors for mobile robots––theory and application. Wellesly, Massachusetts: A.K. Peters; 1995. [6] Gerald DM. A simple ultrasonic ranging systems. Presented at the 102nd Convention of the Audio Engineering Society at Cincinnati, Ohio, May 12, 1993. [7] Hendrik MJ, Van Brussel. Mechatronics––a powerful concurrent engineering framework. IEEE/ ASME Trans 1996;1(2):127–9. [8] Hewit J. Mechatronics design––the key to performance enhancement. Robot Automat Syst 1996;1:135–42.
514
B. Gopalakrishnan et al. / Mechatronics 14 (2004) 491–514
[9] Motorola M68HC11 Reference Manual, 1991. [10] Motorola M68HC11 Technical Specifications Manual, 1991. [11] Polaroid 6500 Series Ultrasonic Ranging System Technical Notes, 1996, Copyright Polaroid Corporation. [12] Resource Materials on the Handy Boarde on the World Wide Web. Available from:
. [13] Tirunellayi S. Design and development of a mobile smart vehicle: a mechatronics application. MS thesis, West Virginia University, 1997.