10 #include <sensor_msgs/NavSatStatus.h>
11 #include <sensor_msgs/NavSatFix.h>
13 #include <nav_msgs/Odometry.h>
22 void callback(
const nav_msgs::OdometryConstPtr& odom) {
32 double northing, easting, latitude, longitude;
34 sensor_msgs::NavSatFix fix;
36 northing = odom->pose.pose.position.y;
37 easting = odom->pose.pose.position.x;
42 fix.header.frame_id = odom->header.frame_id;
45 std::size_t pos = odom->header.frame_id.find(
"/utm_");
46 if(pos==std::string::npos) {
47 ROS_WARN(
"UTM zone not found in frame_id");
50 zone = odom->header.frame_id.substr(pos + 5, 3);
51 fix.header.frame_id = odom->header.frame_id.substr(0, pos);
56 fix.header.stamp = odom->header.stamp;
58 UTMtoLL(northing, easting, zone, latitude, longitude);
60 fix.latitude = latitude;
61 fix.longitude = longitude;
62 fix.altitude = odom->pose.pose.position.z;
64 fix.position_covariance[0] = odom->pose.covariance[0];
65 fix.position_covariance[1] = odom->pose.covariance[1];
66 fix.position_covariance[2] = odom->pose.covariance[2];
67 fix.position_covariance[3] = odom->pose.covariance[6];
68 fix.position_covariance[4] = odom->pose.covariance[7];
69 fix.position_covariance[5] = odom->pose.covariance[8];
70 fix.position_covariance[6] = odom->pose.covariance[12];
71 fix.position_covariance[7] = odom->pose.covariance[13];
72 fix.position_covariance[8] = odom->pose.covariance[14];
74 fix.status.status = sensor_msgs::NavSatStatus::STATUS_FIX;
79 int main (
int argc,
char **argv) {
80 ros::init(argc, argv,
"utm_odometry_to_navsatfix_node");