One-hundred sixty sixth Day 1314 Lego robots

Screen Shot 2014-06-05 at 9.31.57 AM

DifferentialPilot

The DifferentialPilot class controls a vehicle that has two driving wheels, each with its own motor. It steers the vehicle by controlling the speed and direction of rotation of its motors. It is one of several Move Controllers that are based on different mechanical designs, but the differential steering design is the simplest.
The pilot object needs to know the wiring diagram of the robot, i.e. which ports the motors are connected to and whether driving the motors forward makes the robot move forward or backward (reverse). It also needs to know the diameter of the wheels and the width of the track, i.e. the distance between the centres of the tracks of the two wheels. DifferentialPilot uses the wheel diameter to calculate the distance it has traveled. It uses the track width to calculate how far it has rotated. Obviously, both parameters must be in the same units, but they can be anything you wish. With proper adjustment of these parameters, errors in distance traveled and angle of rotation can be held do 2% or perhaps less. This information is passed to the pilot constructor. DifferentialPilot is in the lejos.robotics.navigation package. The documentation for this class is here.

New Assignment: Use what you learned to make your robot follow an 8 shape pattern.