samedi 17 novembre 2012

Odometry


When we are dealing with an autonomous mobile robot, the first thing comes to our mind is how this robot will locate it self while moving.

There are several methods to do that, But in this article I'm going to talk about Odometry ,or sometimes known by "Dead reckoning", for a two wheeled robot.

The main idea about Odometry is to use a foreknown distance unit in a cumulative way.
Let's get to this example, let's suppose that an adult step is about 1 meter. If this adult walks five steps then he walked 5 meters.
In an orthonormal reference (x,y) if this guy starts at (0,0) moves 5 steps in the direction of Y then he's new position is updated and it's (0,5).
If later he moves 5 steps in the direction of X he new position will be updated compared to he's last position so he's new position is  (5,5).
Let's suppose that the adult turn him self while walking and instead of walking 5 steps towards Y then 5 towards X.
He starts with an angel Theta =45° and goes 7 steps ( Distance=~ sqrt(50))
In this case we can tell his X and Y position with simple trigonometry.

X=Distance*Cos(Theta) =~ 5
Y= Distance*Sin(Theta) =~ 5
(X,Y) = (5,5)










Back to robotics Now :p
If we suppose that these guy is a two wheeled robot the measurement of the foreknown distance would be extracted from sensors like quadrature encoders IMU or something else.

We need to know the position of the robot in real time, that means every small sampling time (10 ms is good) we need to recalculate the distance the robot traveled and the angel it did to calculate it's new position. After that we add this position to last calculated position and so on. just like we did with the guy.

The next diagram will explain how to deal with an Odometry in real time with a two wheeled robot using quadrature encoders.

The next code explaining how to implement Odometry in real time in an arduino.
In this code I used a software interrupt of 120ms (toooo much) get more assured that arduino is not for real time application

  l=0.5*(positionRight+positionLeft);
  Theta=positionRight-positionLeft;
  vitesse=l-lastL;
  lastL=l;
  Theta%=2292; //2292 is the number that corresponds to 2*pi
  double Theta_r=(double)Theta*0.002734;//Theta in radian
  deltaX=-vitesse*sin(Theta_r);
  deltaY=vitesse*cos(Theta_r);
  x+=deltaX;
  y+=deltaY;


Cheers :)



Aucun commentaire:

Enregistrer un commentaire