ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# Is it possible to convert geometry_msgs PoseStamped to nav_msgs Odometry?

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 close merge delete

Sort by » oldest newest most voted

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

v.y=0

more

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

( 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?

( 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?

( 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.

( 2019-08-20 20:44:55 -0600 )edit