Path Following Robot with RaspberryPi

In this project, I built a RaspberryPi based differential drive robot that can follow the line on the ground in autonomous mode using camera. Control and image processing programs are developed using ROS and Python.

Objectives

  1. Robot can be manually controlled through Keyboard Input and Text Scripts.
  2. Using fundamentals of dynamics and differential equation, solve the ODE and improve motor control algorithm.
  3. Robot can recognize lines on the ground using camera
  4. Robot is able to follow the line stably using PID control

First Stage: Motor Command

​In ROS package, we can define nodes as publishers and subscribers. They can exchange different types of messages in the ROS channel. I wrote programs that define the nodes and they exchange /motor_speeds messages so that the subscriber can control the motor speed according to keyboard or csv files.


Second Stage: Improve Motor Command Model

​In this stage I developed a model with parameters k & d to transform linear and angular velocity to motor speed. ​Using closed form step model and IMU on robot, I can also track the position of robot by publishing pose message.


Third Stage: Image Processing

For every image received by robot, I run a linear classifier on it so that the green color line becomes white [255,255,255] and the background becomes black [0,0,0]. Then I add a centroid to the white component. So, as the robot follows the centroid line, it follows the green line track.


Final Stage: PID Controller

We define the difference between camera image center and the centroid of image classifier as error message. PID controller adds up the proportional, derivative and integral of every error signal and then pass this message to motor command so that the motor adjust speeds accordingly to lower down this error message to zero. Kp, Ki and Kd are parameters of the error signal. Increasing these parameters increases the speed of correcting the error.


Finally, here is a video that documents this semester-long project