LMICSE: Lego Mindstorms in Computer Science Education

Site Map | Contact Us
Project Overview | Staff | Grant Information
Short Workshops | Primary Workshops
CS 1 | Data Str. & Algo. | Prog. Languages | Architecture | Intelligent Sys. | Operating Sys. | Net-centric
Ada | C | C++ | Java | Lisp

Odometry

Basics of Odometry

Odometry is one form of dead reckoning position finding used with robots and other vehicles. It is based on the idea of relative positioning which is to have a known starting point and then use sensors to measure how far and in what direction movement has occurred to keep an idea of the new location. This can be an imprecise due to robot systematic and non-systematic errors (definitions in Types of Error section) but it is the easiest way to do position estimation. Thus, in this lab we will use odometry to move the robot in set patterns eventually telling it way point coordinates and having it follow those way points and figure out its own path to them.

Prerequisite Knowledge

How to manipulate the robot and how to program it using Java.

Materials

  • A lego mindstorms robot equipped with rotation sensors.
  • Measuring devise.
  • Flat surface.

The Math Formulas

  • Translating one click of the rotation sensor to distance traveled:
    Circumference of wheel * pi/ number of clicks per revolution of wheel.
  • Translating degree of turn into clicks
    (wheelbase * pi * number of degrees of turn)/360

Types of Error

Systematic Error - Systematic error is caused by the kinematic properties of the vehicle. Two major odometery systematic errors are unequal wheel diameters and uncertainty about the effective wheelbase. These errors can be adjusted for in code.

Non-Systematic Error- Errors not directly caused by the kinimatic properties of the vehicle. An example of this would be irregularities in the surface be traveled on. These will be different from location to location, thus cannot be programmed for.

For more on systematic and non-systematic errors as they pertain to mobile robots download this .pdf.

Task 1

      This assignments goal is to have a robot that can be told to move in a precise set of movements to lead it to some goal accurately. Once it is properly programmed your robot will be able to be told what distances to move and what turns to do and it should be able to get to a set location with minimal error. To do this you will need to create methods that can move the robot forward in a straight line, stop the robot after a certain distance is reached, and turn the robot to a certain degree accurately.
      Firstly the problem of moving straight should be addressed. Due to systematic errors such as the unequal wheel bases just telling the robot to go forward on robot motors will not be enough. What will have to be done is the creation of a method that moves the robot forward while checking the rotation sensors. The counts returned by the sensors can then be used to keep the robot moving in a straight line by floating one motor or the other for short periods to account for it being too large (note: float should be used because it will not make the motor activate its break). This will take some calibration testing to figure out the ratio of float to go.
      Next the forward method should be modified to take in a distance to move forward and then to move to that distance. This can also be accomplished by keeping track of the rotation sensors. By using the first formula from the Math Formulas section you can determine how many clicks of the rotation sensor equal a set distance. Depending on how your sensors are attached to the motors your number of clicks per revolution may differ. To determine this just look at how many teeth are on the gear on the rotation sensor's axle, take 16 divided by that number of teeth, then times that number by the number of teeth on the wheel's axle. For example: if your sensor has an 8 tooth gear on it and your wheel has a 40 tooth gear on it the math would be (16/8)*40=80 or 80 clicks per revolution of the tire. This works for robots where the sensor's gear is attached to the wheel's gear. If your robot utilizes more gears in between your clicks will be different. Then once you have this math worked out just monitor one sensor (provided your using your straight forward method) until it reaches the distance desired and then stop the robot.
      Lastly, you need to create a method that can turn the robot to a set degree. To do this we again monitor the rotation sensors, however, this time one sensor will be moving in reverse while the other is moving forward. To complete this accurately though you will need to monitor the current angle of the robot so that when it gets sent a new angle to move to it knows which way to turn and how many degrees to move. Note: rotation sensors can only use non-negative numbers so if you need to have the sensor moving in reverse set the sensors value to something high first otherwise if you set it to zero it will just wrap around to a high number and offset your program. Now to determine how far each motor should travel you must utilize the second formula in the Math Formulas section. Each robots wheel base will be slightly different because the wheels are not razor edges, thus calibrations must be performed to get the exact number. This number will be affected by weight distribution as well as type of tire and imperfections in tires so a good place to start is to measure to the outside edges of the tires as the diameter of the circle created in the turn, then adjust that value in until the correct value is found.

In the end your program should utilize at least the following methods:

forward(distance)    //takes in distance and moves that far forward
turnBot(degree) //takes in a degree and moves the robot to that degree

Test:

 

Your robot will be required to go in a square in one direction and then in the same square in the opposite direction. The square's dimensions should be one meter on a side. Buy having your robot go in robot directions your robot cannot have errors that cancel each other out. For instance: your angles are off but your robot curves in it's forward motion it may get back to its start location just fine but it will have done what the image below depicts. By making the robot go robot directions we see that robot straight and turn are accurate.

.

Task 2

Next create a method with the following call:

goTo(coordinate x, coordinate y)   //takes in a location x,y and moves

This method will be used as a higher level routine above the forward and turn commands to move through a Cartesian Coordinate Plane. Instead of telling the robot what turns and distances to make now you will tell it what locations to go to. To accomplish this a current locations and and current pose variable may need to be created to keep track of where it is and where it needs to turn. This method should be able to call other methods and figure out what angle to turn to and what distance to go. To do the distance the pythagorean theorem can be utilized and since your robot may be expected to do turns other than 90 degrees, arc tan functions for the angle will be needed. Your robot should be able to be told coordinates as a metric measurement but smaller unites mean more precision. Keep this in mind with your programming.

Note: You will want to put a check in your method to see whether or not the coordinates you are being told to move to are the same as your current location. If this is the case, you will not need to move anywhere, because you're already at the given location.

Tests:

 

Your robot will now be required to go in a square by being told to start at location 0,0 and go to 0,1; 1,1; 1,0; 0,0 and then traverse the same course in reverse.

After that it will be expected to be able to also start at location 0,0 but go to locations 1,1; 1,0; 0,0 and the reverse(see picture).

An Additional Problem

 

Conclusion

In this lab, you learned the following:

  • Programming for precision
  • Programming for mechanical problems that may arise
  • Maintaining information about current position and orientation