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

Copying "visualization_msgs::MarkerArray" as a vector

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

Andromeda gravatar image

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

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 -0600

Andromeda gravatar image

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

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

Question Tools

1 follower

Stats

Asked: 2014-11-09 03:56:57 -0600

Seen: 1,027 times

Last updated: Nov 09 '14