How to run two launch files sequentially?
Hello,
So, i wanted to implement an automatic docking of a mobile robot. The docking includes two phases. 1. Navigating to the area in front of the docking station using move_base) 2. moving to the docking station itself using a package I built. (let's call it the controller package)
The problem is I want the transition from phase 1 to phase 2 to be automatic. That means I want to launch the controller package after I get a "success, goal reached" status from move_base. I tried writing a simple bash script but can't find a way to make the controller package wat successfully.
Any help is appreciated.
Asked by Anjulo on 2022-07-22 00:43:23 UTC
Answers
Wouldn't a simple script like this fix your problem?
set -e
ros2 launch phase1 phase1.launch.py
ros2 launch phase2 phase2.launch.py
All you have to do is make sure that when phase1
exits, it does so with status code zero (simply do exit(0)
when you reach success condition in your code)
but as pablo commented it seems to be over complicating things. You can also launch both nodes at once, and simply trigger the phase2
with a service call or via a topic.
Asked by MAB Jakub on 2022-07-22 07:18:05 UTC
Comments
You could have both nodes activated from the beginning and have some boolean that indicates which of the phases is active to select which is the path that must be followed instead of having 2 planners. Also, you could have in your node used for path planning everything integrated and just check in which place you are to change the goal.
I am not sure if I am getting completely your problem, but going to 2 executables solutions seems to me that is a bit overcomplicating it.
Asked by pablo.arandarod on 2022-07-22 02:59:19 UTC