0
$\begingroup$

Rosanswers logo

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/msg/Path.html

Can you help me out? Thank you


Originally posted by Chris_ROSuser on ROS Answers with karma: 31 on 2018-02-08

Post score: 3

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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);

Originally posted by rreignier with karma: 544 on 2018-02-08

This answer was ACCEPTED on the original site

Post score: 5


Original comments

Comment by aarontan on 2018-06-16:
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...

Comment by rreignier on 2018-06-25:
@aarontan It is a complex subject. Maybe you can start here: http://wiki.ros.org/navigation

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.