Slamtec / rplidar_ros

BSD 2-Clause "Simplified" License
485 stars 527 forks source link

[ROS 2] RPLiDAR A1 auto standby not working properly #137

Open jarkenau opened 9 months ago

jarkenau commented 9 months ago

To my understanding, the code responsible for the auto standby assumes that the motor has been started (e.g a node subscribing to the /scan topic) before it can be stopped. This is because is_scanning must be true before the motor can be automatically stopped. https://github.com/Slamtec/rplidar_ros/blob/f0ace62de964af87f8b47f2d91cbd7b5d677f2ca/src/rplidar_node.cpp#L441-L443 is_scanning is only set in the start() method https://github.com/Slamtec/rplidar_ros/blob/f0ace62de964af87f8b47f2d91cbd7b5d677f2ca/src/rplidar_node.cpp#L346 which is only called if auto_standby is disabled or /scan has more than one subscriber https://github.com/Slamtec/rplidar_ros/blob/f0ace62de964af87f8b47f2d91cbd7b5d677f2ca/src/rplidar_node.cpp#L438-L439 https://github.com/Slamtec/rplidar_ros/blob/f0ace62de964af87f8b47f2d91cbd7b5d677f2ca/src/rplidar_node.cpp#L416

A possible solution is to simply skip the check when having no subscribers. Due to the LIDAR starting spinning as soon as it gets power.