ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Which topic should I publish path to?

asked 2014-11-18 19:17:27 -0600

Tixiao gravatar image

Hi guys, I am trying to implement a global path planner to Turtlebot 2 using ROS navigation. Now I can get the initial position, goal position and map data these three for path planning. And I am trying to verify my output. I wrote a simple TALKER to send path to topic /move_base/TrajectoryPlannerROS/global_plan.

int main(int argc, char **argv)
{
  ros::init(argc, argv, "talker");

  ros::NodeHandle p;
  ros::Publisher path_pub = p.advertise<nav_msgs::Path>("move_base/TrajectoryPlannerROS/global_plan", 1000);
  ros::Rate loop_rate(1);

  nav_msgs::Path gui_path;
  geometry_msgs::PoseStamped pose;
  std::vector<geometry_msgs::PoseStamped> plan;
for (int i=0; i<5; i++){
      pose.pose.position.x = i;
      pose.pose.position.y = -i;
      pose.pose.position.z = 0.0;
      pose.pose.orientation.x = 0.0;
      pose.pose.orientation.y = 0.0;
      pose.pose.orientation.z = 0.0;
      pose.pose.orientation.w = 1.0;
      plan.push_back(pose);
    }

gui_path.poses.resize(plan.size());

if(!plan.empty()){
      gui_path.header.frame_id = 'map';
      gui_path.header.stamp = plan[0].header.stamp;
}

for(unsigned int i=0; i < plan.size(); i++){
      gui_path.poses[i] = plan[i];
}

while (1){
  path_pub.publish(gui_path);
  ros::spinOnce();
  loop_rate.sleep();
}
  return 0;
}

I can rostopic echo move_base/TrajectoryPlannerROS/global_plan and get path like this:

header: 
  seq: 10
  stamp: 
    secs: 0
    nsecs: 0
  frame_id: ''
poses: 
  - 
    header: 
      seq: 0
      stamp: 
        secs: 0
        nsecs: 0
      frame_id: ''
    pose: 
      position: 
        x: 0.0
        y: 0.0
        z: 0.0
      orientation: 
        x: 0.0
        y: 0.0
        z: 0.0
        w: 1.0
  - 
    header: 
      seq: 0
      stamp: 
        secs: 0
        nsecs: 0
      frame_id: ''
    pose: 
      position: 
        x: 1.0
        y: -1.0
        z: 0.0
      orientation: 
        x: 0.0
        y: 0.0
        z: 0.0
        w: 1.0

But the robot in Rviz is not moving. Is my method wrong? Which topic should I use?

edit retag flag offensive close merge delete

Comments

is your path appearing in Rviz? I am trying to do something similar

ngoldfarb gravatar image ngoldfarb  ( 2016-01-12 12:49:30 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-11-18 22:37:00 -0600

ahendrix gravatar image

updated 2014-11-19 20:53:19 -0600

global planners for the ROS navigation stack are implemented as plugins for move_base; not as standalone nodes. This allows for better sharing of maps between different parts of the planner, for example. The path topics that are published from the global planner are for visualization and debugging purposes only.

If you want to implement your own global planner, there is a recently published a tutorial on the subject: http://www.ros.org/news/2014/11/new-t...

edit flag offensive delete link more

Comments

1

@ahendrix: Please note that Clearpath didn't write this particular tutorial (though in our opinion, it's very well written).

Ryan gravatar image Ryan  ( 2014-11-19 19:57:54 -0600 )edit

@Ryan : you are entirely correct. I have no idea why I thought that was a Clearpath tutorial.

ahendrix gravatar image ahendrix  ( 2014-11-19 20:54:31 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-11-18 19:17:27 -0600

Seen: 4,293 times

Last updated: Nov 19 '14