Skip to content

Commit

Permalink
Use Gazebo ROS vendor packages (#277)
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey authored May 7, 2024
1 parent 0b9be5c commit 18fd2c7
Show file tree
Hide file tree
Showing 23 changed files with 94 additions and 322 deletions.
97 changes: 0 additions & 97 deletions .github/workflows/ci-iron.yaml

This file was deleted.

38 changes: 3 additions & 35 deletions .github/workflows/ci-rolling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,12 @@ jobs:
fail-fast: false
matrix:
include:
- docker-image: "ubuntu:22.04"
gz-version: "fortress"
ros-distro: "rolling"
ros-repo-packages: ""
- docker-image: "ubuntu:22.04"
gz-version: "garden"
ros-distro: "rolling"
ros-repo-packages: ""
- docker-image: "ubuntu:22.04"
gz-version: "fortress"
ros-distro: "rolling"
ros-repo-packages: "-testing"
- docker-image: "ubuntu:22.04"
gz-version: "garden"
- docker-image: "ubuntu:24.04"
ros-distro: "rolling"
ros-repo-packages: "-testing"

env:
DOCKER_IMAGE: ${{ matrix.docker-image }}
GZ_VERSION: ${{ matrix.gz-version }}
ROS_DISTRO: ${{ matrix.ros-distro }}
ROS_REPO_PACKAGES: ${{ matrix.ros-repo-packages }}
container:
Expand All @@ -48,40 +34,22 @@ jobs:
apt install -qq -y lsb-release wget curl gnupg2 git
cd ..
mkdir -p /home/ros2_ws/src
if [ "$ROS_DISTRO" == "rolling" ]; then
git clone https://github.com/gazebosim/ros_gz/
fi
cp -r gz_ros2_control /home/ros2_ws/src/
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2$ROS_REPO_PACKAGES/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
if [ "$GZ_VERSION" == "garden" ]; then
export GZ_DEPS="libgz-sim7-dev libgz-plugin2-dev gz-sim7-cli"
fi
apt-get update && apt-get upgrade -q -y
apt-get update && apt-get install -qq -y \
dirmngr \
python3-colcon-ros \
python3-colcon-common-extensions \
python3-rosdep \
build-essential \
${GZ_DEPS}
build-essential
if [ "$GZ_VERSION" == "garden" ]; then
export ROSDEP_ARGS="--skip-keys ros_gz_sim --skip-keys gz-plugin2 --skip-keys gz-sim7 --skip-keys gz-transport12 --skip-keys gz-math7 --skip-keys gz-msgs9"
fi
cd /home/ros2_ws/src/
if [ "$ROS_DISTRO" == "rolling" ]; then
git clone https://github.com/gazebosim/ros_gz/
fi
if [ "$ROS_DISTRO" == "iron" ]; then
git clone https://github.com/gazebosim/ros_gz/ -b iron
fi
rosdep init
rosdep update
rosdep install --from-paths ./ -i -y --rosdistro ${ROS_DISTRO} --ignore-src ${ROSDEP_ARGS}
rosdep install --from-paths ./ -i -y --rosdistro ${ROS_DISTRO} --ignore-src
- name: Build project
id: build
run: |
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM ubuntu:22.04
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND noninteractive
ENV GZ_VERSION fortress
ENV ROS_DISTRO rolling

# Make sure everything is up to date before building from source
Expand Down
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ Galactic | Fortress | [galactic](https://github.com/ros-controls/gz_ros2_control
Humble | Fortress | [humble](https://github.com/ros-controls/gz_ros2_control/tree/humble) | https://packages.ros.org
Iron | Edifice | [iron](https://github.com/ros-controls/gz_ros2_control/tree/iron) | only from source
Iron | Fortress | [iron](https://github.com/ros-controls/gz_ros2_control/tree/iron) | https://packages.ros.org
Iron | Garden (not released) | [iron](https://github.com/ros-controls/gz_ros2_control/tree/iron) | only from source
Iron | Harmonic (not released) | [iron](https://github.com/ros-controls/gz_ros2_control/tree/iron) | only from source
Rolling | Edifice | [master](https://github.com/ros-controls/gz_ros2_control/tree/master) | only from source
Rolling | Fortress | [master](https://github.com/ros-controls/gz_ros2_control/tree/master) | https://packages.ros.org
Rolling | Garden (not released) | [master](https://github.com/ros-controls/gz_ros2_control/tree/master) | only from source
Rolling | Harmonic (not released) | [master](https://github.com/ros-controls/gz_ros2_control/tree/master) | only from source
Iron | Garden | [iron](https://github.com/ros-controls/gz_ros2_control/tree/iron) | only from source
Iron | Harmonic | [iron](https://github.com/ros-controls/gz_ros2_control/tree/iron) | only from source
Jazzy | Harmonic | [master](https://github.com/ros-controls/gz_ros2_control/tree/master) | https://packages.ros.org
Rolling | Harmonic | [master](https://github.com/ros-controls/gz_ros2_control/tree/master) | https://packages.ros.org

## Build status

Expand All @@ -37,15 +35,11 @@ See the [documentation file](doc/index.rst) or [control.ros.org](https://control

# Compile from source

If you want compile this from source, you should choose the Gazebo version. The default one is `garden`:
Note that `gz_ros2_control` depends on the version of Gazebo that is
provided by the Gazebo Vendor packages [`gz_plugin_vendor`](https://github.com/gazebo-release/gz_plugin_vendor) and [`gz_sim_vendor`](https://github.com/gazebo-release/gz_sim_vendor).
Currently, for ROS 2 Jazzy and Rolling, the Gazebo version is Harmonic.

```bash
export GZ_VERSION=fortress
export GZ_VERSION=garden
export GZ_VERSION=harmonic
```

Then create a workspace, clone the repo and compile it:
To compile `gz_ros2_control` from source, create a workspace, clone the repo and compile it:

```bash
mkdir -p ~/gz_ros2_control_ws/src
Expand Down
41 changes: 8 additions & 33 deletions gz_ros2_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,11 @@ find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(yaml_cpp_vendor REQUIRED)

set(GZ_PLUGIN)
set(GZ_SIM)

if("$ENV{GZ_VERSION}" STREQUAL "garden")
find_package(gz-sim7 REQUIRED)
set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR})
message(STATUS "Compiling against Gazebo Garden")
find_package(gz-plugin2 REQUIRED)
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR})
set(GZ_PLUGIN gz-plugin${GZ_PLUGIN_VER}::register)
set(GZ_SIM gz-sim${GZ_SIM_VER}::core)
add_definitions(-DGZ_HEADERS)
elseif("$ENV{GZ_VERSION}" STREQUAL "harmonic")
find_package(gz-sim8 REQUIRED)
set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR})
message(STATUS "Compiling against Gazebo Harmonic")
find_package(gz-plugin2 REQUIRED)
set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR})
set(GZ_PLUGIN gz-plugin${GZ_PLUGIN_VER}::register)
set(GZ_SIM gz-sim${GZ_SIM_VER}::core)
add_definitions(-DGZ_HEADERS)
else()
find_package(ignition-gazebo6 REQUIRED)
set(GZ_SIM_VER ${ignition-gazebo6_VERSION_MAJOR})
message(STATUS "Compiling against Gazebo Fortress")
find_package(ignition-plugin1 REQUIRED)
set(GZ_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})
set(GZ_PLUGIN ignition-plugin${GZ_PLUGIN_VER}::register)
set(GZ_SIM ignition-gazebo${GZ_SIM_VER}::core)
endif()
find_package(gz_sim_vendor REQUIRED)
find_package(gz-sim REQUIRED)

find_package(gz_plugin_vendor REQUIRED)
find_package(gz-plugin REQUIRED)

include_directories(include)

Expand All @@ -62,8 +37,8 @@ add_library(${PROJECT_NAME}-system SHARED
)

target_link_libraries(${PROJECT_NAME}-system
${GZ_SIM}
${GZ_PLUGIN}
gz-sim::gz-sim
gz-plugin::register
)
ament_target_dependencies(${PROJECT_NAME}-system
ament_index_cpp
Expand All @@ -86,7 +61,7 @@ ament_target_dependencies(gz_hardware_plugins
rclcpp
)
target_link_libraries(gz_hardware_plugins
${GZ_SIM}
gz-sim::gz-sim
)

## Install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@

#include <memory>

#ifdef GZ_HEADERS
#include <gz/sim/System.hh>
namespace sim = gz::sim;
#else
#include <ignition/gazebo/System.hh>
namespace sim = ignition::gazebo;
#endif

namespace gz_ros2_control
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@
#include <string>
#include <vector>

#ifdef GZ_HEADERS
#include <gz/sim/System.hh>
namespace sim = gz::sim;
#else
#include <ignition/gazebo/System.hh>
namespace sim = ignition::gazebo;
#endif

#include <hardware_interface/system_interface.hpp>
#include <hardware_interface/types/hardware_interface_type_values.hpp>
Expand Down
13 changes: 3 additions & 10 deletions gz_ros2_control/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,9 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<depend>ament_index_cpp</depend>
<!-- default version to use in official ROS2 packages is GAzebo Fortress for ROS2 Rolling -->
<depend condition="$GZ_VERSION == ''">ignition-gazebo6</depend>
<depend condition="$GZ_VERSION == fortress">ignition-gazebo6</depend>
<depend condition="$GZ_VERSION == garden">gz-sim7</depend>
<depend condition="$GZ_VERSION == harmonic">gz-sim8</depend>

<depend condition="$GZ_VERSION == ''">ignition-plugin</depend>
<depend condition="$GZ_VERSION == fortress">ignition-plugin</depend>
<depend condition="$GZ_VERSION == garden">gz-plugin2</depend>
<depend condition="$GZ_VERSION == harmonic">gz-plugin2</depend>
<!-- default version to use in official ROS 2 packages is Gazebo Harmonic for ROS 2 Rolling -->
<depend>gz_sim_vendor</depend>
<depend>gz_plugin_vendor</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>yaml_cpp_vendor</depend>
Expand Down
22 changes: 0 additions & 22 deletions gz_ros2_control/src/gz_ros2_control_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,13 @@
#include <utility>
#include <vector>

#ifdef GZ_HEADERS
#include <gz/sim/components/Joint.hh>
#include <gz/sim/components/JointType.hh>
#include <gz/sim/components/Name.hh>
#include <gz/sim/components/ParentEntity.hh>
#include <gz/sim/components/World.hh>
#include <gz/sim/Model.hh>
#include <gz/plugin/Register.hh>
#else
#include <ignition/gazebo/components/Joint.hh>
#include <ignition/gazebo/components/JointType.hh>
#include <ignition/gazebo/components/Name.hh>
#include <ignition/gazebo/components/ParentEntity.hh>
#include <ignition/gazebo/components/World.hh>
#include <ignition/gazebo/Model.hh>
#include <ignition/plugin/Register.hh>
#endif


#include <controller_manager/controller_manager.hpp>
Expand Down Expand Up @@ -581,7 +571,6 @@ void GazeboSimROS2ControlPlugin::PostUpdate(
}
} // namespace gz_ros2_control

#ifdef GZ_HEADERS
GZ_ADD_PLUGIN(
gz_ros2_control::GazeboSimROS2ControlPlugin,
gz::sim::System,
Expand All @@ -591,14 +580,3 @@ GZ_ADD_PLUGIN(
GZ_ADD_PLUGIN_ALIAS(
gz_ros2_control::GazeboSimROS2ControlPlugin,
"ign_ros2_control::IgnitionROS2ControlPlugin")
#else
IGNITION_ADD_PLUGIN(
gz_ros2_control::GazeboSimROS2ControlPlugin,
ignition::gazebo::System,
gz_ros2_control::GazeboSimROS2ControlPlugin::ISystemConfigure,
gz_ros2_control::GazeboSimROS2ControlPlugin::ISystemPreUpdate,
gz_ros2_control::GazeboSimROS2ControlPlugin::ISystemPostUpdate)
IGNITION_ADD_PLUGIN_ALIAS(
gz_ros2_control::GazeboSimROS2ControlPlugin,
"ign_ros2_control::IgnitionROS2ControlPlugin")
#endif
Loading

0 comments on commit 18fd2c7

Please sign in to comment.