16-311 Introduction to Robotics Main         Schedule         Homework         Labs         Links

16-311 Lab 3: Line Following and Odometry

# Challenge Statement

Create a system that can follow a colored line with high accuracy and speed and navigate precisely to a planned location.

# Lab Goals

1. Make a basic robot that uses a sensor.
2. Use odometry to accurately navigate.

# Background

Line-Following

One of the easiest ways to have a machine follow a certain path is to create a clear landmark that the robot can identify and follow. In the case of line-following, this is a colored line typically located under the robot that the vechile can sense and use to determine where it should drive. Line-following was one of the first methods of mobile robot navigation. In 1970, Stanford empowered their autonomous cart vehicle with a camera that could follow a high-contrast white line at a speed of 0.8 mph[1]

There are two main strategies for employing line-following on a LEGO robot with a single light sensor[2]:

1. Stay on the line:
• Drive straight until you do not see the line.
• When you do not see the line, rotate in place until the line is detected.
2. Hug the side of the line:
• If you see the line, curve in one direction.
• If you do not see the line, curve in the other direction.
Odometry

Currently, there is no sensor that can sense a vehicle's position without information from the outside world. We can sense an object's orientation with respect to the ground with devices relying on weight and the predicatable acceleration of gravity, we can sense acceleration through devices that capitalize on Newton's Second Law of motion, but there is no way to purely meature displacement on an internal system. Odometry is the practice of gleaning position through the use of internal motion sensors[3].

The sensors that we have to work with are the encoders on each motor. Through ROBOTC, we can read these encoders directly, giving us displacements per unit of time we sample at. So the angular velocity of our motor is (clicks now - clicks the last time we checked)/time between checks. Or:

$\omega =\left(c$n-cp)/tstep

To get this value from clicks/second to radians per second, we can multiply by pi/180.

From here, we can get the tangential velocity of the point of the wheel in contact with the ground by multiplying this angular velocity by the radius of the wheel.

$v$wheelwheelr

Note that changing wheel type will change this calculation. Assuming we are working in the metric system, this gives us the tangential speed at the point of contact for each wheel. If both wheels are moving in the same direction, we can guess that our robot's velocity would also be in this direction and we can describe our robot's velocity as (ideally) the average of the left and right wheels. In this same example, our robot's angular velocity would be 0, because it is moving in one direction. If we were to lower the speed of one motor, we can imagine the robot would turn toward that direction. Additionally, if we move one motor forward and the other back at the same speed, we would cause the robot to spin in place as fast as possible. The relationship between motor speed and robot angular speed is also related to the wheelbase. We can imagine a simple robot with two wheels and a skid plate. The wider the robot, the slower it would rotate. The equation describing the angular velocity of the robot is (right tangential velocity-left tangential velocity)/wheelbase. Or:

$\omega =\left(v$r-vl)/L

So now we have the velocity of the robot in the "forward direction" related to the robot. This would be called the robot frame of reference. Where as the environment (typically described with x and y coordinates and theta heading) is described as the world frame. Since we want to be able to move our robot to a specific location in the world rame, we are interested in these (x,y,theta) values. We can get to speeds in this frame fairly easily where X velocity is speed*cos(theta), Y velocity is speed*sin(theta), and the speed that the robot's orientation changes (theta dot) is equal to its's rotational speed. Written in equation form:

$v$x=v cos(θ)

$v$y=v sin(θ)

$dot\left(\theta \right)=\omega$

To go from these velocities to position, it is necessary to solve a nonlinear differential system of equations. This can be estimated with Runge-Kutta Methods. An example of this math is shown below:

The values for x, y and theta will be updated at each step and can be used to find you final position.

# Lab Requirements

The specifications for Lab 3 are presented in the following documents.

2020 Lab 3 Writeup

2020 Lab 3 Grading Sheet