ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Tue, 20 Aug 2019 20:44:55 -0500Is it possible to convert geometry_msgs PoseStamped to nav_msgs Odometry?https://answers.ros.org/question/331044/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`?Mon, 19 Aug 2019 09:47:49 -0500https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/Answer by PapaG for <p>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 <code>nav_msgs/Odometry</code>.</p>
<p>I tried using <code>laser_scan_matcher</code> but it only give <code>Pose2D</code>, which isn't sufficient as I need Twist information for Odometry msgs as well.</p>
<p>I even tried using the rf2o_laser_odometry, but I'm unable to get it working.</p>
<p>I tried <code>hector_mapping</code>, but it publishes <code>geometry_msgs/PoseStamped</code> and <code>PoseWithCovariance</code>.</p>
<p>Can someone guide me with the process of converting this datav from this message type to Odometry type which is compulsory for <code>move_base</code>?</p>
https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/?answer=331102#post-id-331102Is [this](https://answers.ros.org/question/331081/does-move_base-require-twist-from-odometry/) 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=0Tue, 20 Aug 2019 00:39:55 -0500https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/?answer=331102#post-id-331102Comment by PapaG for <p>Is <a href="https://answers.ros.org/question/331081/does-move_base-require-twist-from-odometry/">this</a> a duplicate question? Please do not flood the forums with duplicates.</p>
<p>If not, you could estimate your velocity by deriving your position with respect to time.
Estimate pose from velocity</p>
<pre><code>x += v_x * dt
y += v_y * dt
theta += v_theta * dt
</code></pre>
<p>and so therefore your velocity in the odom frame can be estimated as</p>
<pre><code>v_x = delta_x / dt
v_y = delta_y / dt
v_theta = delta_theta /dt
</code></pre>
<p>Given this you can extrapolate a robot frame velocity of </p>
<pre><code>v.x = v_x/cos(theta)
omega = v_theta (due to the nature of differential drive kinematics).
</code></pre>
<p>Also keep in mind that due to kinematic constraints</p>
<pre><code>v.y=0
</code></pre>
https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/?comment=331187#post-id-331187I 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.Tue, 20 Aug 2019 20:44:55 -0500https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/?comment=331187#post-id-331187Comment by parzival for <p>Is <a href="https://answers.ros.org/question/331081/does-move_base-require-twist-from-odometry/">this</a> a duplicate question? Please do not flood the forums with duplicates.</p>
<p>If not, you could estimate your velocity by deriving your position with respect to time.
Estimate pose from velocity</p>
<pre><code>x += v_x * dt
y += v_y * dt
theta += v_theta * dt
</code></pre>
<p>and so therefore your velocity in the odom frame can be estimated as</p>
<pre><code>v_x = delta_x / dt
v_y = delta_y / dt
v_theta = delta_theta /dt
</code></pre>
<p>Given this you can extrapolate a robot frame velocity of </p>
<pre><code>v.x = v_x/cos(theta)
omega = v_theta (due to the nature of differential drive kinematics).
</code></pre>
<p>Also keep in mind that due to kinematic constraints</p>
<pre><code>v.y=0
</code></pre>
https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/?comment=331151#post-id-331151Yes. 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?Tue, 20 Aug 2019 08:41:08 -0500https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/?comment=331151#post-id-331151Comment by PapaG for <p>Is <a href="https://answers.ros.org/question/331081/does-move_base-require-twist-from-odometry/">this</a> a duplicate question? Please do not flood the forums with duplicates.</p>
<p>If not, you could estimate your velocity by deriving your position with respect to time.
Estimate pose from velocity</p>
<pre><code>x += v_x * dt
y += v_y * dt
theta += v_theta * dt
</code></pre>
<p>and so therefore your velocity in the odom frame can be estimated as</p>
<pre><code>v_x = delta_x / dt
v_y = delta_y / dt
v_theta = delta_theta /dt
</code></pre>
<p>Given this you can extrapolate a robot frame velocity of </p>
<pre><code>v.x = v_x/cos(theta)
omega = v_theta (due to the nature of differential drive kinematics).
</code></pre>
<p>Also keep in mind that due to kinematic constraints</p>
<pre><code>v.y=0
</code></pre>
https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/?comment=331131#post-id-331131Is 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?Tue, 20 Aug 2019 03:54:13 -0500https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/?comment=331131#post-id-331131Comment by parzival for <p>Is <a href="https://answers.ros.org/question/331081/does-move_base-require-twist-from-odometry/">this</a> a duplicate question? Please do not flood the forums with duplicates.</p>
<p>If not, you could estimate your velocity by deriving your position with respect to time.
Estimate pose from velocity</p>
<pre><code>x += v_x * dt
y += v_y * dt
theta += v_theta * dt
</code></pre>
<p>and so therefore your velocity in the odom frame can be estimated as</p>
<pre><code>v_x = delta_x / dt
v_y = delta_y / dt
v_theta = delta_theta /dt
</code></pre>
<p>Given this you can extrapolate a robot frame velocity of </p>
<pre><code>v.x = v_x/cos(theta)
omega = v_theta (due to the nature of differential drive kinematics).
</code></pre>
<p>Also keep in mind that due to kinematic constraints</p>
<pre><code>v.y=0
</code></pre>
https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/?comment=331128#post-id-331128No it is not a duplicate. The robot setup is same but they are fundamentally two different problemsTue, 20 Aug 2019 03:43:45 -0500https://answers.ros.org/question/331044/is-it-possible-to-convert-geometry_msgs-posestamped-to-nav_msgs-odometry/?comment=331128#post-id-331128