Skip to content

Commit

Permalink
WIP towards configurable world
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-hanheide committed Feb 23, 2024
1 parent a271e7c commit 769b211
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
26 changes: 14 additions & 12 deletions uol_tidybot/launch/tidybot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.conditions import IfCondition, UnlessCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import Command, LaunchConfiguration, PythonExpression
from launch.substitutions import Command, LaunchConfiguration, PythonExpression, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():

# Constants for paths to different files and folders
# setting defaults
urdf_model_name = 'tidybot.gazebo'
world_file_name = 'level_1_1.world'
rviz_config_file_name = 'urdf.rviz'
default_world = 'level_1_1.world'

robot_name_in_model = 'limo_gazebosim'

Expand All @@ -30,18 +30,20 @@ def generate_launch_description():

# Set the path to different files and folders.
pkg_gazebo_ros = FindPackageShare(package='gazebo_ros').find('gazebo_ros')
pkg_uol_tidybot = FindPackageShare(package='uol_tidybot').find('uol_tidybot')

default_urdf_model_path = os.path.join(
get_package_share_directory('uol_tidybot'),
'urdf',
urdf_model_name
)

world_path = os.path.join(
get_package_share_directory('uol_tidybot'),
'worlds',
world_file_name
)
#world_path_prefix = os.path.join(
# get_package_share_directory('uol_tidybot'),
# 'worlds'
#)

world_path_prefix = PathJoinSubstitution([FindPackageShare('uol_tidybot'), 'worlds'])

gazebo_models_path = os.path.join(
get_package_share_directory('uol_tidybot'),
Expand All @@ -68,7 +70,7 @@ def generate_launch_description():
use_robot_state_pub = LaunchConfiguration('use_robot_state_pub')
use_rviz = LaunchConfiguration('use_rviz')
use_simulator = LaunchConfiguration('use_simulator')
world = LaunchConfiguration('world')
world = LaunchConfiguration('world', default=default_world)

remappings = [((namespace, '/tf'), '/tf'),
((namespace, '/tf_static'), '/tf_static'),
Expand Down Expand Up @@ -128,8 +130,8 @@ def generate_launch_description():

declare_world_cmd = DeclareLaunchArgument(
name='world',
default_value=world_path,
description='Full path to the world model file to load')
default_value=default_world,
description='Name of the world file in uol_tidybot package')

# Subscribe to the joint states of the robot, and publish the 3D pose of each link.
start_robot_state_publisher_cmd = Node(
Expand Down Expand Up @@ -174,7 +176,7 @@ def generate_launch_description():
start_gazebo_server_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py')),
condition=IfCondition(use_simulator),
launch_arguments={'world': world}.items())
launch_arguments={'world': PathJoinSubstitution([world_path_prefix, world])}.items())

# Start Gazebo client
start_gazebo_client_cmd = IncludeLaunchDescription(
Expand Down
4 changes: 2 additions & 2 deletions uol_tidybot/worlds/level_2_1.world
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@

<model name='obstacle_1'>
<static>1</static>
<pose>0.5 0.0 0.25 0 0 0</pose>
<pose>0.5 0.5 0.25 0 0 0</pose>
<link name='link'>
<collision name='collision'>
<geometry>
Expand Down Expand Up @@ -293,7 +293,7 @@
</geometry>
<material>
<script>
<name>Gazebo/Red</name>
<name>Gazebo/Grey</name>
<uri>file://media/materials/scripts/gazebo.material</uri>
</script>
</material>
Expand Down

0 comments on commit 769b211

Please sign in to comment.