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

# How to calculate distance between two GPS values?

Hi,

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;

Regards, rsmitha.

edit retag close merge delete

Sort by ยป oldest newest most voted

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.

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?

( 2017-05-28 20:05:49 -0600 )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.

( 2017-05-28 20:10:33 -0600 )edit