Ask Your Question
0

Copying "visualization_msgs::MarkerArray" as a vector

asked 2014-11-09 03:56:57 -0500

Andromeda gravatar image

updated 2014-11-09 04:07:03 -0500

I'm attemping to copy that message over the topic visualization_msgs::MarkerArray with a function like this:

void myclass::incomingPoints( const visualization_msgs::MarkerArray &waypoints ) 
{
    goals.reserve( waypoints->markers.size() );
    copy( waypoints->markers.begin(), waypoints->markers.end(), back_inserter( goals ) );
}

where:

std::vector<visualization_msgs::Marker> goals;

But trying to compile I get the error that says: .begin(), .size(), and .end() are not defined in the

visualization_msgs::Marker

error: base operand of ‘->’ has non-pointer type ‘const MarkerArray {aka const visualization_msgs::MarkerArray_<std::allocator<void>

}’ goals.reserve( waypoints->markers.size() );

and that's ok, because they are in the class vector defined. But how can I copy that array?

Regards

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2014-11-09 04:17:54 -0500

Andromeda gravatar image

updated 2014-11-09 04:19:22 -0500

Ok, I can answer myself.

I discoevered the using such function signature:

void myclass::incomingPoints( const visualization_msgs::MarkerArray &waypoints ) 
{
    goals.reserve( waypoints.markers.size() );    <---- Note the point!!!
    copy( waypoints.markers.begin(), waypoints.markers.end(), back_inserter( goals ) );   <---- Note the point!!!
}

it compiles

And changing the signature to:

void myclass::incomingPoints( const visualization_msgs::MarkerArray::ConstPtr &waypoints ) 
{
    goals.reserve( waypoints->markers.size() );    <---- Note the arrow
    copy( waypoints->markers.begin(), waypoints->markers.end(), back_inserter( goals ) );   <---- Note the arrow
}

even works.

Function signature and called method must also match.

edit flag offensive delete link more

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: 2014-11-09 03:56:57 -0500

Seen: 671 times

Last updated: Nov 09 '14