ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
As geodesy seems to be the most official way to convert between geographic and UTM coordinates, here are some code snippets, which worked for me. Start with:
#include <geodesy/utm.h>
For coordinate conversions, you need data of type geographic_msgs::GeoPoint and geodesy::UTMPoint:
geographic_msgs::GeoPoint geo_pt;
geo_pt.latitude = latitude;
geo_pt.longitude = longitude;
geo_pt.altitude = altitude;
geodesy::UTMPoint utm_pt(geo_pt);
Don't forget to add geodesy to your CMakeLists.txt:
find_package(catkin REQUIRED COMPONENTS geodesy)
Now you are good to go with your UTM data.
2 | No.2 Revision |
As geodesyGeodesy seems to be the most official way to convert between geographic latitude/logitude and UTM coordinates, coordinates. As I wasn't able to find any code examples, here are some code snippets, lines, which worked for me. Start with:
#include <geodesy/utm.h>
For coordinate conversions, you need data of type geographic_msgs::GeoPoint and geodesy::UTMPoint:geodesy::UTMPoint.
Example for Lat/Lon -> UTM conversion:
geographic_msgs::GeoPoint geo_pt;
geo_pt.latitude = latitude;
geo_pt.longitude = longitude;
geo_pt.altitude = altitude;
geodesy::UTMPoint utm_pt(geo_pt);
Example for UTM -> Lat/Lon conversion:
geodesy::UTMPoint utm_pt(easting, northing, altitude, zone, band);
geographic_msgs::GeoPoint geo_pt;
geo_pt = geodesy::toMsg(utm_pt);
Don't forget to add geodesy to your CMakeLists.txt:
find_package(catkin REQUIRED COMPONENTS geodesy)
Now you are good to go with your UTM data.