Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent...

18
University Of Florida 18-Sep-13 Reinaldo Molina EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Reinaldo Molina Robot: “The Patrolling Android” EEL 5666 Intelligence Machine Design Laboratory Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD Teacher Assistants : Devin Hughes Josh Weaver Andy Gray 1

Transcript of Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent...

Page 1: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

Reinaldo Molina

Robot: “The Patrolling Android”

EEL 5666 Intelligence Machine Design Laboratory

Instructors: A. Antonio Arroyo, PhDEric M. Schwartz, PhD

Teacher Assistants: Devin HughesJosh WeaverAndy Gray

1

Page 2: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

Table of Contents

Abstract...................................................................................................................... 4

Executive Summary....................................................................................................5

Introduction................................................................................................................6

Integrated Systems....................................................................................................7

Actuators..................................................................................................................10

Mobile Platform.........................................................................................................11

Sensors.....................................................................................................................12

Behavior...................................................................................................................13

Conclusions..............................................................................................................14

Appendices...............................................................................................................15

2

Page 3: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

AbstractThe purpose of building this robot is to detect human presence. It will achieve

this using Open Computer Vision libraries and camera on board. The robot attempts this operation by first doing color detection; if the previous is true this is followed by face detection. In the case that the previously mentioned two behaviors are true the robot snaps a picture of the person sends it to a remote computer using WiFi and stores a backup in hard drive. The scope of this project is to build a robot with a useful application. That application for this project is to develop a self sufficient autonomous robot that patrols an area in search of intruders. In its current state case the intruders are persons wearing red shirts. But in the future this could be much further develop to much more specific targets or wide variety of targets.

3

Page 4: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

Executive SummaryThis project makes use of two main innovative pieces of software: ROS (Robot

Operating System) and OpenCV (Open Computer Vision). ROS is more of framework that facilitates communication between different computer programs running at the same time. OpenCV is an open library with many tools at its disposal that makes image processing available to the beginner software developer. Infinite possibilities are achievable through the use tools.

Moreover, the use of a Remote Control Car was made to facilitate mechanical and electrical design. Further in this document there is more information about this vehicle and how is controlled, but it is used as the moving platform of the electronics compartment. Onto this several pieces of hardware were mounted to make possible goal of this project. For instance this robot is made of a ODROID – U2, for brain, 3 sonars, for obstacle avoidance, a camera, to satisfy its main purpose, and a ATxmega128A4U development board, that makes possible the interfacing of the ODROID with vehicle and the rest of the sensors and hardware. This electronics compartment its not sophisticated in design but fulfills its main purpose of housing and protecting all the additional hardware to make this project possible. Its shape of a rectangle, held together by 6 L-Brackets. The material used is Polycarbonate; this a strong and easy to customize transparent plastic.

4

Page 5: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

IntroductionRobotics is a field that is making huge technological advances by the day.

Robots already form a big part of our everyday life. For instance, traffic lights, traffic cameras, automatic toll payments, smart phones, smart cars, all of these are operating on the basics of robotics. They may not follow the popular concept of a robot which has a humanoid form and talk like a computer by they are intelligent and flawlessly follow a programmed behavior.

This served as my inspiration to show that how we can integrate with all this software that already exists and put it to use in some other areas. That is the idea behind The Patrolling Android; it has sensors that allow it to interact with the rest of the world. It has sonars that allow it to avoid obstacle, and a camera with which it can see the world and be programmed for infinite number of behaviors and uses. Moreover, it uses WiFi to communicate.

In this paper all the information about The Patrolling Android can be found. What is it current state, what is current programmed behavior, how it was achieved and what can be improved.

5

Page 6: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

Integrated SystemsThe main component, or Higher Level Board, of the robot is going to be the

ODROID – U2. This powerful component controls the Input/Output(I/O) Board and Camera. The I/O Board, or Lower Level Board is an ATxmega128A4U development board. This board interfaces with the sonar sensors, LEDs, servo controller, and motor controller. In Figure 1 we can see a diagram with a visual representation of the Integrated Systems. In this diagram Red Lines represents Serial Communication while Black Lines represent command and information.

Figure 1Moreover, there are 2 batteries used to power the robot. One of the batteries

powers the chassis. The chassis contains a motor and a servo. The power from the battery goes to the ESC (Electronic Speed Control). The ESC controls the voltage and power's the Remote Control Receiver. The servo that is used to steer the front wheels and the motor take power and signal from the Receiver. Here, adjustments were made so that the motor and servo take power from the receiver but the signal comes from the Atxmega Board. To make this possible a ground connection from the Electronics Enclosure was made to the Remote Control Receiver.

The Atxmega Board is program with the objective of doing the least processing possible in this platform. This board does not do any conditional processing. Its function is to wait for serial commands from the ODROID Board, when this happens distributes the commands to the servo and motor, blinks the feedback LEDs in a pattern told by the Higher level board and responds with the current motor state and the Sonar Value readings.

The higher level board is in charge to do all the processing. It has a loop cycle of 10Hz in all its nodes. Nodes, refers to Robot Operating System (ROS) nodes.

6

Page 7: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

EngineeringWhere each node represents a piece of code that controls a behavior. For instance, all the OpenCV processing that the higher level board does is a ROS node. This nodes process all the Video Camera Stream and reports to the main node when there are any changes. Moreover, this node also in the case that it detects a person wearing a piece of red clothing, sends that Video frame to another node that runs on a remote computer. This is another great possibility that ROS offers. The possibility of running nodes of the same workspace on different computers that communicate over WiFi. Another piece of code that runs on a remote computer is one that takes receives communication from an Xbox Controller and converts them into ROS messages. These messages are translated into commands that the Patrolling Android understands and this way it can be remote controlled from the distance.

The previous mention describes the 3 main nodes that control the robot behavior. Pseudo Code is provided for each of the nodes below:

• AtxmegaTalker Node:

◦ Sets up the serial communication with the Atxmega board

◦ Writes 4 commands over serial

▪ Servo Command

▪ Motor Command

▪ Camera Servo Command

▪ Error Command

◦ Waits for an answer from the lower level board in the following format▪ Sonars values(Left Sonar, Center Sonar, and Right Sonar Values)

▪ Error Command

◦ It then proceeds to Receive messages from the other nodes

◦ If the message comes from the Remote Control Node

▪ A faster loop rate is set up to avoid lagging from slower 10Hz loop rate

▪ Convert Xbox controller commands to Robot commands

▪ Transmit this commands.

▪ Repeat until certain Xbox command comes

▪ When it does we exit this inside loop and go back to default behavior

• The way that the buttons on the Xbox controller are configured to control the Patrolling Android is the following:

◦ A button: Enables Remote Control Capabilities

◦ B button: Disables Remote Control Capabilities

◦ Right Trigger : Produces Forward Threshold or Brake in case of Reverse Throttle

◦ Left Trigger: Produces Reverse Threshold or Brake in case of Forward Throttle

7

Page 8: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering◦ Left Cross Button: Results in Left steering

◦ Right Cross Button: Results in Right Steering

◦ If the message does not come from the Xbox Controller and does not come neither from the OpenCV Node obstacle avoidance behavior follows.

◦ This behavior is repeated until an error presents.

• OpenCV node

◦ Initializes the camera and the ROS Node

◦ If there is no error initializing it enters its main loop

▪ In this loop it constantly grabs a frame from the camera

▪ Process it looking for an area big enough of the red color.

▪ If it finds an area big enough it proceeds to do face detection using OpenCV Haar Classifiers.

▪ If a face is detected it circles the face and sends the frame to a remote computer; just in the case that the remote computer is not active it makes a copy in its hard drive.

▪ While the red blob is tracked this node sends the motors the signal to stop and proceeds to calculate the x coordinate center of the red blob. And face detection is not done anymore. This means that it only sends the first frame captured from the person. This was done to avoid heavy processing time.

▪ It then sends the Camera Servo the signal to turn based on the X position of the red blob.

▪ Once it looses the red blob, the area is below the threshold, it resumes Patrolling behavior.

▪ This behavior repeats as long as no errors are encountered in the camera or abrupt exit of program.

8

Page 9: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

ActuatorsPreviously was mention that the mobile platform is a Volcano EPX RC car. This

vehicle is controlled by bypassing the Remote Control Receiver on board and sending commands from the ATxmega Board directly to the Servo and Motor. Firstly, an oscilloscope was connected to the receiver to analyze the kind of signal it was sending to the motor and servo. Then, this signal was reproduce on the Atxmega Board and movement was achieved. Below is the explanation of the results obtained from the oscilloscope readings.

Figure 3For instance, in Figure 3 is appreciable that for the motor not to move, a Pulse

With Modulation (PWM) signal with a frequency of approximately 54Hz was required. Moreover, at 500 µs per division the time this signal is high is slightly over 1500 µs. Following the same procedure all the values were obtained to move the motor and wheels in all directions. Also an excel document was created to help with the PWM and USART calculations. Figure 4 shows a screen shot of the document. Please contact me if access to this document is desired. The document does all the PWM

9

Page 10: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineeringvalue calculations provided that you input the correct values and is compatible with your Microcontroller and PWM mode.

Figure 4

Backwards throttle turned to be one the most challenging aspect faced on the development of this robot. The way Remote Control (RC) cars break inertia, forward and backwards is by issuing a PWM equal in magnitude, to the current PWM, but subtracted from the idle PWM value. For instance, given Atxmega PWM configuration the period value for the motors to be idle is 3200, full forward throttle is 3600, and full reverse throttle is 2800. Therefore, in the case the current throttle is forward and reverse throttle was desired; the procedure is to break issuing reverse throttle until the RC would be physically stopped. Sending idle throttle, and then sending reverse throttle PWM again. Arriving to this realization took many hours of tests and frustration. The main problems was that batteries would only provide approximately 15 min of runtime, and then would take 6 hours to recharge.

This presented problems because the main idea was to obtain response from the RC at a rate of 10 Hz (0.1s). The workaround was to code in software that when

10

Page 11: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineeringa change of direction was desired it would idle the RC for 1s waiting for the wheels to be physically stop, while still keeping 10Hz rate communication, and then send the reverse direction signal. Given that the RC is being driven at only ¼ of its speed capabilities and adjusting the sonar values to warn in a timely manner when an obstacle is encounter this turned up to be the best solution.

11

Page 12: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

Mobile PlatformThe chassis of the robot is a Volcano EPX Remote Controlled Car. I choose this

because it would facilitate enormously my mechanical design, leaving me more time to focus on the Electrical and Software design. This vehicle is equipped with an electric brushed 27T 540 motor, forward/reverse transmission, four wheel drive, and a high torque servo. It also comes with a polycarbonate body scheme, huge soft compound RC off road tread, and aluminum capped oil filled shocks. Figure 2 shows the dimension of the car along with a picture of it.

In addition an Electronics Compartment box was made of Polycarbonate. This compartment sits on top of the chassis of the RC. Inside all the electronics components are securely mounted and interconnected. All the sides of the box are held together with L-brackets and 8mm screws. To hold the top lid closed, magnets were used to keep it in place. This box sits on top of 4 pins that come out of the RC car. Holes were carved on the bottom of the box making it securely held to the RC and very resilient to vibrations.

Figure 5

12

Page 13: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

EngineeringIn addition, 3 holes were drilled to the front of the Electronic Compartment to

mount the Ultrasonic Sensor. The 2 side holes were drilled at an angle make in it possible to give the desired inclination angle to each Sonar. For instance, the left sonar is inclined 45 degrees to the left with the respect to the flat front surface. The center sonar is perpendicular to the surface at 90 degrees. And the right sonar is inclined 45 degrees to the right. This makes it possible to cover wide 160 degrees arch since each sonar has a cover range of 30 degrees to each side of its angle.

13

Page 14: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

SensorsThe sensors that the Patrolling Android uses are sonars and a camera. The

sonars are used for obstacle avoidance and are placed in the front of the car. For Surrounding Ambience detection a Camera is used. The camera is mounted to a servo that allows for rotatory movement in the x coordinate. As can be seen in Figure 6. The sonars are from MaxBotics, and the type LZ-EZ1. Three sonars of this type are positioned in the front of the vehicle. They are positioned in such a way that each is within 45 degrees of inclination of each other. Figure 6 shows how the sensors are mounted to the front of the platform.

Figure 6They are arranged in a continuous looping daisy chain way. Moreover,

continuous looping refers that they are constantly taking measurements. And daisy chain means that they have circuitry that triggers them one at a time. This is convenient given that provided the proximity they have to each other if they were

14

Page 15: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineeringto trigger all the same time this would interfere with the measurements. A graphical representation of this circuitry is shown in Figure 7 below.

Figure 7

Moreover the readings from the ATxmega Board of the sensor are through the Analog to Digital Conversion feature. A connection is made from the analog pins of the ATxmega board to the AN pin of the sonar. 5 Volts and Ground are provided to the sonar from the Terminal Block. In addition each BW pin on the sensor is pulled high from the digital pins on the ATxmega Board. The sensor that kick starts the continuous looping is the right sensor to which the initial 20 µs high signal is also provided.

15

Page 16: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

BehaviorThe Patrolling Android has 2 main behaviors. Obstacle avoidance while doing

Blob Detection, and Remote Control. When the robot its first started, its default behavior is to avoid obstacles, while doing Blob detection. This means that the sensors are constantly reporting data, while the camera is constantly looking for the a Red blob with enough area. If a red blob is encountered, the robot stops and detects if there is a face in the same frame of the color. This behavior is repeated while the red blob area is big enough. If there is face with its center in plus minus range of the center of the red blob area; it sends the current video frame as a ROS message to a listening node running on a remote computer. Just in the case that there is no remote computer listening it stores a copy of that frame in its hard drive. The next step is that while the red blob is of enough size it will turn the Camera in the direction in which the center point of the red blob turns. Moreover, if the Y coordinate of the red blob is below certain threshold it moves forward trying not to loose the person. In the case that it looses the person, by the area of the red blob not being big enough, it falls back to it default behavior of just avoiding obstacles and looking for a red blob again.

In addition to the previously described, at any point in time it is possible to connect an Xbox Remote Controller to the remote computer and gain full control over the robot.

Once Remote Control Capabilities are enable Obstacle Avoidance while Detecting Red Blob Behavior is eliminated. As soon as the B button is pressed on the Controller this behavior is restored.

16

Page 17: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

Conclusions

Current limitations of this project is that it was originally intended to work outdoors. But with the current placement of its sonars, tall grass or slight inclinations in the field obstruct its view. Moreover, Y coordinate target following was also attempted but when the camera moves its X coordinate to track the target, this movement drastically affects the Y coordinate points resulting in false center points.

There is however, much space for improvement. A GPS and magnetometer can be implemented to not only report a picture of the person but also the robots coordinates. Moreover, software can be written to be able to change the robot behavior in real time. For instance, tell it to follow the blue color instead of the read, or not track a face but only the blue color, or to search only for faces.

Some mistakes that were made on the making of this robot that could be fixed, if the project was to start from scratch would be to use a Lithium Polymer battery. The current Nithium Hydrogen batteries provide the Electronics Compartment with about 1 hour of continuous runtime but the motors only about 15 minutes. This was a major setback in this project given that once drawn out these batteries take close to 8 hours to recharge making the testing process very difficult. In addition, Lithium Polymer batteries not only provide ample hours of continuous use but also are 80% lighter and recharge in 1/8 of the time the Nithium Hydrogen do.

Moreover, a better material should have being chosen for the Electronics Compartment. Polycarbonate is a very strong material but is very heavy at the same time. This was another factor that heavily contributed to the quick discharge of the batteries.

17

Page 18: Instructors: A. Antonio Arroyo, PhD Eric M. Schwartz, PhD · 2013. 12. 6. · EEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical Engineering Abstract The purpose of building

University Of Florida 18-Sep-13 Reinaldo MolinaEEL 5666 Intelligent Machine Design Laboratory 4 EG Electrical

Engineering

Appendices• The Patrolling Android website's:

◦ https://sites.google.com/site/thepatrollingandroid/

◦ In this link supplementary documentation can be found. Including weekly progress reports, Engineering Notebook drawings, preliminary concepts generated, and drawing designs.

◦ Moreover, progress videos, and link to code develop is also reported in the link.

• Program Code:

◦ http://github.com/rmolin88

18