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

How to calculate distance between two GPS values?

asked 2017-05-28 04:23:16 -0500

rsmitha gravatar image


I am using the jackal in simulation. I have C++ code which has a subscriber to the "navsat/fix" topic. My program has the jackal travelling to a distance of 10m in the "x direction" before it stops. I am trying to collect data from different sensors one of them being the gps. I have latitude, longitude and altitude values. How do I use the values to calculate the distance travelled between two points?

the first value is : lat = 49.9; long = 8.9; alt = 0.0634842; The value at the end of 10m is: lat = 49.9001; long = 8.9; alt = 0.0634803;

Please help.

Regards, rsmitha.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-05-28 19:58:33 -0500

ufr3c_tjc gravatar image

Have a look at the robot_localization package, and its documentation here. It sounds like you could be trying to perform the job that it does already. It includes a node called navsat_transform_node which performs accurate GPS -> map conversions, to fuse with imu and odometry data to position your robot more accurately.

If you don't want to use the node itself, have a look at the navsat_conversions.h file in its include directory. This provides a lat/long -> UTM conversion. UTM is measured in meters, so you can easily find the positions in the UTM grid and use this to get your distance travelled in meters.

edit flag offensive delete link more


Thanks for the help and the documentation, @ufr3c_tjc. If the navsat_transform_node is already present, when we do "rostopic list" shouldn't the odometry/gps topic be listed?

rsmitha gravatar image rsmitha  ( 2017-05-28 20:05:49 -0500 )edit

Have you set up navsat_transform_node correctly? Please read through the documentation fully. It's not a trivial exercise and may take you a while to make sure the node is working correctly. Once it is all working, yes, it will publish the data on the odometry/gps topic.

ufr3c_tjc gravatar image ufr3c_tjc  ( 2017-05-28 20:10:33 -0500 )edit

Question Tools



Asked: 2017-05-28 04:23:16 -0500

Seen: 1,177 times

Last updated: May 28 '17