“Puzzlebot” Differential Car Driving on a Scaled Track with Traffic Elements

For this group class project, we used the Puzzlebot kit from Manchester Robotics containing a differential car kit consisting of a 2-level modular base for computer boards and two DC motors with wheels attached, a “Hackerboard” chip which dealt with the speed control for each wheel, and a camera used for traffic signal detections.
I developed the control package in ROS2 using C++ nodes, based on 3 main nodes: pose estimation, a guidance node, and a waypoint publisher. The pose estimation listens to the angular velocity of each wheel, which updates the dynamic model’s variables, which is the vehicle’s 2D pose (position and orientation measured from where the vehicle started).

On the other hand, the waypoint publisher takes into consideration that pose and the context of what the camera is identifying (just a line to follow, or if the vehicle is in front of a traffic signal), and based on that the algorithm either makes corrections as a local planner for path following, or generates a set of waypoints for the car to follow. This turned out to be very useful, because as long as the vehicle followed the waypoint, it didn’t need to listen to what the camera was detecting, and that was useful when “crossing roads” (dotted lines which could confuse the line follower algorithm) or turning left of right (there were moments were the region of interest of the camera focused on the lower pixels wouldn’t show a line to follow, so the car could get lost there if pure line following was always enabled). Finally, the guidance node is based on a simple pure pursuit algorithm controlling the heading references with a PID controller for a smoother approach to the line.

I also worked on the optimization of the line follower algorithm, migrating the code from python to C++, and collaborated in the change of the camera messages from sensor_msgs/Image to CompressedImage messages, which made the topic transmission way faster and gave us the chance to increase our vehicle’s speed.

As a bonus, inspired by the Boat project, I worked on a master node, which enabled the toggling between a teleoperated mode and an autonomous mode. That made testing easier and faster, because if I saw the car deviate, or the YOLO algorithm ignored a traffic signal, I could always toggle the modes and go back to where the car failed, and debug errors faster.

In the end, I am very proud to say our team had the fastest car (and by a lot) and could correctly follow all the traffic signals without the intervention of a person for aiding, but most importantly, I really enjoyed the process of building a new ROS2 project from scratch and discussing with my teammates different approaches, and testing all the different ideas that occurred to us.