runtime/rbs_bringup/launch/simulation.launch.py

66 lines
2.6 KiB
Python
Raw Normal View History

2023-07-24 14:57:23 +03:00
import os
from launch_ros.actions import Node
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch_ros.substitutions import FindPackageShare
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
declared_arguments = []
declared_arguments.append(
DeclareLaunchArgument("sim_gazebo", default_value="false", description="Gazebo Simulation")
)
declared_arguments.append(
DeclareLaunchArgument(
"rbs_robot_type",
description="Type of robot by name",
choices=["ur3", "ur3e", "ur5", "ur5e", "ur10", "ur10e", "ur16e"],
default_value="ur5e",
)
)
declared_arguments.append(
DeclareLaunchArgument("env_manager", default_value="false", description="Launch env_manager?")
)
sim_gazebo = LaunchConfiguration("sim_gazebo")
rbs_robot_type = LaunchConfiguration("rbs_robot_type")
env_manager_cond = LaunchConfiguration("env_manager")
# FIXME: To args when we'll have different files
world_config_file = PathJoinSubstitution(
[FindPackageShare("rbs_simulation"), "worlds", "mir.sdf"]
)
# Gazebo nodes
gazebo = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[os.path.join(get_package_share_directory('ros_ign_gazebo'),
'launch', 'ign_gazebo.launch.py')]),
launch_arguments=[('ign_args', [' -r ',world_config_file, " --physics-engine ignition-physics-dartsim-plugin --render-engine ogre2"])],
condition=IfCondition(sim_gazebo))
# Spawn robot
gazebo_spawn_robot = Node(package='ros_ign_gazebo', executable='create',
arguments=[
'-name', rbs_robot_type,
'-x', '0.0',
'-z', '0.0',
'-y', '0.0',
'-topic', '/robot_description'],
output='screen',
condition=IfCondition(sim_gazebo))
env_manager = Node(package="env_manager",
2023-07-24 16:06:39 +03:00
executable="env_manager_node",
2023-07-24 14:57:23 +03:00
condition=IfCondition(env_manager_cond)
)
nodes_to_start = [
gazebo,
gazebo_spawn_robot,
env_manager
]
return LaunchDescription(declared_arguments + nodes_to_start)