ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
There are a few issues here (some of which you could probably avoid if you go through the ROS tutorials carefully ;) )
while ros::ok()
loop, you should call ros::spinOnce()
instead of spin()
as the latter is a blocking call.euler_t
vector only gets resized in the subscriber callback. As callbacks only get serviced when a spin
(or spinOnce
, see above) has been called, it is perfectly normal that your code trying to access elements of the vector crashes.euler_t
is called before you try accessing elements of it in the while-loop. For this reason (and many others) it's a good idea to check if the vector really has the correct size before trying to access it's elements directly.