How to stop the robot if an obstacle is detected , dont avoid?

Give me some ideas for robot routing. Generate a one-time route (global planing) without using local planing. If it encounters an object, stop it. Until the object escapes from the path, then continue walking until reaching the destination by using ROS. Thank you.

Hello @jakkapong,

I haven’t implemented what you mention so this is just a thought:

You could create two custom nodes: one node to detect obstacles in front of the robot and another one to act as a multiplexer node for the cmd_vel topic.

The node for detecting obstacles should be straightforward: you could use data from a laser scanner or another ranging sensor to detect obstacles. When an obstacle is detected the node will send a twist message to the cmd_vel topic with values 0, making the robot stop.

The multiplexer node subscribes to the various cmd_vel topics, for instance a cmd_vel topic for move_base and the cmd_vel topic from the node that detects obstacles. The multiplexer node will have the responsibility of choosing which velocity command to forward to the robot’s motion controller based on priorities. In this solution you would assign a higher priority to your custom obstacle detection node and a lower priority to the navigation stack.

This means each time the custom obstacle detection node publishes a message (in this case a message to stop the robot) it will have higher priority and the robot will stop. Once the obstacle is gone it will not pubish anything so the cmd_vel command from the Navigation Stack will have priority and the robot will continue moving.

To make this work you will also have to tune many of the Navigation Stack parameters. One example that comes to mind it to modify the planner frequency for the global planner to avoid it to plan a new path. You will most likely also need to tune the local planner parameters.

As always there are many different ways to solve the problem you have, I hope the idea described above inspires you to find a solution that fits your needs.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.