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

Revision history [back]

There is a good chance that your problem is caused because the code on your micro controller doesn't terminate when the nodes running on your raspberry pi are shutdown. This is causing your robot to continue moving at the final velocity it was commanded to.

There is a convention and a strong safety reason why you should write your micro-controller code so this is impossible. The serial connection could be lost for many reasons, computer crashes, serial cable unplugged, etc. In all these cases you want your robot to stop moving as quickly as possible.

This is achieved by writing code which sets the target velocity to zero if a cmd_vel message hasn't been received within a set period of time. If your cmd_vel topic usually runs at 100 Hz then a half second limit should allow it to ignore brief gaps in messages but also stop quickly enough if the serial connection is lost. Using this approach your robot will always stop whenever the rosserial node is closed.

Hope this helps.