Introduction: Robot Object Tracker Using CV
This is a project we have completed for our robotics class. It utilizes OpenCV to track objects' location by colour. Then location information is translated into commands which directs the robot to a green target through a microcontroller.
Step 1: Getting Materials to Build a Moving Robot
2 DC MOTORS ( 6v / you can use higher voltage rated motors but we used 6v so that we can use the battery pack to power both Arduino as well as the Motor without using a voltage regulator.)
1 robot base to mount the motors and battery holder.
1 Arduino UNO / MEGA / any Arduino.
Motor shield or H-Bridge Motor Driver ( i used Texas Instrument SN754411 )
Battery and / or battery holder if you want to use a few AA batteries to power up the robot and the Arduino
Step 2: Putting the Robot Together
1. Drill holes to the base / or use a laser cutter to cut holes to allow wires to go through
2. Screw the motors, battery holder to the base.
3. Solder the wires to the end of the motors
4. Get the wires on the top of the base so it is easier to connect to Arduino and the motor drive.
Step 3: Make the Motor Driver
1. Search for the Pin-out for SN75441ONE or goto http://digitalmedia.risd.edu/pbadger/PhysComp/?n=D...
they have a good instruction on how to connect the motor driver to the motors and Arduino
2. Solder the wires together, and add 1uF capacitor between output pins ( 4 in total ) to the ground in parallel to reduce noise.
Step 4: Connect the Motor Driver to Arduino
1. Upload the Arduino code to the Arduino.
2. Connect Pin 2 and Pin 15 to PWM output on Arduino, I used Pin 8 and 9. they are used to control the speed of which the motor will be rotating.
3. In the serial monitor on the Arduino IDE, type 0, for stop, type 8 and 9 for turning left or right fast. type 5 for straight. you can add more cases to Arduino code if you want the robot to do some other things. But try putting those commands in first to make sure the robot is working properly.
Step 5: Setting Up CV
1. Download the OPENCV libraries from their website.
2. Import the libraries to your IDE of choice. The visual control code is in C++ and was compiled and run using Visual Studio 2012 where you can find many instructions on how to use the OPENCV libraries with Visual Studio on Youtube.
3. Download attached code. Make sure that you have a webcam installed with the appropriate drivers.
4. The code was based on a tutorial on Youtube for multiple colour tracking using OPENCV. Check out tutorial here for instructions on how to calibrate the program to detect certain colours.
The modified version is attached for you to download for the specific purpose of this project; robot object tracking using colour.
5. Now attach the robot to your computer running the code and take note of the COM port in which you will edit in the code for communication between the program and the Arduino that controls the robot. Note that the serial communication protocol used in this code requires specific Windows libraries and will not work on other operating systems.
6. Once you have calibrated the program to detect the specified colors, run the program and the robot should be on its merry way to the target colour. (See the youtube video for a demonstration)
We have a be nice policy.
Please be positive and constructive.