Skip to content

Commit 997c402

Browse files
authored
Merge pull request #17 from IOES-Lab/camera
[GSOC-98] Underwater Camera Plugin
2 parents 98d4849 + 0def1a9 commit 997c402

29 files changed

+1325
-267
lines changed

examples/dave_demos/README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Examples
1+
# Examples
22

3-
### 1. Launching a Dave Object Model using Fuel URI
3+
## Launching a Dave Object Model using Fuel URI
44

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

@@ -18,7 +18,7 @@ To launch a Dave model directly from a Fuel URI, follow these steps:
1818

1919
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.
2020

21-
### 2. Launching a Dave Sensor Model using Downloaded Model Files
21+
## Launching a Dave Sensor Model using Downloaded Model Files
2222

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

@@ -52,7 +52,39 @@ If you prefer to use model files downloaded from Fuel, proceed as follows:
5252

5353
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.
5454

55-
### 3. Launching a World File
55+
## Launching a Dave Robot Model
56+
57+
Before launching, ensure to build and source the workspace:
58+
59+
```bash
60+
colcon build && source install/setup.bash
61+
```
62+
63+
1. Launching REXROV in an empty world:
64+
65+
```bash
66+
ros2 launch dave_demos dave_robot.launch.py z:=2.0 namespace:=rexrov world_name:=empty.sdf paused:=false
67+
```
68+
69+
2. Launching REXROV in dave_ocean_waves.world:
70+
71+
```bash
72+
ros2 launch dave_demos dave_robot.launch.py z:=-5 namespace:=rexrov world_name:=dave_ocean_waves paused:=false
73+
```
74+
75+
3. Launching Slocum Glider in an empty world:
76+
77+
```bash
78+
ros2 launch dave_demos dave_robot.launch.py z:=0.2 namespace:=glider_slocum world_name:=empty.sdf paused:=false
79+
```
80+
81+
4. Launching Slocum Glider in dave_ocean_waves.world:
82+
83+
```bash
84+
ros2 launch dave_demos dave_robot.launch.py x:=4 z:=-1.5 namespace:=glider_slocum world_name:=dave_ocean_waves paused:=false
85+
```
86+
87+
## Launching a World File
5688

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

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

65-
1. Launch the world using the specified launch file
97+
2. Launch the world using the specified launch file
6698

6799
```bash
68100
ros2 launch dave_demos dave_world.launch.py world_name:='dave_ocean_waves'
69101
```
70102

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

73-
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.
105+
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.
74106

75107
In this setup, you can dynamically specify different world files by changing the `world_name` argument in the launch command.

examples/dave_demos/launch/dave_object.launch.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
11
from launch import LaunchDescription
22
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction
3-
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, TextSubstitution
3+
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
44
from launch.launch_description_sources import PythonLaunchDescriptionSource
55
from launch.conditions import IfCondition
66
from launch_ros.substitutions import FindPackageShare
77

88

99
def launch_setup(context, *args, **kwargs):
10-
paused = LaunchConfiguration("paused").perform(context)
11-
gui = LaunchConfiguration("gui").perform(context)
12-
use_sim_time = LaunchConfiguration("use_sim_time").perform(context)
13-
headless = LaunchConfiguration("headless").perform(context)
14-
verbose = LaunchConfiguration("verbose").perform(context)
15-
namespace = LaunchConfiguration("namespace").perform(context)
16-
world_name = LaunchConfiguration("world_name").perform(context)
17-
x = LaunchConfiguration("x").perform(context)
18-
y = LaunchConfiguration("y").perform(context)
19-
z = LaunchConfiguration("z").perform(context)
20-
roll = LaunchConfiguration("roll").perform(context)
21-
pitch = LaunchConfiguration("pitch").perform(context)
22-
yaw = LaunchConfiguration("yaw").perform(context)
23-
use_ned_frame = LaunchConfiguration("use_ned_frame").perform(context)
10+
paused = LaunchConfiguration("paused")
11+
gui = LaunchConfiguration("gui")
12+
use_sim_time = LaunchConfiguration("use_sim_time")
13+
debug = LaunchConfiguration("debug")
14+
headless = LaunchConfiguration("headless")
15+
verbose = LaunchConfiguration("verbose")
16+
namespace = LaunchConfiguration("namespace")
17+
world_name = LaunchConfiguration("world_name")
18+
x = LaunchConfiguration("x")
19+
y = LaunchConfiguration("y")
20+
z = LaunchConfiguration("z")
21+
roll = LaunchConfiguration("roll")
22+
pitch = LaunchConfiguration("pitch")
23+
yaw = LaunchConfiguration("yaw")
24+
use_ned_frame = LaunchConfiguration("use_ned_frame")
2425

25-
if world_name != "empty.sdf":
26+
if world_name.perform(context) != "empty.sdf":
27+
world_name = LaunchConfiguration("world_name").perform(context)
2628
world_filename = f"{world_name}.world"
2729
world_filepath = PathJoinSubstitution(
2830
[FindPackageShare("dave_worlds"), "worlds", world_filename]
29-
).perform(context)
31+
)
3032
gz_args = [world_filepath]
3133
else:
3234
gz_args = [world_name]
3335

34-
if headless == "true":
35-
gz_args.append("-s")
36-
if paused == "false":
37-
gz_args.append("-r")
38-
if verbose == "true":
39-
gz_args.append("--verbose")
40-
41-
gz_args_str = " ".join(gz_args)
36+
if headless.perform(context) == "true":
37+
gz_args.append(" -s")
38+
if paused.perform(context) == "false":
39+
gz_args.append(" -r")
40+
if debug.perform(context) == "true":
41+
gz_args.append(" -v ")
42+
gz_args.append(verbose.perform(context))
4243

4344
gz_sim_launch = IncludeLaunchDescription(
4445
PythonLaunchDescriptionSource(
@@ -53,7 +54,7 @@ def launch_setup(context, *args, **kwargs):
5354
]
5455
),
5556
launch_arguments=[
56-
("gz_args", TextSubstitution(text=gz_args_str)),
57+
("gz_args", gz_args),
5758
],
5859
condition=IfCondition(gui),
5960
)
@@ -105,15 +106,20 @@ def generate_launch_description():
105106
default_value="true",
106107
description="Flag to indicate whether to use simulation time",
107108
),
109+
DeclareLaunchArgument(
110+
"debug",
111+
default_value="false",
112+
description="Flag to enable the gazebo debug flag",
113+
),
108114
DeclareLaunchArgument(
109115
"headless",
110116
default_value="false",
111117
description="Flag to enable the gazebo headless mode",
112118
),
113119
DeclareLaunchArgument(
114120
"verbose",
115-
default_value="false",
116-
description="Enable verbose mode for Gazebo simulation",
121+
default_value="0",
122+
description="Adjust level of console verbosity",
117123
),
118124
DeclareLaunchArgument(
119125
"world_name",

examples/dave_demos/launch/dave_sensor.launch.py

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
11
from launch import LaunchDescription
22
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction
3-
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, TextSubstitution
3+
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
44
from launch.launch_description_sources import PythonLaunchDescriptionSource
55
from launch.conditions import IfCondition
66
from launch_ros.substitutions import FindPackageShare
77

88

99
def launch_setup(context, *args, **kwargs):
10-
paused = LaunchConfiguration("paused").perform(context)
11-
gui = LaunchConfiguration("gui").perform(context)
12-
use_sim_time = LaunchConfiguration("use_sim_time").perform(context)
13-
headless = LaunchConfiguration("headless").perform(context)
14-
verbose = LaunchConfiguration("verbose").perform(context)
15-
namespace = LaunchConfiguration("namespace").perform(context)
16-
world_name = LaunchConfiguration("world_name").perform(context)
17-
x = LaunchConfiguration("x").perform(context)
18-
y = LaunchConfiguration("y").perform(context)
19-
z = LaunchConfiguration("z").perform(context)
20-
roll = LaunchConfiguration("roll").perform(context)
21-
pitch = LaunchConfiguration("pitch").perform(context)
22-
yaw = LaunchConfiguration("yaw").perform(context)
23-
use_ned_frame = LaunchConfiguration("use_ned_frame").perform(context)
10+
paused = LaunchConfiguration("paused")
11+
gui = LaunchConfiguration("gui")
12+
use_sim_time = LaunchConfiguration("use_sim_time")
13+
debug = LaunchConfiguration("debug")
14+
headless = LaunchConfiguration("headless")
15+
verbose = LaunchConfiguration("verbose")
16+
namespace = LaunchConfiguration("namespace")
17+
world_name = LaunchConfiguration("world_name")
18+
x = LaunchConfiguration("x")
19+
y = LaunchConfiguration("y")
20+
z = LaunchConfiguration("z")
21+
roll = LaunchConfiguration("roll")
22+
pitch = LaunchConfiguration("pitch")
23+
yaw = LaunchConfiguration("yaw")
24+
use_ned_frame = LaunchConfiguration("use_ned_frame")
2425

25-
if world_name != "empty.sdf":
26+
if world_name.perform(context) != "empty.sdf":
27+
world_name = LaunchConfiguration("world_name").perform(context)
2628
world_filename = f"{world_name}.world"
2729
world_filepath = PathJoinSubstitution(
2830
[FindPackageShare("dave_worlds"), "worlds", world_filename]
29-
).perform(context)
31+
)
3032
gz_args = [world_filepath]
3133
else:
3234
gz_args = [world_name]
3335

34-
if headless == "true":
35-
gz_args.append("-s")
36-
if paused == "false":
37-
gz_args.append("-r")
38-
if verbose == "true":
39-
gz_args.append("--verbose")
40-
41-
gz_args_str = " ".join(gz_args)
36+
if headless.perform(context) == "true":
37+
gz_args.append(" -s")
38+
if paused.perform(context) == "false":
39+
gz_args.append(" -r")
40+
if debug.perform(context) == "true":
41+
gz_args.append(" -v ")
42+
gz_args.append(verbose.perform(context))
4243

4344
gz_sim_launch = IncludeLaunchDescription(
4445
PythonLaunchDescriptionSource(
@@ -53,7 +54,7 @@ def launch_setup(context, *args, **kwargs):
5354
]
5455
),
5556
launch_arguments=[
56-
("gz_args", TextSubstitution(text=gz_args_str)),
57+
("gz_args", gz_args),
5758
],
5859
condition=IfCondition(gui),
5960
)
@@ -105,15 +106,20 @@ def generate_launch_description():
105106
default_value="true",
106107
description="Flag to indicate whether to use simulation time",
107108
),
109+
DeclareLaunchArgument(
110+
"debug",
111+
default_value="false",
112+
description="Flag to enable the gazebo debug flag",
113+
),
108114
DeclareLaunchArgument(
109115
"headless",
110116
default_value="false",
111117
description="Flag to enable the gazebo headless mode",
112118
),
113119
DeclareLaunchArgument(
114120
"verbose",
115-
default_value="false",
116-
description="Enable verbose mode for Gazebo simulation",
121+
default_value="0",
122+
description="Adjust level of console verbosity",
117123
),
118124
DeclareLaunchArgument(
119125
"world_name",

examples/dave_robot_launch/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/dave_robot_launch/README.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/dave_robot_launch/package.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

gazebo/dave_gz_sensor_plugins/CMakeLists.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,27 @@ find_package(dave_interfaces REQUIRED)
1414
find_package(sensor_msgs REQUIRED)
1515
find_package(Protobuf REQUIRED)
1616
find_package(gz-msgs10 REQUIRED)
17+
find_package(OpenCV REQUIRED)
1718

1819
# Set version variables
1920
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR})
2021
set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR})
2122
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR})
2223
set(GZ_MSGS_VER ${gz-msgs10_VERSION_MAJOR})
2324

25+
include_directories(${OpenCV_INCLUDE_DIRS})
26+
2427
message(STATUS "Compiling against Gazebo Harmonic")
2528

2629
add_library(UsblTransceiver SHARED src/UsblTransceiver.cc)
2730
add_library(UsblTransponder SHARED src/UsblTransponder.cc)
2831
add_library(sea_pressure_sensor SHARED src/sea_pressure_sensor.cc)
32+
add_library(UnderwaterCamera SHARED src/UnderwaterCamera.cc)
2933

3034
target_include_directories(UsblTransceiver PRIVATE include)
3135
target_include_directories(UsblTransponder PRIVATE include)
3236
target_include_directories(sea_pressure_sensor PRIVATE include)
37+
target_include_directories(UnderwaterCamera PRIVATE include)
3338

3439
target_link_libraries(UsblTransceiver
3540
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
@@ -43,6 +48,11 @@ target_link_libraries(sea_pressure_sensor
4348
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
4449
)
4550

51+
target_link_libraries(UnderwaterCamera
52+
gz-sim${GZ_SIM_VER}::gz-sim${GZ_SIM_VER}
53+
${OpenCV_LIBS}
54+
)
55+
4656
# Specify dependencies for FullSystem using ament_target_dependencies
4757
ament_target_dependencies(UsblTransceiver
4858
dave_interfaces
@@ -65,8 +75,13 @@ ament_target_dependencies(sea_pressure_sensor
6575
geometry_msgs
6676
)
6777

78+
ament_target_dependencies(UnderwaterCamera
79+
rclcpp
80+
sensor_msgs
81+
)
82+
6883
# Install targets
69-
install(TARGETS UsblTransceiver UsblTransponder sea_pressure_sensor
84+
install(TARGETS UsblTransceiver UsblTransponder sea_pressure_sensor UnderwaterCamera
7085
DESTINATION lib/${PROJECT_NAME}
7186
)
7287

0 commit comments

Comments
 (0)