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

Gazebo Classic Simulation humble #78

Merged
merged 18 commits into from Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -22,6 +22,6 @@ jobs:
- uses: ros-tooling/action-ros-ci@v0.3
id: action_ros_ci_step
with:
package-name: andino_base andino_control andino_description andino_slam
package-name: andino_base andino_control andino_description andino_slam andino_gazebo
target-ros2-distro: ${{ env.ROS_DISTRO }}
import-token: ${{ secrets.GITHUB_TOKEN }}
Expand Up @@ -57,7 +57,7 @@
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<mesh filename="package://${package_name}/meshes/sensors/${mesh}" />
<mesh filename="package://andino_description/meshes/sensors/${mesh}" />
francocipollone marked this conversation as resolved.
Show resolved Hide resolved
</geometry>
<material name="blue"/>
</visual>
Expand Down
9 changes: 9 additions & 0 deletions andino_gazebo/CHANGELOG.rst
@@ -0,0 +1,9 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package andino_gazebo
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


0.0.1 (2023-06-29)
------------------
* First andino release
* Contributors: olmerg
32 changes: 32 additions & 0 deletions andino_gazebo/CMakeLists.txt
@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.8)

project(andino_gazebo)

# Skip if Gazebo not present
find_package(gazebo QUIET)
if(NOT gazebo_FOUND)
message(WARNING "Gazebo not found, proceeding without that simulator.")
return()
endif()

find_package(ament_cmake REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

install(
DIRECTORY
launch
rviz
urdf
DESTINATION
share/${PROJECT_NAME}/
)


ament_package()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing empty line in the end of the file

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think it is resolved
image

29 changes: 29 additions & 0 deletions andino_gazebo/LICENSE
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2023, 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.
80 changes: 80 additions & 0 deletions andino_gazebo/README.MD
@@ -0,0 +1,80 @@

# Gazebo Classic simulation for the Andino robot

## Build

Install package dependencies:

```
rosdep install --from-paths src -i -y
```

Build the package:

```
colcon build
```

Note: `--symlink-install` can be added if needed.

Finally, source the install folder
```
. install/setup.bash
```

Note: `gazebo` might be needed to be sourced as well

```
. /usr/share/gazebo/setup.bash
```

# Usage

This package has the next option to be executed.

## Andino simulation with Gazebo diff drive plugin


```
ros2 launch andino_gazebo andino_one_robot.launch.py initial_pose_x:=3.0
```

This launch file supports the following launch arguments:

- `use_sim_time` . This parameter indicate to the rviz that it should work with simulation time. (default: 'true')
- `rviz` . This parameter let to decide if you want to run rviz with this launch. False can be useful if you want to view the rviz in another computer. (default: 'true')
- `world` . SDF file of the world where andino will run. Note that the world should be available in gazebo paths.(default: 'empty_world.world')

Finally, all the parameters of spawn an andino robot to put the robot in specific position are available. for more information of all the parameters of the child launch files you can write:

```
ros2 launch andino_gazebo andino_one_robot.launch.py -s
```

## Spawn an Andino robot

```
ros2 launch andino_gazebo spawn_robot.launch.py initial_pose_x:=3.0 entity:=andino robot_description_topic:=/andino/robot_description
```

The parameters of this launch let to put the robot in any place of the simulation.

- `use_sim_time`: Use simulation (Gazebo) clock if true. (default: 'true')

- `initial_pose_x`: Initial x pose of andino in the simulation. (default: '0.0')

- `initial_pose_y`: Initial y pose of andino in the simulation. (default: '0.0')

- `initial_pose_z`: Initial z pose of andino in the simulation. (default: '0.0')

- `robot_description_topic`: robot description topic. (default: '/robot_description')

- `initial_pose_yaw`: Initial yaw pose of andino in the simulation. (default: '0.0')

- `use_gazebo_ros_control`: True to use the gazebo_ros_control plugin. (default: 'false')

- `entity`: Name of the robot. (default: 'andino')

- `rsp_frequency`: robot state publisher frequency. (default: '30.0')

Spawn multiple andino robots has some issues, so no namespace is created.
99 changes: 99 additions & 0 deletions andino_gazebo/launch/andino_one_robot.launch.py
@@ -0,0 +1,99 @@
# Licensed under the 3-Clause BSD License
#
# Copyright (c) 2023, 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.

"""Launch Gazebo with a world that has Andino."""

import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription, TimerAction
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description():
# Arguments
use_sim_time = LaunchConfiguration('use_sim_time')
use_rviz = LaunchConfiguration('rviz')

pkg_gazebo_ros = get_package_share_directory('gazebo_ros')
pkg_andino_gazebo = get_package_share_directory('andino_gazebo')

use_sim_time_argument = DeclareLaunchArgument(
'use_sim_time',
default_value='true',
description='Use simulation (Gazebo) clock if true',
)
world_argument = DeclareLaunchArgument(
'world', default_value=['empty_world.world'], description='SDF world file'
)
use_rviz_argument = DeclareLaunchArgument(
'rviz', default_value='true', description='Open RViz.'
)

# Include andino
include_andino = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_andino_gazebo, 'launch', 'spawn_robot.launch.py')
),
launch_arguments={'use_gazebo_ros_control': 'false'}.items(),
)
# Gazebo launch
gazebo = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_gazebo_ros, 'launch', 'gazebo.launch.py')
)
olmerg marked this conversation as resolved.
Show resolved Hide resolved
)

# RViz
rviz = Node(
package='rviz2',
executable='rviz2',
parameters=[{'use_sim_time': use_sim_time}],
arguments=['-d', os.path.join(pkg_andino_gazebo, 'rviz', 'andino_gazebo.rviz')],
)

andino_visualization_timer = TimerAction(
period=5.0, actions=[rviz], condition=IfCondition(use_rviz)
)
return LaunchDescription(
[
use_sim_time_argument,
world_argument,
use_rviz_argument,
gazebo,
include_andino,
andino_visualization_timer,
]
)