forked from Field-Robotics-Lab/dave
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from IOES-Lab/robot-models
- Loading branch information
Showing
14 changed files
with
3,177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(dave_robot_launch) | ||
|
||
find_package(ament_cmake REQUIRED) | ||
|
||
install( | ||
DIRECTORY launch | ||
DESTINATION share/dave_robot_launch | ||
) | ||
|
||
ament_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
## Examples | ||
|
||
### 1. Launching REXROV in an empty world | ||
|
||
To launch the rexrov model in an empty world, follow these steps: | ||
|
||
1. Build and source the workspace: | ||
|
||
```bash | ||
colcon build && source install/setup.bash | ||
``` | ||
|
||
2. Launch the model using the specified launch file: | ||
|
||
```bash | ||
ros2 launch dave_robot_launch robot_in_world.launch.py z:=2.0 namespace:=rexrov world_name:=empty.sdf paused:=false | ||
``` | ||
|
||
### 2. Launching REXROV in dave_ocean_waves.world | ||
|
||
To launch the rexrov model in an underwater world, follow these steps: | ||
|
||
1. Build and source the workspace: | ||
|
||
```bash | ||
colcon build && source install/setup.bash | ||
``` | ||
|
||
2. Launch the model using the specified launch file: | ||
|
||
```bash | ||
ros2 launch dave_robot_launch robot_in_world.launch.py z:=-5 namespace:=rexrov world_name:=dave_ocean_waves paused:=false | ||
``` |
176 changes: 176 additions & 0 deletions
176
examples/dave_robot_launch/launch/robot_in_world.launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
from launch import LaunchDescription | ||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction | ||
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") | ||
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.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] | ||
) | ||
gz_args = [world_filepath] | ||
else: | ||
gz_args = [world_name] | ||
|
||
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)) | ||
|
||
# Include the first launch file | ||
gz_sim_launch = IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource( | ||
[ | ||
PathJoinSubstitution( | ||
[ | ||
FindPackageShare("ros_gz_sim"), | ||
"launch", | ||
"gz_sim.launch.py", | ||
] | ||
) | ||
] | ||
), | ||
launch_arguments=[ | ||
("gz_args", gz_args), | ||
], | ||
condition=IfCondition(gui), | ||
) | ||
|
||
# Include the second launch file with model name | ||
robot_launch = IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource( | ||
[ | ||
PathJoinSubstitution( | ||
[ | ||
FindPackageShare("dave_robot_models"), | ||
"launch", | ||
"upload_robot.launch.py", | ||
] | ||
) | ||
] | ||
), | ||
launch_arguments={ | ||
"gui": gui, | ||
"use_sim_time": use_sim_time, | ||
"namespace": namespace, | ||
"x": x, | ||
"y": y, | ||
"z": z, | ||
"roll": roll, | ||
"pitch": pitch, | ||
"yaw": yaw, | ||
"use_ned_frame": use_ned_frame, | ||
}.items(), | ||
) | ||
|
||
include = [gz_sim_launch, robot_launch] | ||
|
||
return include | ||
|
||
|
||
def generate_launch_description(): | ||
|
||
# Declare the launch arguments with default values | ||
args = [ | ||
DeclareLaunchArgument( | ||
"paused", | ||
default_value="true", | ||
description="Start the simulation paused", | ||
), | ||
DeclareLaunchArgument( | ||
"gui", | ||
default_value="true", | ||
description="Flag to enable the gazebo gui", | ||
), | ||
DeclareLaunchArgument( | ||
"use_sim_time", | ||
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="0", | ||
description="Adjust level of console verbosity", | ||
), | ||
DeclareLaunchArgument( | ||
"world_name", | ||
default_value="empty.sdf", | ||
description="Gazebo world file to launch", | ||
), | ||
DeclareLaunchArgument( | ||
"namespace", | ||
default_value="", | ||
description="Namespace", | ||
), | ||
DeclareLaunchArgument( | ||
"x", | ||
default_value="0.0", | ||
description="Initial x position", | ||
), | ||
DeclareLaunchArgument( | ||
"y", | ||
default_value="0.0", | ||
description="Initial y position", | ||
), | ||
DeclareLaunchArgument( | ||
"z", | ||
default_value="0.0", | ||
description="Initial z position", | ||
), | ||
DeclareLaunchArgument( | ||
"roll", | ||
default_value="0.0", | ||
description="Initial roll angle", | ||
), | ||
DeclareLaunchArgument( | ||
"pitch", | ||
default_value="0.0", | ||
description="Initial pitch angle", | ||
), | ||
DeclareLaunchArgument( | ||
"yaw", | ||
default_value="0.0", | ||
description="Initial yaw angle", | ||
), | ||
DeclareLaunchArgument( | ||
"use_ned_frame", | ||
default_value="false", | ||
description="Flag to indicate whether to use the north-east-down frame", | ||
), | ||
] | ||
|
||
return LaunchDescription(args + [OpaqueFunction(function=launch_setup)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?><package format="3"> | ||
<name>dave_robot_launch</name> | ||
<version>0.1.0</version> | ||
<description>A package that shows a demo to launch robot models.</description> | ||
<maintainer email="[email protected]">Rakesh Vivekanandan</maintainer> | ||
<license>MIT</license> | ||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(dave_robot_models) | ||
|
||
find_package(ament_cmake REQUIRED) | ||
|
||
install( | ||
DIRECTORY description launch meshes | ||
DESTINATION share/dave_robot_models | ||
) | ||
|
||
ament_environment_hooks( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in") | ||
|
||
ament_package() |
Oops, something went wrong.