1、新建工程
mkdir -p catkin_ws/src
cd src
catkin_create_pkg showpath roscpp sensor_msgs std_msgs nav_msgs tf
cd ..
catkin_make
2、编辑主函数showpath.cpp
#include <ros/ros.h>
#include <ros/console.h>
#include <nav_msgs/Path.h>
#include <nav_msgs/Odometry.h>
#include <std_msgs/String.h>
#include <geometry_msgs/Quaternion.h>
#include <geometry_msgs/PoseStamped.h>
#include <tf/transform_broadcaster.h>
#include <tf/tf.h>
nav_msgs::Path path;
ros::Publisher path_pub;
void odomCallback(const nav_msgs::Odometry::ConstPtr& odom)
{