8 #include <sensor_msgs/NavSatStatus.h> 9 #include <sensor_msgs/NavSatFix.h> 11 #include <nav_msgs/Odometry.h> 19 void callback(
const sensor_msgs::NavSatFixConstPtr& fix) {
20 if (fix->status.status == sensor_msgs::NavSatStatus::STATUS_NO_FIX) {
29 double northing, easting;
32 LLtoUTM(fix->latitude, fix->longitude, northing, easting, zone);
35 nav_msgs::Odometry odom;
36 odom.header.stamp = fix->header.stamp;
39 odom.header.frame_id = fix->header.frame_id;
45 odom.pose.pose.position.x = easting;
46 odom.pose.pose.position.y = northing;
47 odom.pose.pose.position.z = fix->altitude;
49 odom.pose.pose.orientation.x = 0;
50 odom.pose.pose.orientation.y = 0;
51 odom.pose.pose.orientation.z = 0;
52 odom.pose.pose.orientation.w = 1;
55 boost::array<double, 36> covariance = {{
56 fix->position_covariance[0],
57 fix->position_covariance[1],
58 fix->position_covariance[2],
60 fix->position_covariance[3],
61 fix->position_covariance[4],
62 fix->position_covariance[5],
64 fix->position_covariance[6],
65 fix->position_covariance[7],
66 fix->position_covariance[8],
73 odom.pose.covariance = covariance;
79 int main (
int argc,
char **argv) {
80 ros::init(argc, argv,
"utm_odometry_node");
86 priv_node.
param<
double>(
"rot_covariance",
rot_cov, 99999.0);
88 odom_pub = node.
advertise<nav_msgs::Odometry>(
"odom", 10);
static ros::Publisher odom_pub
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
std::string child_frame_id
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
static void LLtoUTM(const double Lat, const double Long, double &UTMNorthing, double &UTMEasting, char *UTMZone)
int main(int argc, char **argv)
Universal Transverse Mercator transforms.
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void callback(const sensor_msgs::NavSatFixConstPtr &fix)
#define ROS_DEBUG_THROTTLE(period,...)