Skip to content

Commit

Permalink
Review applied. Iron support. Cleaned unnecessary files
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Jaroszek <[email protected]>
  • Loading branch information
pijaro committed Aug 9, 2023
1 parent 7bb118f commit 745adc0
Show file tree
Hide file tree
Showing 14 changed files with 1,988 additions and 147 deletions.
40 changes: 40 additions & 0 deletions Templates/Ros2FleetRobotTemplate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ If your simulation does not match this and you would like to start with a simple
Please follow the instructions in [ROS 2 Gem documentation](https://development--o3deorg.netlify.app/docs/user-guide/interactivity/robotics/project-configuration/)
to install all required dependencies and create your project with a template (make sure to use chose this template during the process).

## Spawning robots

The level contains spawn points configured to easily add more Proteus robots through ROS 2 calls.

This is done with the [Spawner Component](https://development--o3deorg.netlify.app/docs/user-guide/interactivity/robotics/concepts-and-components-overview/#spawner).
There are 4 spawn points already added in the level. You can use them all with the following service calls:

```shell
ros2 service call /spawn_entity gazebo_msgs/srv/SpawnEntity '{name: 'proteus', xml: 'spawnPoint1'}'& \
ros2 service call /spawn_entity gazebo_msgs/srv/SpawnEntity '{name: 'proteus', xml: 'spawnPoint2'}'& \
ros2 service call /spawn_entity gazebo_msgs/srv/SpawnEntity '{name: 'proteus', xml: 'spawnPoint3'}'& \
ros2 service call /spawn_entity gazebo_msgs/srv/SpawnEntity '{name: 'proteus', xml: 'spawnPoint4'}'
```

## Fleet navigation

This template comes with the example fleet navigation ROS 2 package called `o3de_fleet_nav`. You can find a prepared ROS 2 workspace in the `Examples` directory.
Expand All @@ -23,6 +37,8 @@ This package contains a modified code from `nav2_bringup` package (https://githu

In this example, a fleet of robots is automatically spawned and each individual robot can be controlled via the Rviz2. An AMCL localization is used for robot localization.

> Notice: Before running an automated fleet example, please make sure your level doesn't contain any robots in it (they will be spawned).
### Fleet configuration

You can configure the fleet by modifying `Example/ros2_ws/src/o3de_fleet_nav/config/fleet_config.yaml` file:
Expand Down Expand Up @@ -60,6 +76,14 @@ You can modify contents of this file to add/remove robots or change their initia

> Notice: You have to rebuild the ROS 2 workspace for changes to update.
### Navigation configuration

You can configure navigation parameters by modifying `Example/ros2_ws/src/o3de_fleet_nav/params/<ROS_DISTRO>/nav2_*.yaml` files.

Please visit the [nav2 configuration guide](https://navigation.ros.org/configuration/index.html) for a detailed description of the navigation parameters.

> Notice: You have to rebuild the ROS 2 workspace for changes to update.
### Topics and frames

Every spawned robot will have its own namespace for all topics. For the first robot ('robot1' namespace), these will be:
Expand All @@ -75,6 +99,22 @@ The first spawned robot also provides the following transformations:

To understand more about transformations, see ROS 2 navigation [documentation](https://navigation.ros.org/setup_guides/transformation/setup_transforms.html).

## Using your robots in the simulation

You can also use your robots in the simulation. To do so, you need to:
- [import robot](https://docs.o3de.org/docs/user-guide/interactivity/robotics/importing-robot/) from existing URDF file,
- or create a robot from scratch in a O3DE editor using ROS 2 gem components (see [Frames](https://docs.o3de.org/docs/user-guide/interactivity/robotics/concepts-and-components-overview/#frames)),
- make sure that your robot has a 2D scanner attached
- and publishes scans on `scan` topic (see [Sensors](https://docs.o3de.org/docs/user-guide/interactivity/robotics/concepts-and-components-overview/#robot-control)),
- is controlled via the `cmd_vel` topic (see [Robot Control](https://docs.o3de.org/docs/user-guide/interactivity/robotics/concepts-and-components-overview/#robot-control)).

When you have your robot set up:
- create a prefab out of it (skip if URDF importer did that for you),
- load the `Warehouse` level,
- assign the prefab to the `RobotSpawner` entity inside `ROS2 Spawner Component` with a preferred name.

Then you can alter `fleet_config.yaml` file to change the robot name to the assigned one, and start the fleet simulation with your robot!

### Building

- Source ROS 2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def generate_launch_description():
o3de_fleet_nav_dir = get_package_share_directory('o3de_fleet_nav')
o3de_fleet_nav_launch_dir = os.path.join(o3de_fleet_nav_dir, 'launch')

distro = os.getenv('ROS_DISTRO')

# Create the launch configuration variables
namespace = LaunchConfiguration('namespace')
use_namespace = LaunchConfiguration('use_namespace')
Expand Down Expand Up @@ -78,7 +80,7 @@ def generate_launch_description():

declare_params_file_cmd = DeclareLaunchArgument(
'params_file',
default_value=os.path.join(o3de_fleet_nav_dir, 'params', 'nav2_multirobot_params.yaml'),
default_value=os.path.join(o3de_fleet_nav_dir, 'params', distro, 'nav2_multirobot_params.yaml'),
description='Full path to the ROS2 parameters file to use for all launched nodes')

declare_autostart_cmd = DeclareLaunchArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def generate_launch_description():
use_rviz = LaunchConfiguration('use_rviz')
log_settings = LaunchConfiguration('log_settings', default='true')

distro = os.getenv('ROS_DISTRO')

# Declare the launch arguments
declare_map_yaml_cmd = DeclareLaunchArgument(
'map',
Expand All @@ -64,7 +66,7 @@ def generate_launch_description():

declare_robot_params_file_cmd = DeclareLaunchArgument(
'robot_params_file',
default_value=os.path.join(o3de_fleet_nav_dir, 'params', 'nav2_multirobot_params.yaml'),
default_value=os.path.join(o3de_fleet_nav_dir, 'params', distro, 'nav2_multirobot_params.yaml'),
description='Full path to the ROS2 parameters file to use for all robot launched nodes')

declare_autostart_cmd = DeclareLaunchArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def generate_launch_description():
use_respawn = LaunchConfiguration('use_respawn')
log_level = LaunchConfiguration('log_level')

distro = os.getenv('ROS_DISTRO')

lifecycle_nodes = ['map_server', 'amcl']

# Create our own temporary YAML files that include substitutions
Expand Down Expand Up @@ -74,7 +76,7 @@ def generate_launch_description():

declare_params_file_cmd = DeclareLaunchArgument(
'params_file',
default_value=os.path.join(o3de_fleet_nav_dir, 'params', 'nav2_multirobot_params.yaml'),
default_value=os.path.join(o3de_fleet_nav_dir, 'params', distro, 'nav2_multirobot_params.yaml'),
description='Full path to the ROS2 parameters file to use for all launched nodes')

declare_autostart_cmd = DeclareLaunchArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


Expand All @@ -40,6 +40,8 @@ def generate_launch_description():
use_composition = LaunchConfiguration('use_composition')
use_respawn = LaunchConfiguration('use_respawn')

distro = os.getenv('ROS_DISTRO')

# Launch configuration variables specific to simulation
rviz_config_file = LaunchConfiguration('rviz_config_file')
use_rviz = LaunchConfiguration('use_rviz')
Expand Down Expand Up @@ -68,7 +70,7 @@ def generate_launch_description():

declare_params_file_cmd = DeclareLaunchArgument(
'params_file',
default_value=os.path.join(o3de_fleet_nav_dir, 'params', 'nav2_params.yaml'),
default_value=os.path.join(o3de_fleet_nav_dir, 'params', distro, 'nav2_params.yaml'),
description='Full path to the ROS2 parameters file to use for all launched nodes')

declare_autostart_cmd = DeclareLaunchArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def generate_launch_description():
use_respawn = LaunchConfiguration('use_respawn')
log_level = LaunchConfiguration('log_level')

distro = os.getenv('ROS_DISTRO')

lifecycle_nodes = ['controller_server',
'smoother_server',
'planner_server',
Expand Down Expand Up @@ -75,7 +77,7 @@ def generate_launch_description():

declare_params_file_cmd = DeclareLaunchArgument(
'params_file',
default_value=os.path.join(o3de_fleet_nav_dir, 'params', 'nav2_multirobot_params.yaml'),
default_value=os.path.join(o3de_fleet_nav_dir, 'params', distro, 'nav2_multirobot_params.yaml'),
description='Full path to the ROS2 parameters file to use for all launched nodes')

declare_autostart_cmd = DeclareLaunchArgument(
Expand Down

This file was deleted.

Loading

0 comments on commit 745adc0

Please sign in to comment.