0
$\begingroup$

Rosanswers logo

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


Originally posted by Andromeda on ROS Answers with karma: 893 on 2014-11-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Andromeda with karma: 893 on 2014-11-09

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.