SMACC2
Functions
gazebo_launch Namespace Reference

Functions

def generate_launch_description ()
 

Function Documentation

◆ generate_launch_description()

def gazebo_launch.generate_launch_description ( )

Definition at line 25 of file gazebo_launch.py.

26 declare_use_simulator_cmd = DeclareLaunchArgument(
27 "use_simulator", default_value="False", description="Whether to execute gzclient)"
28 )
29
30 use_simulator = LaunchConfiguration("use_simulator")
31 world = LaunchConfiguration("world")
32 headless = LaunchConfiguration("headless")
33 show_gz_lidar = LaunchConfiguration("show_gz_lidar")
34
35 sm_dance_bot_dir = get_package_share_directory("sm_dance_bot")
36 launch_dir = os.path.join(sm_dance_bot_dir, "launch")
37
38 declare_use_simulator_cmd = DeclareLaunchArgument(
39 "use_simulator", default_value="True", description="Whether to start the simulator"
40 )
41
42 declare_simulator_cmd = DeclareLaunchArgument(
43 "headless", default_value="False", description="Whether to execute gzclient)"
44 )
45
46 declare_show_gz_lidar = DeclareLaunchArgument(
47 "show_gz_lidar",
48 default_value="True",
49 description="Whether to apply a namespace to the navigation stack",
50 )
51
52 declare_world_cmd = DeclareLaunchArgument(
53 "world",
54 default_value=os.path.join(sm_dance_bot_dir, "worlds", "ridgeback_race.world"),
55 description="Full path to world model file to load",
56 condition=IfCondition(show_gz_lidar),
57 )
58
59 declare_world_cmd_2 = DeclareLaunchArgument(
60 "world",
61 default_value=os.path.join(sm_dance_bot_dir, "worlds", "ridgeback_race_no_lidar.world"),
62 description="Full path to world model file to load",
63 condition=UnlessCondition(show_gz_lidar),
64 )
65
66 # Create the launch description and populate
67 ld = LaunchDescription()
68
69 # xtermprefix = "xterm -xrm 'XTerm*scrollBar: true' -xrm 'xterm*rightScrollBar: true' " \
70 # "-hold -geometry 1000x600 -sl 10000 -e"
71
72 gzenv = dict(os.environ)
73 model_database_uri = os.environ["GAZEBO_MODEL_PATH"]
74 gzenv["GAZEBO_MODEL_DATABASE_URI"] = model_database_uri
75
76 # Specify the actions
77 start_gazebo_server_cmd = ExecuteProcess(
78 condition=IfCondition(use_simulator),
79 cmd=["gzserver", "-s", "libgazebo_ros_init.so", world, "--verbose"],
80 env=gzenv,
81 cwd=[launch_dir],
82 output="screen",
83 )
84
85 start_gazebo_client_cmd = ExecuteProcess(
86 condition=IfCondition(PythonExpression([use_simulator, " and not ", headless])),
87 cmd=["gzclient"],
88 cwd=[launch_dir],
89 env=gzenv,
90 output="screen",
91 )
92
93 # Add any conditioned actions
94 ld.add_action(declare_simulator_cmd)
95 ld.add_action(declare_use_simulator_cmd)
96 ld.add_action(declare_world_cmd)
97 ld.add_action(declare_world_cmd_2)
98
99 ld.add_action(declare_show_gz_lidar)
100
101 ld.add_action(start_gazebo_server_cmd)
102 ld.add_action(start_gazebo_client_cmd)
103
104 return ld
def generate_launch_description()