Open goruck opened 7 years ago
Needed to add "respawn_delay = 30" attribute for the usb_cam_node in the launch file since the reconnection may fail if attempted too soon after a crash. With this the camera always reconnects for me and as a added bonus it stays on the same port so the top camera remains mapped to /dev/video0 assuming its physically plugged into the right USB port on the Raspberry Pi.
The get_topic_data function in nodes/api.py wasn't really useful beyond specific messages. I've rewritten it to be general and more robust. I've added this changes to this PR. Note that get_topic_data depends on rospy_message_converter so I added that to scripts/generate_rosinstall. I'll also open an issue and link it to this PR just in case someone tries to use it and runs into problems.
The usb_cam_node driver crashes frequently because the USB port loses connection with the camera and the driver tries to read from it before the port gets automatically reconnected by the Raspberry Pi's OS.
You'll see an error like the following:
Note that the USB port automatically gets reconnected but not before the driver attempts a read which causes it to crash.
The errors above are generated in the usb_cam ros driver here:
which caused the process to be killed:
The simple solution is to specify the respawn = "true" attribute for the usb_cam_node in the launch file so that if it crashes ROS will automatically restart it.
This seems to work well as evidenced by the roslaunch log file:
It's not clear why the USB ports disconnect in the first place but since they get automatically reconnected this will mitigate the crash of the USB camera driver. We should still seek the root cause of the Raspberry Pi's USB ports in this regard.