Skip to content

Commit

Permalink
Rebase with ros2 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshv24 committed Sep 4, 2024
1 parent 98d4849 commit 92fa2b4
Show file tree
Hide file tree
Showing 29 changed files with 1,334 additions and 269 deletions.
50 changes: 42 additions & 8 deletions examples/dave_demos/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
## Examples
# Examples

### 1. Launching a Dave Object Model using Fuel URI
## Launching a Dave Object Model using Fuel URI

To launch a Dave model directly from a Fuel URI, follow these steps:

1. Build and source the workspace:
1. Copy and paste the model URI into the `model.sdf` file as shown [here](https://github.com/IOES-Lab/dave/blob/ros2/models/dave_object_models/description/mossy_cinder_block/model.sdf).

2. Build and source the workspace:

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

2. Launch the model using the specified launch file:
3. Launch the model using the specified launch file:

```bash
ros2 launch dave_demos dave_object.launch.py namespace:='mossy_cinder_block' paused:=false
```

This method simplifies the process by pulling the model directly from Fuel, ensuring you always have the latest version without needing to manage local files.

### 2. Launching a Dave Sensor Model using Downloaded Model Files
## Launching a Dave Sensor Model using Downloaded Model Files

If you prefer to use model files downloaded from Fuel, proceed as follows:

Expand Down Expand Up @@ -52,7 +54,39 @@ 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
## Launching a Dave Robot Model

Before launching, ensure to build and source the workspace:

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

1. Launching REXROV in an empty world:

```bash
ros2 launch dave_demos dave_robot.launch.py z:=2.0 namespace:=rexrov world_name:=empty.sdf paused:=false
```

2. Launching REXROV in dave_ocean_waves.world:

```bash
ros2 launch dave_demos dave_robot.launch.py z:=-5 namespace:=rexrov world_name:=dave_ocean_waves paused:=false
```

3. Launching Slocum Glider in an empty world:

```bash
ros2 launch dave_demos dave_robot.launch.py z:=0.2 namespace:=glider_slocum world_name:=empty.sdf paused:=false
```

4. Launching Slocum Glider in dave_ocean_waves.world:

```bash
ros2 launch dave_demos dave_robot.launch.py x:=4 z:=-1.5 namespace:=glider_slocum world_name:=dave_ocean_waves paused:=false
```

## Launching a World File

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

Expand All @@ -62,14 +96,14 @@ To launch a specific world file, you can specify the world name without the `.wo
colcon build && source install/setup.bash
```

1. Launch the world using the specified launch file
2. 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.
The world 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.
62 changes: 34 additions & 28 deletions examples/dave_demos/launch/dave_object.launch.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, TextSubstitution
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.conditions import IfCondition
from launch_ros.substitutions import FindPackageShare


def launch_setup(context, *args, **kwargs):
paused = LaunchConfiguration("paused").perform(context)
gui = LaunchConfiguration("gui").perform(context)
use_sim_time = LaunchConfiguration("use_sim_time").perform(context)
headless = LaunchConfiguration("headless").perform(context)
verbose = LaunchConfiguration("verbose").perform(context)
namespace = LaunchConfiguration("namespace").perform(context)
world_name = LaunchConfiguration("world_name").perform(context)
x = LaunchConfiguration("x").perform(context)
y = LaunchConfiguration("y").perform(context)
z = LaunchConfiguration("z").perform(context)
roll = LaunchConfiguration("roll").perform(context)
pitch = LaunchConfiguration("pitch").perform(context)
yaw = LaunchConfiguration("yaw").perform(context)
use_ned_frame = LaunchConfiguration("use_ned_frame").perform(context)
paused = LaunchConfiguration("paused")
gui = LaunchConfiguration("gui")
use_sim_time = LaunchConfiguration("use_sim_time")
debug = LaunchConfiguration("debug")
headless = LaunchConfiguration("headless")
verbose = LaunchConfiguration("verbose")
namespace = LaunchConfiguration("namespace")
world_name = LaunchConfiguration("world_name")
x = LaunchConfiguration("x")
y = LaunchConfiguration("y")
z = LaunchConfiguration("z")
roll = LaunchConfiguration("roll")
pitch = LaunchConfiguration("pitch")
yaw = LaunchConfiguration("yaw")
use_ned_frame = LaunchConfiguration("use_ned_frame")

if world_name != "empty.sdf":
if world_name.perform(context) != "empty.sdf":
world_name = LaunchConfiguration("world_name").perform(context)
world_filename = f"{world_name}.world"
world_filepath = PathJoinSubstitution(
[FindPackageShare("dave_worlds"), "worlds", world_filename]
).perform(context)
)
gz_args = [world_filepath]
else:
gz_args = [world_name]

if headless == "true":
gz_args.append("-s")
if paused == "false":
gz_args.append("-r")
if verbose == "true":
gz_args.append("--verbose")

gz_args_str = " ".join(gz_args)
if headless.perform(context) == "true":
gz_args.append(" -s")
if paused.perform(context) == "false":
gz_args.append(" -r")
if debug.perform(context) == "true":
gz_args.append(" -v ")
gz_args.append(verbose.perform(context))

gz_sim_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
Expand All @@ -53,7 +54,7 @@ def launch_setup(context, *args, **kwargs):
]
),
launch_arguments=[
("gz_args", TextSubstitution(text=gz_args_str)),
("gz_args", gz_args),
],
condition=IfCondition(gui),
)
Expand Down Expand Up @@ -105,15 +106,20 @@ def generate_launch_description():
default_value="true",
description="Flag to indicate whether to use simulation time",
),
DeclareLaunchArgument(
"debug",
default_value="false",
description="Flag to enable the gazebo debug flag",
),
DeclareLaunchArgument(
"headless",
default_value="false",
description="Flag to enable the gazebo headless mode",
),
DeclareLaunchArgument(
"verbose",
default_value="false",
description="Enable verbose mode for Gazebo simulation",
default_value="0",
description="Adjust level of console verbosity",
),
DeclareLaunchArgument(
"world_name",
Expand Down
62 changes: 34 additions & 28 deletions examples/dave_demos/launch/dave_sensor.launch.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, TextSubstitution
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.conditions import IfCondition
from launch_ros.substitutions import FindPackageShare


def launch_setup(context, *args, **kwargs):
paused = LaunchConfiguration("paused").perform(context)
gui = LaunchConfiguration("gui").perform(context)
use_sim_time = LaunchConfiguration("use_sim_time").perform(context)
headless = LaunchConfiguration("headless").perform(context)
verbose = LaunchConfiguration("verbose").perform(context)
namespace = LaunchConfiguration("namespace").perform(context)
world_name = LaunchConfiguration("world_name").perform(context)
x = LaunchConfiguration("x").perform(context)
y = LaunchConfiguration("y").perform(context)
z = LaunchConfiguration("z").perform(context)
roll = LaunchConfiguration("roll").perform(context)
pitch = LaunchConfiguration("pitch").perform(context)
yaw = LaunchConfiguration("yaw").perform(context)
use_ned_frame = LaunchConfiguration("use_ned_frame").perform(context)
paused = LaunchConfiguration("paused")
gui = LaunchConfiguration("gui")
use_sim_time = LaunchConfiguration("use_sim_time")
debug = LaunchConfiguration("debug")
headless = LaunchConfiguration("headless")
verbose = LaunchConfiguration("verbose")
namespace = LaunchConfiguration("namespace")
world_name = LaunchConfiguration("world_name")
x = LaunchConfiguration("x")
y = LaunchConfiguration("y")
z = LaunchConfiguration("z")
roll = LaunchConfiguration("roll")
pitch = LaunchConfiguration("pitch")
yaw = LaunchConfiguration("yaw")
use_ned_frame = LaunchConfiguration("use_ned_frame")

if world_name != "empty.sdf":
if world_name.perform(context) != "empty.sdf":
world_name = LaunchConfiguration("world_name").perform(context)
world_filename = f"{world_name}.world"
world_filepath = PathJoinSubstitution(
[FindPackageShare("dave_worlds"), "worlds", world_filename]
).perform(context)
)
gz_args = [world_filepath]
else:
gz_args = [world_name]

if headless == "true":
gz_args.append("-s")
if paused == "false":
gz_args.append("-r")
if verbose == "true":
gz_args.append("--verbose")

gz_args_str = " ".join(gz_args)
if headless.perform(context) == "true":
gz_args.append(" -s")
if paused.perform(context) == "false":
gz_args.append(" -r")
if debug.perform(context) == "true":
gz_args.append(" -v ")
gz_args.append(verbose.perform(context))

gz_sim_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
Expand All @@ -53,7 +54,7 @@ def launch_setup(context, *args, **kwargs):
]
),
launch_arguments=[
("gz_args", TextSubstitution(text=gz_args_str)),
("gz_args", gz_args),
],
condition=IfCondition(gui),
)
Expand Down Expand Up @@ -105,15 +106,20 @@ def generate_launch_description():
default_value="true",
description="Flag to indicate whether to use simulation time",
),
DeclareLaunchArgument(
"debug",
default_value="false",
description="Flag to enable the gazebo debug flag",
),
DeclareLaunchArgument(
"headless",
default_value="false",
description="Flag to enable the gazebo headless mode",
),
DeclareLaunchArgument(
"verbose",
default_value="false",
description="Enable verbose mode for Gazebo simulation",
default_value="0",
description="Adjust level of console verbosity",
),
DeclareLaunchArgument(
"world_name",
Expand Down
11 changes: 0 additions & 11 deletions examples/dave_robot_launch/CMakeLists.txt

This file was deleted.

31 changes: 0 additions & 31 deletions examples/dave_robot_launch/README.md

This file was deleted.

12 changes: 0 additions & 12 deletions examples/dave_robot_launch/package.xml

This file was deleted.

Loading

0 comments on commit 92fa2b4

Please sign in to comment.