This PR fixes two issue we've experienced using the driver with the VN-100 on a mobile robot running ROS 2 Humble.
First in the current ros2 branch reconnecting is not working. The reconnect timer is trying to connect but it keeps throwing an exception and never connects.
We've had an issue with the driver stopping and throwing a segfault on our robots.
I tracked this down to an issue with how the driver was cleaning up when it reconnects. Every time connect is called on the vn::sensors::VnSensor object it spawns a new thread to handle the serial port. If disconnect is never called then the thread is never exited and will keep going. For us when the driver was trying to reconnect it ended with multiple threads running which was causing segfaults because of invalid iterators in the dataReceieved callback of packet_finder.cpp.
What I've tried to so with the changes I made was make sure to disconnect and clean up the VnSensor object whenever the driver reconnects and this has fixed the issue for us. We have been able to run the driver reliably without and segfaults and happily disconnect/reconnecting without any issues.
This PR fixes two issue we've experienced using the driver with the VN-100 on a mobile robot running ROS 2 Humble.
I tracked this down to an issue with how the driver was cleaning up when it reconnects. Every time connect is called on the vn::sensors::VnSensor object it spawns a new thread to handle the serial port. If disconnect is never called then the thread is never exited and will keep going. For us when the driver was trying to reconnect it ended with multiple threads running which was causing segfaults because of invalid iterators in the dataReceieved callback of packet_finder.cpp.
What I've tried to so with the changes I made was make sure to disconnect and clean up the VnSensor object whenever the driver reconnects and this has fixed the issue for us. We have been able to run the driver reliably without and segfaults and happily disconnect/reconnecting without any issues.