To provide obstacle detection RPLidar 2D laser scanner was used to connect with ROS (Robot Operating System). The basic device handling the RPLidar can be found here. The code was extended by an additional node to provide a preview of the obstacle detected. RPlidar measurements are used to calculate the best avoidance direction when getting close to the obstacle. After detecting an object which crosses the safe zone, the algorithm calculates the direction in which the drone should move. The direction is calculated in such a way to allow the drone to stay at a safe distance and simultaneously reduce the amount of surplus route. The direction of the drone’s movement is presented in the turtlesim node. We have prepared a short video which shows how the obstacle detection works.
The second video presents the data output of this algorithm.