Ask Your Question

How can geometry_msgs::Point use push_back()? [closed]

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

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;


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 reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by harderthan
close date 2018-08-21 00:30:24.788558

1 Answer

Sort by ยป oldest newest most voted

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

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


Thank you.

harderthan gravatar imageharderthan ( 2018-05-14 21:46:53 -0600 )edit

Question Tools

1 follower


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

Seen: 826 times

Last updated: May 03 '18