Ask Your Question
0

publish a path

asked 2018-02-08 02:12:03 -0500

Chris_ROSuser gravatar image

Hello,

I want to publish a path, but with this code I can publish only one point at a time: geometry_msgs::Point msg;

What can I do to publish the path? This page should work, but I don't know exactly how to write the code for it. http://docs.ros.org/api/nav_msgs/html...

Can you help me out? Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-02-08 02:48:19 -0500

rreignier gravatar image

To fill that kind of messages, create a geometry_msgs/PoseStamped and then insert it in the vector poses in the nav_msgs/Path message.

Note that in C++, an variable length array is a std::vector.

So it should look like:

nav_msgs::Path path;

geometry_msgs::PoseStamped pose;

pose.header.stamp = ...;
pose.header.frame_id = ...;
pose.pose.position.x = ...;
[...]

path.header.stamp = ...;
path.header.frame_id = ...;
path.poses.push_back(pose);
edit flag offensive delete link more

Comments

once you publish a path, how do you make a robot follow the published path in rviz? I am using this package to publish predefined paths but my robot wont move along the path...

aarontan gravatar image aarontan  ( 2018-06-16 10:58:41 -0500 )edit

@aarontan It is a complex subject. Maybe you can start here: http://wiki.ros.org/navigation

rreignier gravatar image rreignier  ( 2018-06-25 14:05:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-02-08 02:12:03 -0500

Seen: 3,680 times

Last updated: Feb 08 '18