Skip to content

Commit

Permalink
added world selection argument
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri van Warmerdam <[email protected]>
  • Loading branch information
YuriVanWarmerdam committed Nov 6, 2024
1 parent 35f5755 commit 36a3dfc
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions rcdt_utilities/launch/gazebo_robot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,45 @@
#
# SPDX-License-Identifier: Apache-2.0

from launch.actions import IncludeLaunchDescription
from launch import LaunchDescription
from typing import List

from launch import LaunchContext, LaunchDescription
from launch.actions import IncludeLaunchDescription, OpaqueFunction
from launch_ros.actions import Node
from rcdt_utilities.launch_utils import get_file_path
from rcdt_utilities.launch_utils import LaunchArgument, get_file_path

world_arg = LaunchArgument("world", "empty.sdf")


gazebo = IncludeLaunchDescription(
get_file_path("ros_gz_sim", ["launch"], "gz_sim.launch.py"),
launch_arguments={"gz_args": "empty.sdf -r"}.items(),
)
def launch_setup(context: LaunchContext) -> List:
gazebo = IncludeLaunchDescription(
get_file_path("ros_gz_sim", ["launch"], "gz_sim.launch.py"),
launch_arguments={"gz_args": f" -r {world_arg.value(context)}"}.items(),
)

spawn_robot = Node(
package="ros_gz_sim",
executable="create",
arguments=["-topic", "/robot_description"],
output="screen",
)
spawn_robot = Node(
package="ros_gz_sim",
executable="create",
arguments=["-topic", "/robot_description"],
output="screen",
)

sync_clock = Node(
package="ros_gz_bridge",
executable="parameter_bridge",
name="sync_clock",
arguments=["/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock"],
)
sync_clock = Node(
package="ros_gz_bridge",
executable="parameter_bridge",
name="sync_clock",
arguments=["/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock"],
)
return [gazebo, spawn_robot, sync_clock]


def generate_launch_description() -> LaunchDescription:
return LaunchDescription(
[
gazebo,
spawn_robot,
sync_clock,
world_arg.declaration,
# gazebo,
# spawn_robot,
# sync_clock,
OpaqueFunction(function=launch_setup),
]
)

0 comments on commit 36a3dfc

Please sign in to comment.