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

Revision history [back]

click to hide/show revision 1
initial version

@Andromeda. BennyRe is right. If you check the documentation for the visualization_msgs::MarkerArray, it contains only one field, Marker[] markers. This field is a vector of markers to store it just declare a std::vector of that type.

/* class #2: different from #1 */ ... ros::Subscriber array_sub = subscribe ("marker_topic", 5, &function, this ); ... std::vector<visualization_msgs::marker> incoming_array; ... void classname::function( const visualization_msgs::MarkerArray& msg ) {

if( !done ) { incoming_array = msg->markers; done = true; } }

With that modification it should work. Sorry for the code being like plain text, I wasn't able to input preformated code for some reason.

@Andromeda. BennyRe is right. If you check the documentation for the visualization_msgs::MarkerArray, it contains only one field, Marker[] markers. This field is a vector of markers to store it just declare a std::vector of that type.

/* class #2: different from #1 */
...
ros::Subscriber array_sub = subscribe ("marker_topic", 5, &function, this );
...
std::vector<visualization_msgs::marker> std::vector<visualization_msgs::Marker> incoming_array;
...
void classname::function( const visualization_msgs::MarkerArray& msg ) {

{

if( !done ) { incoming_array = msg->markers; done = true; } }

}

With that modification it should work. Sorry for the code being like plain text, I wasn't able to input preformated code for some reason.