Skip to content

Commit

Permalink
Merge pull request #4 from IOES-Lab/worlds
Browse files Browse the repository at this point in the history
[GSOC-51] DAVE worlds and respective launch files
  • Loading branch information
hmoyen authored Jun 27, 2024
2 parents db639af + d47d52b commit 585101d
Show file tree
Hide file tree
Showing 19 changed files with 3,044 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@

# vs code
.vscode

# Mac
.DS_Store
22 changes: 22 additions & 0 deletions examples/dave_demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,25 @@ If you prefer to use model files downloaded from Fuel, proceed as follows:
```

This approach gives you more control over the models you use, allowing for offline use and customization. It's especially useful when working in environments with limited internet connectivity or when specific model versions are required.

### 3. Launching a World File

To launch a specific world file, you can specify the world name without the `.world` extension. Follow these steps:

1. Build and source the workspace:

```bash
colcon build && source install/setup.bash
```

1. Launch the world using the specified launch file

```bash
ros2 launch dave_demos dave_world.launch.py world_name:='dave_ocean_waves'
```

To check which worlds are available to launch, refer to `models/dave_worlds/worlds` directory.

The worlds files are linked to use models at https://app.gazebosim.org/ which means you need an internet connection to download the models and it takes some time to download at first launch. The files are saved in temporary directories and are reused in subsequent launches.

In this setup, you can dynamically specify different world files by changing the `world_name` argument in the launch command.
42 changes: 42 additions & 0 deletions examples/dave_demos/launch/dave_world.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration


def launch_setup(context, *args, **kwargs):

pkg_dave_worlds = get_package_share_directory("dave_worlds")
pkg_ros_gz_sim = get_package_share_directory("ros_gz_sim")

world_name = LaunchConfiguration("world_name").perform(context)
world_file_name = f"{world_name}.world"

world_path = os.path.join(pkg_dave_worlds, "worlds", world_file_name)

# Gazebo simulation launch
gz_sim = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(pkg_ros_gz_sim, "launch", "gz_sim.launch.py")),
launch_arguments={"gz_args": f"-r {world_path}"}.items(),
)

return [gz_sim]


def generate_launch_description():
return LaunchDescription(
[
DeclareLaunchArgument(
"world_name",
default_value="dave_bimanual_example", # Default world file name without extension
description="Name of the world file",
),
OpaqueFunction(function=launch_setup),
]
)


if __name__ == "__main__":
generate_launch_description()
15 changes: 15 additions & 0 deletions models/dave_worlds/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.5)
project(dave_worlds)

# Find dependencies
find_package(ament_cmake REQUIRED)

install(
DIRECTORY worlds media
DESTINATION share/${PROJECT_NAME}
)

ament_environment_hooks(
"${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in")

ament_package()
1 change: 1 addition & 0 deletions models/dave_worlds/hooks/dave_worlds.dsv.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prepend-non-duplicate;GZ_SIM_RESOURCE_PATH;@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
18 changes: 18 additions & 0 deletions models/dave_worlds/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>dave_worlds</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">lena</maintainer>
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading

0 comments on commit 585101d

Please sign in to comment.