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

Using std::vector Copy Constructor In a Message

asked 2011-10-25 08:01:53 -0600

Constantin S gravatar image

updated 2011-10-25 09:54:34 -0600

Hello all, I am attempting the following code:

vector<float> ranges(360, 10); //A vector of 360 '10's
sensor_msgs::LaserScan currentScan;
currentScan.ranges(ranges);   // <---------- Fails

Here is the cryptic error message:

error: no match for call to ‘(std::vector<float, std::allocator<float> >) (std::vector<float,std::allocator<float> >&)’

I tried googling similar errors but to no avail. If someone could offer some readings on the failure behind this, I would really appreciate this. Thank you

Constantin

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
5

answered 2011-10-25 08:09:55 -0600

Mac gravatar image

You can't use copy-constructor syntax because currentScan.ranges has already been constructed (as part of the constructor for sensor_msgs::LaserScan).

Assignment will work, though:

currentScan.ranges = ranges;
edit flag offensive delete link more

Comments

Ahh of course. Thank you!
Constantin S gravatar image Constantin S  ( 2011-10-25 09:54:10 -0600 )edit

Question Tools

Stats

Asked: 2011-10-25 08:01:53 -0600

Seen: 1,479 times

Last updated: Oct 25 '11