ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to run two launch files sequentially?

asked 2022-07-22 00:43:23 -0500

Anjulo gravatar image

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.

edit retag flag offensive close merge delete

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.

pablo.arandarod gravatar image pablo.arandarod  ( 2022-07-22 02:59:19 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-07-22 07:18:05 -0500

MAB Jakub gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-07-22 00:43:23 -0500

Seen: 83 times

Last updated: Jul 22 '22