The goal of this project is using ros and OpenCV to cruise the cozmo robot on a track with the ability avoiding obstacles and stopping at traffic sign. You can find the project Here at Github
Similar to my previous projects, the frame is analyzed in HSV space and segmented into regions. The lower area marked in red is for road center detection and obstacle detection. As in the picture above, a block showing in the frame makes the robot turning to right as the blue arrowed line indicated.
The reason why I chose this over the road shoulder/edge detection is the narrow viewing angle of the mounted camera. Otherwise, edge detection and hough transfer can do the work for edge detection and return the middle point of the two lines for the motion control.
And the green rectangle marks the area for sign or traffic light detection. So far, a predefined color, pink, is chosen. When the robot sees the sign, it stops until the sign is removed.
Here I use PID control of the angular velocity (velocity delta between caterpillar tracks) for the cruise of the robot. As in equations below, the e, error, represents the delta between the center of the road ahead in the red rectangular area and the screen center. Besides the P control, I include the D control to improve the stability and reduce overshoots.
u = ke* e + ki* eint + kd* ed
ed = e - eprev eint = eint + e
The node list and the function of each node:
The topics used in this project:
There is a launch file, run.launch, enables the visual tracking function and the motion control function mentioned above. Once the cozmo driver is enabled, we are ready to go.
The auto white balance of the cozmo robot is not ideal. So, there is an additional function, img_cal, that does the calibration, normalizes the RGB values and store the values into a text file in the src folder of this project.
The default setting of the cozmo driver outputs mono color stream. So a little tweak is required.
coz.camera.color_image_enabled = True
enables the color stream output but the tradeoff is the resolution goes down from 640x480 to 320x240.
Another tweak I did to the cozmo driver is boosting its rate. It was 10Hz and to have a better tracking performance, I boosted it up to 30Hz.