March 2018
Intermediate to advanced
1396 pages
42h 14m
English
In this example, we are going to project the latitude and the longitude of GPS to a 2D Cartesian space. For this, we will use a function written by Chuck Gantz that converts latitudes and longitudes into UTM coordinates. The node will subscribe to the /fix topic where GPS data is sent. You can find the code in chapter8_tutorials in the c8_fixtoUTM.cpp file:
#include <ros/ros.h> #include <tf/transform_broadcaster.h> #include <nav_msgs/Odometry.h> #include <stdio.h> #include <iostream> #include <sensor_msgs/NavSatFix.h> geometry_msgs::Point global_position; ros::Publisher position_pub; void gpsCallBack(const sensor_msgs::NavSatFixConstPtr& gps) { double northing, easting; char zone; LLtoUTM(gps->latitude, ...