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

Segfault whilst reading message

asked 2014-04-18 19:41:44 -0500

hjed gravatar image

updated 2016-10-24 09:03:32 -0500

ngrennan gravatar image

Hi we've been writting some code to subscribe to the /joint_states topic produced by the husky simulator. However we found that even though all the arrays in /joint_states should be the same length, we are getting an empty array for velocity at random intervals. Which causes a seg fault as there appears to be no way to detect it. (checking if msg->velocity == NULL won't compile). So two questions, is there a way to stop these invalid messages? And if there isn't what is the best way to detect the empty array (gdb says its a boost shared vector).

Thanks, Harry

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-04-18 21:21:52 -0500

The arrays of Float64 data in sensor_msgs/JointState are represented by a std::vector<double> when using roscpp. You should thus be able to get the length of the vector by calling YOUR_MSG.velocity.size().

The "velocity disappearance" issue sounds like a bug to me, but maybe some other husky user or dev can comment on that one.

edit flag offensive delete link more

Comments

Thanks, this is a very good fix for the problem

hjed gravatar image hjed  ( 2014-04-19 02:53:02 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-04-18 19:41:44 -0500

Seen: 231 times

Last updated: Apr 18 '14