Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 117 additions & 76 deletions common/robotnik_simulation_bringup/launch/bringup_complete.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,163 +24,204 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from launch import LaunchDescription
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.substitutions import FindPackageShare
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.actions import GroupAction, DeclareLaunchArgument, IncludeLaunchDescription
from launch.actions import (
DeclareLaunchArgument,
GroupAction,
IncludeLaunchDescription,
TimerAction,
)
from launch.conditions import IfCondition
from launch.actions import TimerAction
from launch.substitutions import EqualsSubstitution, OrSubstitution
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import (
EqualsSubstitution,
LaunchConfiguration,
OrSubstitution,
PathJoinSubstitution,
)
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():

declared_arguments = [
DeclareLaunchArgument(
"robot_id",
default_value="robot",
description="Name for launch and config resources"
description="Name for launch and config resources",
),
DeclareLaunchArgument(
"robot",
default_value="rbsummit",
description="Robot Model Name",
),
DeclareLaunchArgument(
"robot_model",
default_value="rbsummit",
description="Set robot model"
description="Set robot model",
),
DeclareLaunchArgument(
"use_gui",
default_value="true",
description="Enable simulation gui"
description="Enable simulation gui",
),
DeclareLaunchArgument(
"low_performance_simulation",
default_value="true",
description="Enable smooth simulation for low performance computers"
description="Enable smooth simulation for low performance computers",
),
DeclareLaunchArgument(
"use_rviz",
default_value="true",
description="Enable rviz gui"
description="Enable rviz gui",
),
DeclareLaunchArgument(
"world_path",
default_value=PathJoinSubstitution([
#FindPackageShare('electrical_substation_world'), 'worlds/electrical_substation.world'
FindPackageShare('robotnik_gazebo_ignition'), 'worlds/demo.world',
]),
description="Path to the world file"
default_value=PathJoinSubstitution(
[
# FindPackageShare('electrical_substation_world'), 'worlds/electrical_substation.world'
FindPackageShare("robotnik_gazebo_ignition"),
"worlds/demo.world",
]
),
description="Path to the world file",
),
DeclareLaunchArgument(
"has_arm",
default_value="false",
description="Enable Arm Controller",
),
]

robot_id = LaunchConfiguration("robot_id")
robot = LaunchConfiguration("robot")
robot_model = LaunchConfiguration("robot_model")
use_gui = LaunchConfiguration("use_gui")
low_performance_simulation = LaunchConfiguration("low_performance_simulation")
world_path = LaunchConfiguration("world_path")
use_rviz = LaunchConfiguration("use_rviz")
has_arm = LaunchConfiguration("has_arm")

gazebo_world = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution([
FindPackageShare('robotnik_gazebo_ignition'), 'launch/spawn_world.launch.py'
])
PathJoinSubstitution(
[
FindPackageShare("robotnik_gazebo_ignition"),
"launch/spawn_world.launch.py",
]
)
),
launch_arguments={
'robot_id': robot_id,
'gui': use_gui,
'world_path': world_path
}.items()
"robot_id": robot_id,
"gui": use_gui,
"world_path": world_path,
}.items(),
)

gazebo_robot = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution([
FindPackageShare('robotnik_gazebo_ignition'), 'launch/spawn_robot.launch.py'
])
PathJoinSubstitution(
[
FindPackageShare("robotnik_gazebo_ignition"),
"launch/spawn_robot.launch.py",
]
)
),
launch_arguments={
'robot_id': robot_id,
'robot': robot_model,
'low_performance_simulation': low_performance_simulation,
'run_rviz': 'false'
}.items()
"robot_id": robot_id,
"robot": robot,
"robot_model": robot_model,
"low_performance_simulation": low_performance_simulation,
"run_rviz": "false",
"has_arm": has_arm,
}.items(),
)
delayed_spawn_robot = TimerAction(period=5.0, actions=[gazebo_robot])

# In spawn_robot.launch.py the add_laser("front") is defined for any robot model
# This causes two publishers to /robot/front_laser/scan when laser filters are enabled
# In rbsummit and rbwatcher is not an issue because front laser is not available
# but in other robot models that have front laser, it causes conflict.
laser_filters = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution([
FindPackageShare('robotnik_simulation_bringup'), 'launch/laser_filters.launch.py'
])
PathJoinSubstitution(
[
FindPackageShare("robotnik_simulation_bringup"),
"launch/laser_filters.launch.py",
]
)
),
launch_arguments={
'robot_id': robot_id,
'use_sim': 'true',
"robot_id": robot_id,
"use_sim": "true",
}.items(),
condition=IfCondition(
OrSubstitution(
EqualsSubstitution(robot_model, 'rbsummit'),
EqualsSubstitution(robot_model, 'rbwatcher'),
EqualsSubstitution(robot_model, "rbsummit"),
EqualsSubstitution(robot_model, "rbwatcher"),
)
)
),
)
delayed_laser_filters = TimerAction(period=6.0, actions=[laser_filters])

localization = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution([
FindPackageShare('robotnik_simulation_localization'), 'launch/localization.launch.py'
])
PathJoinSubstitution(
[
FindPackageShare("robotnik_simulation_localization"),
"launch/localization.launch.py",
]
)
),
launch_arguments={
'robot_id': robot_id,
'use_sim': 'true',
}.items()
"robot_id": robot_id,
"use_sim": "true",
}.items(),
)

delayed_localization = TimerAction(
period=10.0,
actions=[localization]
)
delayed_localization = TimerAction(period=10.0, actions=[localization])

navigation = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution([
FindPackageShare('robotnik_simulation_navigation'), 'launch/navigation.launch.py'
])
PathJoinSubstitution(
[
FindPackageShare("robotnik_simulation_navigation"),
"launch/navigation.launch.py",
]
)
),
launch_arguments={
'robot_id': robot_id,
'use_sim': 'true',
}.items()
"robot_id": robot_id,
"use_sim": "true",
}.items(),
)

delayed_navigation = TimerAction(
period=15.0,
actions=[navigation]
)
delayed_navigation = TimerAction(period=15.0, actions=[navigation])

rviz = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution([
FindPackageShare('robotnik_simulation_bringup'), 'launch/rviz.launch.py'
])
PathJoinSubstitution(
[
FindPackageShare("robotnik_simulation_bringup"),
"launch/rviz.launch.py",
]
)
),
condition=IfCondition(use_rviz)
condition=IfCondition(use_rviz),
)

delayed_rviz = TimerAction(
period=20.0,
actions=[rviz]
)
delayed_rviz = TimerAction(period=20.0, actions=[rviz])

group = GroupAction([
gazebo_world,
gazebo_robot,
laser_filters,
delayed_localization,
delayed_navigation,
delayed_rviz
])
group = GroupAction(
[
gazebo_world,
delayed_spawn_robot,
delayed_laser_filters,
# gazebo_robot,
# laser_filters,
delayed_localization,
delayed_navigation,
delayed_rviz,
]
)

return LaunchDescription(declared_arguments + [group])
return LaunchDescription(declared_arguments + [group])
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def generate_launch_description():
'robot_id': robot_id,
'use_sim': use_sim,
}.items(),
condition=IfCondition(run_mapping)
)

group = GroupAction([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ def generate_launch_description():
lifecycle_manager_localization,
])

return LaunchDescription([group])
return LaunchDescription([group])
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ def generate_launch_description():
lifecycle_manager_mapping
])

return LaunchDescription([group])
return LaunchDescription([group])
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def generate_launch_description():
arguments=[
'-f', [maps_path, '/', map_folder_name, '/', map_name], # /tmp/demo_map/demo_map.file
'--fmt', 'pgm', # Map format
'-t', "robot_map" # Map topic
'-t', "map", # Map topic
]
)

Expand All @@ -137,4 +137,4 @@ def generate_launch_description():
move_after_save
])

return LaunchDescription(declared_arguments + [group])
return LaunchDescription(declared_arguments + [group])