ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

how to calculate the odometry for irobot create robot

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

vincent gravatar image

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

Hi,

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 driver.py. I've included the code snippet. I also included the odometry calculation part in turtlebot_node.py 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

From driver.py

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

From turtlebot_node.py

    # 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
3

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

updated 2013-03-02 03:09:03 -0500

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:

http://rossum.sourceforge.net/papers/DiffSteer/

-Jon

(EDIT): It appears that the global coordinate frame (self.x, self.y and self.th in driver.py) has +y to the left. But the coordinate frame for the change in position (x,y, and th in driver.py) 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 driver.py.

edit flag offensive delete link more

Comments

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 -0500 )edit
2

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 -0500 )edit

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

vincent gravatar image vincent  ( 2013-02-27 02:00:30 -0500 )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 -0500 )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 -0500 )edit
1

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 -0500 )edit
1

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 -0500 )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 -0500 )edit

Question Tools

Stats

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

Seen: 3,175 times

Last updated: Mar 02 '13