Running Cozmo - MSR Winter Project

Category: Computer Vision, Python, ROS

Overview

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

Path/Obstacle recognition

alt text

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.

Motion Control

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

ROS structure

The node list and the function of each node:

  1. cozmo_driver: The node handles the communication between cozmo python driver and the host. It is generated by cozmo driver package and is not included in this package.
  2. obj_id: The main function of this node is processing the video frame and output the position and the size of the road and the obstacles.
  3. vel_ctl: With the positions of different objects, the node calculates and outputs the velocity of the cozmo.

The topics used in this project:

  1. /cozmo_driver/image - the image feedback
  2. /cmd_vel - the velocity
  3. /head_angle - Adjusting the vertical field of view
  4. /odom - the odometry
  5. /obj_size - the topic of the location and the size of each object

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.

Other functions

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.

Notes

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.