接收导航包全局规划路径话题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/HERO_CJN/article/details/79714995
#include <ros/ros.h>
#include <actionlib/client/simple_action_client.h>
#include <move_base_msgs/MoveBaseAction.h>
#include "tf/tf.h"
#include <tf/transform_listener.h>
#include <geometry_msgs/PoseArray.h>
#include <nav_msgs/Path.h>
using namespace std;
class MyNode
{
public:
    MyNode();
    void cmd_velCallback(const nav_msgs::Path& path);
private:
    ros::NodeHandle nh;
    ros::Subscriber plan_sub_;
};
MyNode::MyNode()
{
    plan_sub_ = nh.subscribe("/move_base/plan", 50, &MyNode::cmd_velCallback, this);
}
void MyNode::cmd_velCallback(const nav_msgs::Path& path)
{
    for(int i = 0; i < path.poses.size(); ++i)
    {
        ROS_INFO("PATH:%f",path.poses[i].pose.position.x);
    }

}
int main (int argc, char **argv)
{
  ros::init(argc, argv, "test_fibonacci_class_client");
  MyNode mynode;
  ros::Rate loop_rate(10);
  while(ros::ok())
  {
      ros::spinOnce();
      loop_rate.sleep();
  }
  return 0;
}

猜你喜欢

转载自blog.csdn.net/HERO_CJN/article/details/79714995
今日推荐