Ask Your Question

how to calculate the odometry for irobot create robot

asked 2013-02-26 14:08:36 -0600

vincent gravatar image

updated 2013-02-27 03:16:52 -0600


I'm trying to understand how the odometry is calculated in irobot_create_2_1 driver. I spent lots of time trying to figure out where the minus sign comes from in y=-sin(th)*d, on the 53th line in I've included the code snippet. I also included the odometry calculation part in from turtlebot stack, which does the same thing but easier for me to understand.

Can anyone give me a hint or let me know where I can find good resource on mobile robot odometry/kinematics in order to understand the whole scenario. Thanks


00046                 d = self.create.d_distance / 1000.
00047                 th = self.create.d_angle*pi/180
00048                 dx = d / elapsed
00049                 dth = th / elapsed
00051                 if (d != 0):
00052                         x = cos(th)*d
00053                         y = -sin(th)*d
00054                         self.x = self.x + (cos(*x - sin(*y)
00055                         self.y = self.y + (sin(*x + cos(*y)
00057                 if (th != 0):
00058                = + th


    # this is really delta_distance, delta_angle
    d  = sensor_state.distance * self.odom_linear_scale_correction #correction factor from calibration
    angle = sensor_state.angle * self.odom_angular_scale_correction #correction factor from calibration

    x = cos(angle) * d
    y = -sin(angle) * d

    last_angle = self._pos2d.theta
    self._pos2d.x += cos(last_angle)*x - sin(last_angle)*y
    self._pos2d.y += sin(last_angle)*x + cos(last_angle)*y
    self._pos2d.theta += angle

I've attached my calculation as below, can someone point out where went wrong? image description

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-02-26 14:59:39 -0600

updated 2013-03-02 03:09:03 -0600

I don't know if I can answer your specific question, but this is a good source for learning about how to calculate the odometry:


(EDIT): It appears that the global coordinate frame (self.x, self.y and in has +y to the left. But the coordinate frame for the change in position (x,y, and th in has +y to the right.

It seems unlikely to me that that is what the original author intended. It's probably either a bug that doesn't matter in the end, or maybe an artifact of the odometry that supplies data to

edit flag offensive delete link more


thank you Jon, i've read through this tutorial but still didn't get the answer for my question.

vincent gravatar image vincent  ( 2013-02-26 15:09:15 -0600 )edit

I think it just comes down to the definition of the axes and the angle. If I've got it right, I think +x is forward, +y is to the right, and +angle is counter-clockwise.

Jon Stephan gravatar image Jon Stephan  ( 2013-02-26 15:48:02 -0600 )edit

ok i see. Is it left-handed coordinate system?

vincent gravatar image vincent  ( 2013-02-27 02:00:30 -0600 )edit

based on my calculation, it came down to this: self._pos2d.x += cos(last_angle)x + sin(last_angle)y; self._pos2d.y += - sin(last_angle)x + cos(last_angle)y. (the rest is the same with the examples). still different signs... not sure if you got the same result...

vincent gravatar image vincent  ( 2013-02-27 02:19:57 -0600 )edit

i've edited my question with my calculation attached. could you please have a look and let me know if anything went wrong? thx.

vincent gravatar image vincent  ( 2013-02-27 02:59:16 -0600 )edit

Wow, I thought I understood this, but I guess not. It looks to me like the coordinate frame of x and y (the change of x and y) has +y to the right, while self.x and self.y has +y to the left. I also confirmed on my robot that +y (the global +y) is to the left.

Jon Stephan gravatar image Jon Stephan  ( 2013-02-27 15:39:36 -0600 )edit

I also confirmed that rotating to the right gives a positive y, and a negative self.y.

Jon Stephan gravatar image Jon Stephan  ( 2013-02-27 15:54:56 -0600 )edit

Great! that explains. Is it like a convention to define these two coordinate frame differently or is it just specific to the create robot?

vincent gravatar image vincent  ( 2013-02-28 04:34:42 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-02-26 14:08:36 -0600

Seen: 2,612 times

Last updated: Mar 02 '13