In this lines you can read how build a rover using opencv for do something detecting colors.
The work process is simple, Arduino have a basic program to the rover: forward, left and right that manages the movement in the rover.
The Arduino board is connected to a Raspberry pi by USB port and RPI send data from serial port:
For example, if the RPI process the image and the center of the target is in the left side of the image, the RPI send a command to the Arduino for move the wheels to the left. If the target is far ( the high of the object is little) the RPI send the order forward while the target isn't big.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Materials
-Raspberry PI 2 or 3
-Raspberry PI Camera V2
-Arduino UNO,nano, MEGA....
-7.4V LiPo battery for brushless motor
-5V Power bank for Raspberry and Arduino
-2x Micro servos for Raspberry pi 2 Camera
In this case you have two options:
1.- Use RC car (this have been my option)
2.- Build your own rover platform:
2.1- using brushless motor + ESC + servo
2.2- using motor + servo
2.3- using that you want
Step 2: Installing OpenCV in Raspbian
I am assuming that you have working a raspbian distribution on your raspberry. If it isn't your case, you have to follow this downloading the latest raspbian image:
This is the worst step in this tutorial. Install OpenCV in raspbian for RPI2 taked me about 3 hours.
The best thing that you can do is follow this tutorial:
When you are sure that OpenCV is working on your RPI you can continue.
Step 3: Set Up the Raspberry Pi Camera
In this tutorial from official Raspberry you can check the process.
Step 4: Set Up the Servos for Pi Camera Mount
The pinout that I use for the servos in the RPI2 were the PIN 7 for data wire in X axis servo and PIN 13 for data wire in Y axis servo.
The servos' power pins to PIN 2 and 4 in the RPI2.
The servos' ground pins to PIN 14 and 9 in the RPI2.
Step 5: Arduino Set Up
In this image you can check the pins.
If you are not using brushless motor, you will have other configuration for the motors.
In my GitHub you can obtain the simple code:
Step 6: Final Set Up
In this step you have to connect the Arduino to the Raspberry Pi for USB port, because the python program use the serial port to send movements to the Arduino board.
And this is the python program that manages the opencv processing and send data to Arduino:
Now you can enjoy the project!
Participated in the
Make It Move Contest 2017