Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds example using slam_toolbox. #48

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ source install/setup.bash

## :rocket: Usage

### Andino simulation

Once the package is built and sourced, you can start a simulation.

```sh
Expand All @@ -68,6 +70,29 @@ If you'd like to work from ROS you can launch the ros bridge by adding the corre
Make sure to review the required topics using `ign topics` and `ros2 topic` CLI tools.
Also, consider using looking at the translation entries under `andino_gz/config/bridge_config.yaml`.

### SLAM

<img src="./docs/media/andino_slam.png" width="800"/>

1. Run simulation with ros bridge and RViz.

```sh
ros2 launch andino_gz andino_gz.launch.py ros_bridge:=true rviz:=true
```

2. Run slam toolbox
```
ros2 launch andino_gz slam_toolbox_online_async.launch.py
```

Configuration can be forwarded to the `slam_toolbox_node`. By default, the configuration parameters are obtained from [andino's configuration file](https://github.com/Ekumen-OS/andino/blob/humble/andino_slam/config/slam_toolbox_online_async.yaml). In case a custom file is wanted to be passed, simply use the launch file argument for indicating the path to a new file.

```
ros2 launch andino_gz slam_toolbox_online_async.launch.py slams_param_file:=<my_path>
```

3. Visualize in RViz: Add `map` panel to RViz and see how the map is being generated.

### Spawn multiple Andinos

Launch simulation as before:
Expand All @@ -82,6 +107,8 @@ For spawning more Andinos you can use the `spawn_robot` launch file. Make sure a
ros2 launch andino_gz spawn_robot.launch.py entity:=andino_n initial_pose_x:=1 initial_pose_y:=1
```

_Note: Andino is spawned but no bridge to ROS2 bridge are spawned for those robots._

## :raised_hands: Contributing

Issues or PRs are always welcome! Please refer to [CONTRIBUTING](CONTRIBUTING.md) doc.
Expand Down
66 changes: 66 additions & 0 deletions andino_gz/launch/slam_toolbox_online_async.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# BSD 3-Clause License

# Copyright (c) 2024, Ekumen Inc.
# All rights reserved.

# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.

# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import os

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():
slam_params_file = LaunchConfiguration('slam_params_file')

declare_slam_params_file_cmd = DeclareLaunchArgument(
'slam_params_file',
default_value=os.path.join(get_package_share_directory("andino_slam"),
'config', 'slam_toolbox_online_async.yaml'),
description='Full path to the ROS 2 parameters file to use for the slam_toolbox node')

start_async_slam_toolbox_node = Node(
parameters=[
slam_params_file,
{
'use_sim_time': True
}
],
package='slam_toolbox',
executable='async_slam_toolbox_node',
name='slam_toolbox',
output='screen')

ld = LaunchDescription()

ld.add_action(declare_slam_params_file_cmd)
ld.add_action(start_async_slam_toolbox_node)

return ld
1 change: 1 addition & 0 deletions andino_gz/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<exec_depend>andino_description</exec_depend>
<exec_depend>andino_slam</exec_depend>

<exec_depend>ignition-gazebo6</exec_depend>
<exec_depend>ros_gz_bridge</exec_depend>
Expand Down
Binary file added docs/media/andino_slam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading