# Robot Odometry

The goals of this exercise are to

- Implement the forward kinematics of a differential wheel robot on an embedded system
- To experience and quantify sensor noise from wheel-slip, discretization, and real-time violations
- To understand the concept of “loop closure”

You need:

- A Sparki robot
- A working implementation of a line-following algorithm
- The ArcBotics line following poster
- A caliper to measure the robot’s wheel radius and axle length

## Overview

Odometry integrates the wheel speeds of your robot to calculate its 3D pose (x, y, ) on the plane. In order to do this, you need to write down the *forward kinematics* of your robot. As your robot is non-holonomic, you need to calculate the *velocity* along the robots x and y-axis, as well as the rotational speed around its z-axis. You then need to transform these velocities into a global coordinate frame and add them up to calculate the robot’s pose. You will find out that you cannot do this without error as the robot slips, time discretization introduces inaccuracies, and your computer might not be fast enough to perform calculations fast enough.

## Instructions

- Inspect the line following code provided by ArcBotics. What happens during the “delay(100)” statement and where would you want to introduce your odometry code?
- Think about what would happen if calculating a position update would take longer than 100ms. Think about ways to measure the time the execution of a command takes and making sure every loop takes exactly 100ms. Hint: check out the millis library for Arduino.
- Use the caliper to measure the robot’s wheel radius and axle length. Use the millis library to measure how long it takes the robot to move 30cm and calculate its speed from there.
- Implement odometry code following Chapter 3 in the textbook, in particular Equation 3.48 that relates the wheel speed of the left and right wheel to speeds in the inertial frame. Calculate the actual distance by multiplying the speeds with the time that the robot actually moves. Make sure the robot actually moves for exactly 100ms, not the time of the delay plus the time it takes to execute your code! Initialize your pose with (0,0,0).
- Display the robot’s pose on its display. (Make sure this operation does not destroy your timing!). What do you expect the display to show when the robot arrives at the start line at the second (the third, the fourth) time? What actually happens?
- Use the robots sensors to identify the start line. How could you exploit this information to reduce your error?

## Deliverables

Written report providing brief answers (1-2 sentences max) to questions 1-3 and 5-6. Report is due one week after the second odometry exercise.