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

How can geometry_msgs::Point use push_back()?

asked 2018-05-02 23:26:49 -0500

harderthan gravatar image

Hello, guys.

I'm trying to study rviz with tutorials provided by ros wiki. I built a sample of document using catkin_make, saw the result.

On the line of this sample codes,

...
visualization_msgs::Marker points, line_strip, line_list;
...
for(ellipsis) {
    ...
    geometry_msgs::Point p;
    p.x = (int32_t)i - 50;
    p.y = y;
    p.z = z;

    points.points.push_back(p);
    ...
}
...

How can the variable of geometry_msgs::Point type use push_back()?

I saw it's msg header on the link
It is just msg consist of 3 variables of float64 type. The function, push_back(), It appears to be used like push_back of stl.

Could you tell me how this works?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
6

answered 2018-05-03 05:24:15 -0500

gvdhoorn gravatar image

visualization_msgs/Marker contains a points field, which is of type geometry_msgs/Point[]. That is an unbounded array (== list) of geometry_msgs/Points.

Lists in the ROS msg IDL are mapped to std::vectors for C++ (see wiki/msg - Message Description Specification - Array handling).

And std::vector has a push_back(..) method that in this case will take geometry_msgs/Point.

edit flag offensive delete link more

Comments

Thank you.

harderthan gravatar image harderthan  ( 2018-05-14 21:46:53 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-05-02 23:26:49 -0500

Seen: 2,633 times

Last updated: May 03 '18