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

How does python launch file works in ros2?

asked 2023-08-06 07:38:06 -0600

Brijrajsinh Raolji gravatar image

updated 2023-08-06 07:38:20 -0600

I Used to work on ROS1 8 months ago and it was quite easy to work with launch files. Now I am working with ros2 after all these months and even after referring to many resources I am unable to create a launch file which can launch a simple empty gazebo world in ignition citadel. I am using ros2 foxy and I want to create a project in it which requires many things but I am not able to launch a simple world in gazebo. So I want to ask if anyone could explain me how launch file is created, how it works in ros2 foxy and how I can launch a simple empty world in gazebo ignition citadel. Even referring to any proper resource would be a great help


I have already tried creating a launch file for talker and listener but m unable to help myself for this one.

Thank You in advance

edit retag flag offensive close merge delete

Comments

Just to draw attention to it (as I don't see it mentioned often in the context of "ROS 2 launch files"): you don't have to use Python-based launch files in ROS 2. The XML syntax is still supported. Especially for simpler launch files (loading some nodes, setting some parameters), I would not necessarily recommend using Python-based launch files.

The .launch.py files were/are intended for more complex scenarios where the "power of a full programming language" would be helpful. Declarative systems can only do so much, and sometimes an imperative approach is just easier. That's when you want to use Python.

For a simple system where you're looking to just launch some nodes, I'd suggest to stick to the XML version of ROS 2 launch files. And you can mix-and-match Python and XML launch files.

The only 'good' documentation on it I know would ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2023-08-07 01:00:35 -0600 )edit

Thank you for addressing my concern. I am working to develop a swarm robotics project and right now in initial phase I am developing and configuring a single bot and then will go on communication between those bots and on collective decision making and for that I think going with python file might be beneficial for me (I might be wrong please correct me if I am). And my main concern is that I am unable to get lunch directory in share folder of install directory by colcon build, so I think I have not understood the basic of launch file for ros2 correctly. Can you help me out with anything for that? Thank you again :)

Brijrajsinh Raolji gravatar image Brijrajsinh Raolji  ( 2023-08-07 02:02:34 -0600 )edit

I am developing and configuring a single bot and then will go on communication between those bots and on collective decision making and for that I think going with python file might be beneficial for me

will the "communication" and "collective decision making" be implemented in the launch file, or in the nodes?

Probably the nodes.

Unless you want to implement (parts of) system runtime management (ie: managed nodes) in your launch file (which gets complex really, really quickly), I'd not expect any logic in the launch files themselves, but in the nodes.

gvdhoorn gravatar image gvdhoorn  ( 2023-08-07 03:36:50 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-08-06 22:07:54 -0600

This link will help: https://github.com/linorobot/linorobot2 He has a Gazebo launch routine in the repo. You can use parts from that, and delete parts you don't need, and change others.

edit flag offensive delete link more

Comments

Thank You very much, I refereed it and now my launch file is working. Some modifications are needed yet but its working. Thank you once again :)))

Brijrajsinh Raolji gravatar image Brijrajsinh Raolji  ( 2023-08-07 02:45:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2023-08-06 07:38:06 -0600

Seen: 716 times

Last updated: Aug 06 '23