Ask Your Question
0

ros2 launch or python3 foo.launch.py

asked 2021-05-12 02:45:14 -0500

highmax1234 gravatar image

updated 2021-05-12 05:54:37 -0500

I see several example launch files which implement a main, instead of just returning a launch description. Example from ros2/launch/ros repo: https://github.com/ros2/launch_ros/bl...

Is there a guideline which variant to prefer? Are there any advantages in using the ros2 launch variant?

#

edit: This seems to be a conceptual question. From what i can see, the deciding part that makes the nodes run is the following:

ls = launch.LaunchService(argv=argv)
ls.include_launch_description(ld)
return ls.run()

It should be easy to include other LaunchDescriptions from other launch files like so:

client_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([share_dir, '/launch/client.launch.py']), 
        launch_arguments={}.items()
)

I dont see an advantage in letting the ros2 launch system take over the LaunchService, when you lose quite some functionality by not defining your own main.

For example:

  • printing the introspection of the launch file
  • performing tasks after starting the nodes, like calling services

What am I missing that the creators of ros2 launch thought of?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-12 04:06:13 -0500

Spectre gravatar image

From what I've seen the ros2 launch <pkg> <launch_file> method is the "proper" way of doing it. If I had to guess I would say that the example you linked is structured as-such so as to make it self-contained in some way.

As for problems... You might run into weird issues if/when you start trying to reference launch descriptions within each other. E.g. you have a launch file for Node A, one for Node B, and another for Node C. Then you have a "master" launch file that imports some combination of each, and perhaps adds a few other things on top like log levels or miscellaneous ROS command line arguments. I can't say you'll 100% run into problems with the latter approach of using python3, but with the former approach with ros2 launch you'll definitely have no weird behaviors crop-up.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-05-12 02:45:14 -0500

Seen: 76 times

Last updated: May 12 '21