Ricardo Delfín
Ricardo Delfín

Robot Car

Early Version of the Robot Car, making use of a serial motor controller.

How does the software work?

The software for this car is written in C++ for the Robot Operating System (ROS). In this system, you can create separate programs called nodes. They all communicate through defined topics and services.

This car has a node that sends commands directly to the motor controllers and creates a service that sets the speed and direction settings for each motor. A separate node uses that service to provide a drive service, where you can provide a direction and speed for the entire car.

The great thing about ROS is you can add all sorts of services and make them entirely modular and detached. These nodes can create a topic for encoders, ultrasonic sensors, more motors, an HTTP client for twitter, you name it!

How does the hardware work?

The motors are a standard set of Sparkfun hobby gearmotors. These are controller by two, Sparkfun tb6612fng motor controllers. These are hooked up directly to the Raspberry Pi output pins, and controlled using software PWM.

The power was an interesting challenge. There are two power sources for the robot: One used by the motors and the controllers (motor power), the other used by the Raspberry Pi (main power). The first is provided by a single 9V battery. The second is powered by a cellphone battery pack, mostly because Raspberry Pi's were not technically designed by a regular battery and so can only be provided power through their micro-USB port. Yay bodging!

Want to look at the code?

Download the code here: