Set up multiple nodes and parameters at once.
ros2 pkg create hexa_robot_bringup
# {robot name}_bringup : typical launch file naming rule.
cd hexa_robot_bringup
rm -rf include
rm -rf src
mkdir launch
cd launch
touch number_app.launch.py
chomod +x number_app.launch.py ## so we don't have to build everytime with symlink.
ros2 launch {hexa_robot_bringup} {number_app.launch.py}
Here is the format
from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
ld = LaunchDescription()
turtlesim_node = Node(
package = "turtlesim",
executable = "turtlesim_node",
)
turtle_spawner_node = Node(
package="tuetlesim_catch_them_all",
executable="turtle_spawner",
parameters=[
{"spawn_frequency": 0.5},
{"turtle_name_prefix": "hexa_burbach"},
]
)
turtle_controller_node = Node(
package = "tuetlesim_catch_them_all",
executable="turtle_controller",
parameters=[
{"catch_closest_turtle_first": True}
]
)
ld.add_action(turtlesim_node)
ld.add_action(turtle_spawner_node)
ld.add_action(turtle_controller_node)
return ld
in package.xml, add what you need extra.
<exec_depend>my_py_pkg</exec_depend>
<exec_depend>my_cpp_pkg</exec_depend>
**<exec_depend>turtlesim</exec_depend>
<exec_depend>tuetlesim_catch_them_all</exec_depend>**