Skip to content

Commit

Permalink
Fix launch files for using gazebo_ros (#20)
Browse files Browse the repository at this point in the history
Use gazebo_ros to run gzserver & gzclient
  • Loading branch information
ahtsan authored Dec 15, 2021
1 parent b965e5b commit ee0af73
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 91 deletions.
66 changes: 14 additions & 52 deletions launch/no_roof_small_warehouse.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,21 @@

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.conditions import IfCondition
import launch
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node


def generate_launch_description():
# Get the launch directory
aws_small_warehouse_dir = get_package_share_directory('aws_robomaker_small_warehouse_world')

# Launch configuration variables specific to simulation
use_sim_time = LaunchConfiguration('use_sim_time')
use_simulator = LaunchConfiguration('use_simulator')
headless = LaunchConfiguration('headless')
world = LaunchConfiguration('world')

declare_use_sim_time_cmd = DeclareLaunchArgument(
'use_sim_time',
default_value='True',
description='Use simulation (Gazebo) clock if true')

declare_simulator_cmd = DeclareLaunchArgument(
'headless',
default_value='False',
description='Whether to execute gzclient)')

declare_world_cmd = DeclareLaunchArgument(
'world',
default_value=os.path.join(aws_small_warehouse_dir, 'worlds', 'no_roof_small_warehouse', 'no_roof_small_warehouse.world'),
description='Full path to world model file to load')

# Specify the actions
start_gazebo_server_cmd = ExecuteProcess(
cmd=['gzserver', '--verbose', '-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so', world],
cwd=[aws_small_warehouse_dir], output='screen')

start_gazebo_client_cmd = ExecuteProcess(
condition=IfCondition(PythonExpression(['not ', headless])),
cmd=['gzclient'],
cwd=[aws_small_warehouse_dir], output='screen')

# Create the launch description and populate
ld = LaunchDescription()

# Declare the launch options
ld.add_action(declare_use_sim_time_cmd)
ld.add_action(declare_simulator_cmd)
ld.add_action(declare_world_cmd)

# Add any conditioned actions
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)

return ld
ld = launch.LaunchDescription([
launch.actions.IncludeLaunchDescription(
launch.launch_description_sources.PythonLaunchDescriptionSource(
[get_package_share_directory(
'aws_robomaker_small_warehouse_world'), '/launch/small_warehouse.launch.py']
),
launch_arguments={
'world': os.path.join(get_package_share_directory('aws_robomaker_small_warehouse_world'), 'worlds', 'no_roof_small_warehouse', 'no_roof_small_warehouse.world')
}.items()
)
])
return ld
80 changes: 42 additions & 38 deletions launch/small_warehouse.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from ament_index_python.packages import get_package_share_directory

import launch
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.conditions import IfCondition
Expand All @@ -25,50 +26,53 @@


def generate_launch_description():
# Get the launch directory
aws_small_warehouse_dir = get_package_share_directory('aws_robomaker_small_warehouse_world')
# Get the launch directory
aws_small_warehouse_dir = get_package_share_directory('aws_robomaker_small_warehouse_world')
gazebo_ros = get_package_share_directory('gazebo_ros')

# Launch configuration variables specific to simulation
use_sim_time = LaunchConfiguration('use_sim_time')
use_simulator = LaunchConfiguration('use_simulator')
headless = LaunchConfiguration('headless')
world = LaunchConfiguration('world')

# Launch configuration variables specific to simulation
use_sim_time = LaunchConfiguration('use_sim_time')
use_simulator = LaunchConfiguration('use_simulator')
headless = LaunchConfiguration('headless')
world = LaunchConfiguration('world')
declare_use_sim_time_cmd = DeclareLaunchArgument(
'use_sim_time',
default_value='True',
description='Use simulation (Gazebo) clock if true')

declare_use_sim_time_cmd = DeclareLaunchArgument(
'use_sim_time',
default_value='True',
description='Use simulation (Gazebo) clock if true')
declare_simulator_cmd = DeclareLaunchArgument(
'headless',
default_value='False',
description='Whether to execute gzclient)')

declare_simulator_cmd = DeclareLaunchArgument(
'headless',
default_value='False',
description='Whether to execute gzclient)')
declare_world_cmd = DeclareLaunchArgument(
'world',
default_value=os.path.join(aws_small_warehouse_dir, 'worlds', 'small_warehouse', 'small_warehouse.world'),
description='Full path to world model file to load')

declare_world_cmd = DeclareLaunchArgument(
'world',
default_value=os.path.join(aws_small_warehouse_dir, 'worlds', 'small_warehouse', 'small_warehouse.world'),
description='Full path to world model file to load')
# Specify the actions
start_gazebo_server_cmd = launch.actions.IncludeLaunchDescription(
launch.launch_description_sources.PythonLaunchDescriptionSource(
os.path.join(gazebo_ros, 'launch', 'gzserver.launch.py'))
)

# Specify the actions
start_gazebo_server_cmd = ExecuteProcess(
cmd=['gzserver', '--verbose', '-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so', world],
cwd=[aws_small_warehouse_dir], output='screen')
start_gazebo_client_cmd = launch.actions.IncludeLaunchDescription(
launch.launch_description_sources.PythonLaunchDescriptionSource(
os.path.join(gazebo_ros, 'launch', 'gzclient.launch.py')),
condition=IfCondition(PythonExpression(['not ', headless]))
)

start_gazebo_client_cmd = ExecuteProcess(
condition=IfCondition(PythonExpression(['not ', headless])),
cmd=['gzclient'],
cwd=[aws_small_warehouse_dir], output='screen')
# Create the launch description and populate
ld = LaunchDescription()

# Create the launch description and populate
ld = LaunchDescription()
# Declare the launch options
ld.add_action(declare_use_sim_time_cmd)
ld.add_action(declare_simulator_cmd)
ld.add_action(declare_world_cmd)

# Declare the launch options
ld.add_action(declare_use_sim_time_cmd)
ld.add_action(declare_simulator_cmd)
ld.add_action(declare_world_cmd)
# Add any conditioned actions
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)

# Add any conditioned actions
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)

return ld
return ld
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="3">
<name>aws_robomaker_small_warehouse_world</name>
<version>1.0.4</version>
<version>1.0.5</version>
<description>
AWS RoboMaker package for a warehouse world to use in manufacturing and logistics robot applications.
</description>
Expand Down

0 comments on commit ee0af73

Please sign in to comment.