Skip to content

Commit

Permalink
Merge pull request #5 from IOES-Lab/robot-models
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshv24 authored Jun 28, 2024
2 parents 7c8baba + 045f11f commit a5bf461
Show file tree
Hide file tree
Showing 14 changed files with 3,177 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/dave_robot_launch/CMakeLists.txt
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()
33 changes: 33 additions & 0 deletions examples/dave_robot_launch/README.md
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 examples/dave_robot_launch/launch/robot_in_world.launch.py
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)])
12 changes: 12 additions & 0 deletions examples/dave_robot_launch/package.xml
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>
14 changes: 14 additions & 0 deletions models/dave_robot_models/CMakeLists.txt
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()
Loading

0 comments on commit a5bf461

Please sign in to comment.