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

how to store a ConstPtr msg into a vector?

asked 2020-02-25 10:00:09 -0600

Zep gravatar image

Hi, I am a ROS and C++ beginner. My aim is to merge frontiers of multiple robot exploration based on frontier exploration. I've tried several ways to achieve that, but the easiest one is to merge frontiers pose together, and the problem here is about how to create a vector to store many robot/frontiers topic output msgs. Those msgs are ConstPtr, so it cannot be directly stored into vector, otherwise some errors happened in the terminal. Could someone have any suggestions? Thanks a lot.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-02-26 02:43:50 -0600

mgruhler gravatar image

You need to create a copy of the msg the pointer is pointing do. You can do that by dereferencing it. my_vector.push_back(*msg)

I guess it would make sense for you to look up a bit on C++ programming, especially with regards to pointers. Also related is #q212857.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-02-25 10:00:09 -0600

Seen: 451 times

Last updated: Feb 26 '20