Final Project – Color Tracker Hexapod
CHAPTER I
INTRODUCTION
Real-time systems become important in the last century, along with the development of high-technology machines. This includes the creation and innovation of computers and all the machines that use the computers in all scales. These lead to the start of real-time systems in our scientific lives.
Computer systems are included in different kind of systems which have a high value, such as the computer systems that control airline companies, computer systems that control high value scientific equipment, and other computer systems that humans’ lives depend on. Airplane’s control system is one of the systems that have a great responsibility in humans’ lives, because the real-time systems have to be perfectly accurate in order to fly safely and securely.
The need of systems that compute with the aim to finish within certain amount of time and getting correct results (in contrast with other computer systems that do not require the answer to be within some predefined amount of time, but of course correct results) evolved, and nowadays, with the high advances in the computer industry, the divining line between these two major divisions of computer systems is becoming blur.
Embedded real-time systems have 2 major subdivisions, event-driven systems and time-driven systems. Event-driven systems have advantages so that they can be considered as hot plug systems; we can add nodes to the system without knowing a prior requirement of the process we add, in contrast with the time-driven systems which require that knowledge.
Raspberry Pi, as a Single Board Computer which has a base Operating System of Linux, has become really helpful in innovating the real-time systems. It has come to our knowledge that Linux is an open-source OS that can program python really quick. With the help of Raspberry Pi and OpenCM, I could make a car that can be driven to move with an event-driven algorithm implemented. Camera is used as the object tracker which could make events that could drive the real-time systems.
CHAPTER II
HARDWARE DETAILS AND SPECIFICATIONS
- Raspberry Pi
Fig. II-1 Raspberry Pi Model B+
Here is the diagram of GPIO ports and others in Raspberry Pi B+.
Fig. II-2 GPIO Ports in Raspberry Pi B+
- OpenCM 9.04 (Arduino-based)
Fig. II-3 OpenCM 9.04’s Physical Appearance
Here is the block diagram of OpenCM 9.04 system, which is based on Arduino systems:
Fig. II-4 System’s Block Diagram of OpenCM 9.04
Here is the GPIO ports and others on OpenCM 9.04:
Fig II-5 GPIO Ports on OpenCM 9.04
- Serial(USART) : 11(TX1), 12(RX1), 4(TX2), 5(RX2), 24(TX3), 25(RX3)
- PWM : 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
- SPI : 0(SS1), 1(SCK1),6(MISO1) ,7(MOSI1), 18(SS2) ,19(SCK2)
,20(MISO2) ,21(MOSI2) - LED : 14 (BOARD_LED_PIN is defined as 14)
- BUTTON : 23 (BOARD_BUTTON_PIN is defined as 23)
- TWI(I2C) : 24(SCL2), 25(SDA2)
- RST : Pin connect to the CPU Reset signal.
- 5V : outputs 5V when the battery is connected to the board. (Does not
output 5V when USB only the USB cable is connected.)\ - 3V : outputs 3.3V when the power is supplied to the board via battery or
USB cable. - GND : GROUND(-) terminal.
- XL-320 Actuator
Fig. II-6 XL-320 Servo/Actuator
- Weight : 16.7g
- Dimension : 24mm *36mm * 27mm
- Resolution : 0.29° Motor : Cored Motor
- Gear Reduction Ratio : 238 : 1
- Stall Torque : 0.39 N.m (at 7.4V)
- No load speed : 114 rpm (at 7.4V)
- Running Degree
- 0° ~ 300°
- Endless Turn
- Running Temperature : -5℃ ~ +70℃
- Voltage : 6 ~ 8.4V (Recommended Voltage 7.4V)
- Command Signal : Digital Packet
- Protocol Type : Half duplex Asynchronous Serial Communication (8bit,1stop,No Parity)
- Link (Physical) : TTL Level Multi Drop (daisy chain type Connector)
- ID : 253 ID (0~252)
- Communication Speed : 7343bps ~ 1 Mbps
- Feedback : Position, Temperature, Load, Input Voltage, etc.
- Material : Engineering Plastic
CHAPTER III
SYSTEM IMPLEMENTATION
- Hardware and Software System
Fig III-1 Hardware Block Diagram with Data Communication Protocol
SBC used in the system is Raspberry Pi, which powered by the 5 DCV and 2 Amp minimum, while microcontroller used is the OpenCM 9.04 which bases Arduino as its system. The system goes from Raspberry Pi connected with Logitech Webcam detecting colored objects (Red, Green, and Blue) to send the values of position X and Y as the center of contours detected to OpenCM. OpenCM reads them, and sends commands to Servos XL-320 to move as they are defined. The claw is commanded through Serial Port 3 on OpenCM, while the left servo for left leg and right servo for right leg are commanded through Serial USB port. The servos move the whole body, which affects the position of X and Y of the contours. It makes the robot keeps following the colored object wherever it goes, in the limit of the camera’s range of view.
- System Implementation
Fig. III-2 Colored Object Tracker using Logitech Webcam C550 on Ubuntu 12.04
This is implemented on VMWare I have been using on my Windows Laptop. The OS on the VMWare is Ubuntu 12.04 LTS, and I use Python 2.7.3 and OpenCV 2.4.11 to make this color tracking system happens. Contours are used in this system to detect blue, red, and green colored objects, and it gives the center of contour shown by the red dot in the middle of the contours. The values are the position X and Y, which determine the x-y coordinates of the frame window.
Here is the picture of color tracking algorithm detecting 2 colors at the same time with each center mass of the contours:
Fig III-3 Colored Object Tracker detecting 2 different colored objects at the same time
Using the serial command on Python, the camera is able to send the position of X and Y to OpenCM 9.04, which drives the servos to move.
Fig. III-4 Picture of the Webcam mounted on the servo to test if the servo makes the camera following the blue color
As shown above, the camera is mounted on top of the servo to make it moves following the blue colored object (the ruler). The algorithm is made such that whenever the ruler goes right, the camera rotates clockwise, and vice versa. When the ruler is in the center of the camera, the algorithm is made to make the servo stays still. The video can be seen on youtube:
https://www.youtube.com/watch?v=l_tcGyNL7uc
Here are the setup of the robot with Raspberry Pi, OpenCM, XL-320, and Webcam attached altogether to create a color tracking hexapod robot:
Raspberry Pi on the top
OpenCM on the back
Camera on the front of the robot (as the eye)
Here are the full images of the robot:
Front View
Back View
Side View
The Raspberry Pi commands the Camera to get the center mass of the contours, and get the x-y coordinates in the form of X and Y values to be sent to OpenCM as a serial data. X values can be sent using serial USB port, while Y values can be sent using serial port number 3 on OpenCM, using RX, TX and GND on Raspberry Pi OpenCM. RX on Raspberry Pi has to be connected to TX on OpenCM,, and vice versa. The coordinate X determines the movement of the wheels/legs so it will follow the colored object wherever it goes. The coordinate Y determines the claw to start picking up the object whenever the object is close to it.
The video of this robot working can be seen on youtube: