16311 Introduction to Robotics 

Main Schedule Homework Labs Links 
Lab 3: Line Following and Odometry 

Challenge StatementCreate a system that can follow a colored line with high accuracy and speed and navigate precisely to a planned location. Lab Goals
BackgroundLineFollowingOne 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 linefollowing, this is a colored line typically located under the robot that the vechile can sense and use to determine where it should drive. Linefollowing 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 highcontrast white line at a speed of 0.8 mph[1] There are two main strategies for employing linefollowing on a LEGO robot with a single light sensor[2]:
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 =(c$_{n}c_{p})/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$_{wheel}=ω_{wheel}r 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 velocityleft tangential velocity)/wheelbase. Or: $\omega =(v$_{r}v_{l})/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(\theta )=\omega $ To go from these velocities to position, it is necessary to solve a nonlinear differential system of equations. This can be estimated with RungeKutta 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. The starter code for this lab is available here: lab3StarterCode.c Lab RequirementsThe specifications for Lab 3 are presented in the following documents. Extensions 

