Robotics StackExchange | Archived questions

publishing a vector of PointCloud2 vectors in ROS.

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 Objectdetectionmodule. Now I am trying to use this so I am doing the following:

1) I am declaring the header:

objectdetectionmodule/clusterVector.h

2) I am instantiating an object of that type:

objectdetectionmodule::clusterVectorConstPtr msg1;

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

sensormsgs::PointCloud2::Ptr testmessage (new sensormsgs::PointCloud2 ()); msg1->clusterClouds.pushback(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 >, std::allocator > > >::pushback(sensormsgs::PointCloud2std::allocator<void >::Ptr&) const’ /home/polychronis/catkinworkspace/src/objectdetectionmodule/src/objectdetectionclass.cpp:100:46: note: candidates are: /usr/include/c++/4.6/bits/stlvector.h:826:7: note: void std::vector<Tp, Alloc>::pushback(const valuetype&) [with _Tp = sensormsgs::PointCloud2std::allocator<void >, _Alloc = std::allocator<sensormsgs::PointCloud2std::allocator<void > >, std::vector<Tp, Alloc>::valuetype = sensormsgs::PointCloud2std::allocator<void >] /usr/include/c++/4.6/bits/stlvector.h:826:7: note: no known conversion for argument 1 from ‘sensormsgs::PointCloud2std::allocator<void >::Ptr {aka boost::sharedptr > >}’ to ‘const valuetype& {aka const sensormsgs::PointCloud2std::allocator<void >&}’ /usr/include/c++/4.6/bits/stlvector.h:839:7: note: void std::vector<Tp, _Alloc>::pushback(std::vector<Tp, _Alloc>::valuetype&&) [with Tp = sensormsgs::PointCloud2std::allocator<void >, _Alloc = std::allocator<sensormsgs::PointCloud2std::allocator<void > >, std::vector<Tp, Alloc>::valuetype = sensormsgs::PointCloud2std::allocator<void >] /usr/include/c++/4.6/bits/stlvector.h:839:7: note: no known conversion for argument 1 from ‘sensormsgs::PointCloud2std::allocator<void >::Ptr {aka boost::sharedptr > >}’ to ‘std::vector >, std::allocator > > >::valuetype&& {aka sensormsgs::PointCloud2std::allocator<void >&&}’ make[2]: *** [objectdetectionmodule/CMakeFiles/objectdetectionmain.dir/src/objectdetectionclass.cpp.o] Error 1 make[1]: *** [objectdetectionmodule/CMakeFiles/objectdetection_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

Asked by Zoid on 2016-05-02 11:56:59 UTC

Comments

Answers

You declare a

sensor_msgs/PointCloud2[] clusterClouds

and try to push a

sensor_msgs::PointCloud2::Ptr 

inside. Second one is a pointer...

Asked by NEngelhard on 2016-05-02 12:31:21 UTC

Comments

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::pointcloud2std::allocator<void >, std::allocator > > >}’ as ‘this’ argument of ‘void std::vector<Tp, _Alloc>::push_back(const value_type&) [with _Tp = sensor_msgs::PointCloud2std::allocator<void >, Alloc = std::allocator<sensor_msgs::pointcloud2std::allocator<void > >, std::vector<Tp, _Alloc>::value_type = sensor_msgs::PointCloud2std::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

Asked by Zoid on 2016-05-02 13:01:28 UTC

Comments

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

Asked by NEngelhard on 2016-05-02 15:48:16 UTC

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.

Asked by Zoid on 2016-05-03 07:49:24 UTC

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

Asked by NEngelhard on 2016-05-03 08:12:48 UTC