Ask Your Question
0

publishing a vector of PointCloud2 vectors in ROS.

asked 2016-05-02 11:56:59 -0500

Zoid gravatar image

updated 2016-05-02 12:04:18 -0500

Hi all,

I have created a custom message for a vector of PointCloud2 with name clusterVector.msg, and inside that vector I have the following line:

sensor_msgs/PointCloud2[] clusterClouds

This message is inside one of my custom made packages Object_detection_module. Now I am trying to use this so I am doing the following:

1) I am declaring the header:

object_detection_module/clusterVector.h

2) I am instantiating an object of that type:

object_detection_module::clusterVectorConstPtr msg1;

3) I am trying to push_back a type 2 point cloud as follows:

sensor_msgs::PointCloud2::Ptr test_message (new sensor_msgs::PointCloud2 ()); msg1->clusterClouds.push_back(test_message);

Unfortunately, when I am trying to compile my code I get the following error:

error: no matching function for call to ‘std::vector<sensor_msgs::pointcloud2_<std::allocator<void> >, std::allocator<sensor_msgs::pointcloud2_<std::allocator<void> > > >::push_back(sensor_msgs::PointCloud2_<std::allocator<void> >::Ptr&) const’ /home/polychronis/catkin_workspace/src/object_detection_module/src/object_detection_class.cpp:100:46: note: candidates are: /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = sensor_msgs::PointCloud2_<std::allocator<void> >, _Alloc = std::allocator<sensor_msgs::pointcloud2_<std::allocator<void> > >, std::vector<_Tp, _Alloc>::value_type = sensor_msgs::PointCloud2_<std::allocator<void> >] /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: no known conversion for argument 1 from ‘sensor_msgs::PointCloud2_<std::allocator<void> >::Ptr {aka boost::shared_ptr<sensor_msgs::pointcloud2_<std::allocator<void> > >}’ to ‘const value_type& {aka const sensor_msgs::PointCloud2_<std::allocator<void> >&}’ /usr/include/c++/4.6/bits/stl_vector.h:839:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = sensor_msgs::PointCloud2_<std::allocator<void> >, _Alloc = std::allocator<sensor_msgs::pointcloud2_<std::allocator<void> > >, std::vector<_Tp, _Alloc>::value_type = sensor_msgs::PointCloud2_<std::allocator<void> >] /usr/include/c++/4.6/bits/stl_vector.h:839:7: note: no known conversion for argument 1 from ‘sensor_msgs::PointCloud2_<std::allocator<void> >::Ptr {aka boost::shared_ptr<sensor_msgs::pointcloud2_<std::allocator<void> > >}’ to ‘std::vector<sensor_msgs::pointcloud2_<std::allocator<void> >, std::allocator<sensor_msgs::pointcloud2_<std::allocator<void> > > >::value_type&& {aka sensor_msgs::PointCloud2_<std::allocator<void> >&&}’ make[2]: * [object_detection_module/CMakeFiles/object_detection_main.dir/src/object_detection_class.cpp.o] Error 1 make[1]: [object_detection_module/CMakeFiles/object_detection_main.dir/all] Error 2 make: ** [all] Error 2 Invoking "make" failed

Any ideas what I am doing wrong? Any help would be greatly appreciated.

Best,

Akis

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2016-05-02 12:31:21 -0500

NEngelhard gravatar image

You declare a

sensor_msgs/PointCloud2[] clusterClouds

and try to push a

sensor_msgs::PointCloud2::Ptr

inside. Second one is a pointer...

edit flag offensive delete link more
0

answered 2016-05-02 13:01:28 -0500

Zoid gravatar image

Thank you for the answer. However, even if I do the following:

sensor_msgs::PointCloud2 test_message; object_detection_module::clusterVectorConstPtr msg1; msg1->clusterClouds.push_back(test_message);

I am receiving the compilation error:

error: passing ‘const _clusterClouds_type {aka const std::vector<sensor_msgs::pointcloud2_<std::allocator<void> >, std::allocator<sensor_msgs::pointcloud2_<std::allocator<void> > > >}’ as ‘this’ argument of ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = sensor_msgs::PointCloud2_<std::allocator<void> >, _Alloc = std::allocator<sensor_msgs::pointcloud2_<std::allocator<void> > >, std::vector<_Tp, _Alloc>::value_type = sensor_msgs::PointCloud2_<std::allocator<void> >]’ discards qualifiers [-fpermissive] make[2]: * [object_detection_module/CMakeFiles/object_detection_main.dir/src/object_detection_class.cpp.o] Error 1 make[1]: [object_detection_module/CMakeFiles/object_detection_main.dir/all] Error 2 make: ** [all] Error 2 Invoking "make" failed

Thx in advance,

Akis

edit flag offensive delete link more

Comments

Please edit your question as this is no answer to your question!

NEngelhard gravatar image NEngelhard  ( 2016-05-02 15:48:16 -0500 )edit

Sorry for that... Unfortunately, I am not familiar with your forum. Could you please let me know how to properly comment your answer since if I only try to "add a comment" to your text, it does not allow me due to max text length. Thx.

Zoid gravatar image Zoid  ( 2016-05-03 07:49:24 -0500 )edit

Just edit your original question. And BTW: you try to change a Const(!!)Ptr

NEngelhard gravatar image NEngelhard  ( 2016-05-03 08:12:48 -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

1 follower

Stats

Asked: 2016-05-02 11:56:59 -0500

Seen: 751 times

Last updated: May 02 '16