Ask Your Question

Is it possible to convert geometry_msgs PoseStamped to nav_msgs Odometry?

asked 2019-08-19 09:47:49 -0600

parzival gravatar image

updated 2019-08-19 15:25:06 -0600

I am trying to build a differential drive robot similar to a turtlebot, but I only have RPLidar as the sensor. I would like to use its data from /scan to publish messages of type nav_msgs/Odometry.

I tried using laser_scan_matcher but it only give Pose2D, which isn't sufficient as I need Twist information for Odometry msgs as well.

I even tried using the rf2o_laser_odometry, but I'm unable to get it working.

I tried hector_mapping, but it publishes geometry_msgs/PoseStamped and PoseWithCovariance.

Can someone guide me with the process of converting this datav from this message type to Odometry type which is compulsory for move_base?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-08-20 00:39:55 -0600

PapaG gravatar image

updated 2019-08-20 20:52:34 -0600

Is this a duplicate question? Please do not flood the forums with duplicates.

If not, you could estimate your velocity by deriving your position with respect to time. Estimate pose from velocity

x += v_x * dt
y += v_y * dt
theta += v_theta * dt

and so therefore your velocity in the odom frame can be estimated as

v_x = delta_x / dt
v_y = delta_y / dt
v_theta = delta_theta /dt

Given this you can extrapolate a robot frame velocity of

v.x = v_x/cos(theta)
omega = v_theta (due to the nature of differential drive kinematics).

Also keep in mind that due to kinematic constraints

edit flag offensive delete link more


No it is not a duplicate. The robot setup is same but they are fundamentally two different problems

parzival gravatar image parzival  ( 2019-08-20 03:43:45 -0600 )edit

Is this still relevant? In the linked question which is newer you say you can already derive an odometery msg. If you are still looking for an answer perhaps consider deriving the velocity from the distance travlled? You’re generating pose estimates and as so can calculate your change in location over time and thus, your velocity?

PapaG gravatar image PapaG  ( 2019-08-20 03:54:13 -0600 )edit

Yes. That sounds like a good option. Thanks! I'm currently using headers from /scan and pose2D from laser_scan_matcher to derive velocity and send Odometry messages. I think laser_scan_matcher would be a much lighter package then hector for my use case. What do you think?

parzival gravatar image parzival  ( 2019-08-20 08:41:08 -0600 )edit

I would suggest experimentation, every robot is different. Please see my updated answer for a mathematical derivation. Perhaps consider selecting it as an answer if you're happy with the help.

PapaG gravatar image PapaG  ( 2019-08-20 20:44:55 -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: 2019-08-19 09:47:49 -0600

Seen: 737 times

Last updated: Aug 20 '19