diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0665a20b..444457b4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,3 +41,39 @@ jobs: . /opt/ros/galactic/local_setup.sh colcon test --event-handlers console_direct+ --packages-select gazebo_ros2_control gazebo_ros2_control_demos colcon test-result + build_testing: + runs-on: ubuntu-latest + container: + image: osrf/ros:galactic-desktop + steps: + - uses: actions/checkout@v2 + - name: Setup colcon workspace + id: configure + run: | + cd .. + mkdir -p /home/ros2_ws/src + cp -r gazebo_ros2_control /home/ros2_ws/src/ + sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2-testing/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list' + apt-get update && apt-get upgrade -q -y + apt-get update && apt-get install -q -y --no-install-recommends \ + dirmngr \ + gnupg2 \ + lsb-release \ + python3-colcon-ros + cd /home/ros2_ws/src/ + rosdep update + rosdep install --from-paths ./ -i -y --rosdistro galactic \ + --ignore-src + - name: Build project + id: build + run: | + cd /home/ros2_ws/ + . /opt/ros/galactic/local_setup.sh + colcon build --packages-up-to gazebo_ros2_control_demos + - name: Run tests + id: test + run: | + cd /home/ros2_ws/ + . /opt/ros/galactic/local_setup.sh + colcon test --event-handlers console_direct+ --packages-select gazebo_ros2_control gazebo_ros2_control_demos + colcon test-result diff --git a/gazebo_ros2_control/include/gazebo_ros2_control/gazebo_system.hpp b/gazebo_ros2_control/include/gazebo_ros2_control/gazebo_system.hpp index 2b37198d..c3fa67f3 100644 --- a/gazebo_ros2_control/include/gazebo_ros2_control/gazebo_system.hpp +++ b/gazebo_ros2_control/include/gazebo_ros2_control/gazebo_system.hpp @@ -38,7 +38,7 @@ class GazeboSystem : public GazeboSystemInterface { public: // Documentation Inherited - hardware_interface::return_type configure(const hardware_interface::HardwareInfo & system_info) + CallbackReturn on_init(const hardware_interface::HardwareInfo & system_info) override; // Documentation Inherited @@ -48,10 +48,10 @@ class GazeboSystem : public GazeboSystemInterface std::vector export_command_interfaces() override; // Documentation Inherited - hardware_interface::return_type start() override; + CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override; // Documentation Inherited - hardware_interface::return_type stop() override; + CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override; // Documentation Inherited hardware_interface::return_type read() override; diff --git a/gazebo_ros2_control/include/gazebo_ros2_control/gazebo_system_interface.hpp b/gazebo_ros2_control/include/gazebo_ros2_control/gazebo_system_interface.hpp index 598f884c..eb40f3b6 100644 --- a/gazebo_ros2_control/include/gazebo_ros2_control/gazebo_system_interface.hpp +++ b/gazebo_ros2_control/include/gazebo_ros2_control/gazebo_system_interface.hpp @@ -24,9 +24,7 @@ #include "gazebo/physics/Model.hh" #include "gazebo/physics/physics.hh" -#include "hardware_interface/base_interface.hpp" #include "hardware_interface/system_interface.hpp" -#include "hardware_interface/types/hardware_interface_type_values.hpp" #include "rclcpp/rclcpp.hpp" @@ -60,7 +58,7 @@ class SafeEnum // SystemInterface provides API-level access to read and command joint properties. class GazeboSystemInterface - : public hardware_interface::BaseInterface + : public hardware_interface::SystemInterface { public: /// \brief Initilize the system interface diff --git a/gazebo_ros2_control/src/gazebo_system.cpp b/gazebo_ros2_control/src/gazebo_system.cpp index da25fb0e..d148546d 100644 --- a/gazebo_ros2_control/src/gazebo_system.cpp +++ b/gazebo_ros2_control/src/gazebo_system.cpp @@ -22,6 +22,9 @@ #include "gazebo/sensors/ImuSensor.hh" #include "gazebo/sensors/ForceTorqueSensor.hh" #include "gazebo/sensors/SensorManager.hh" + +#include "hardware_interface/types/hardware_interface_type_values.hpp" + class gazebo_ros2_control::GazeboSystemPrivate { public: @@ -346,13 +349,13 @@ void GazeboSystem::registerSensors( } } -hardware_interface::return_type -GazeboSystem::configure(const hardware_interface::HardwareInfo & actuator_info) +CallbackReturn +GazeboSystem::on_init(const hardware_interface::HardwareInfo & actuator_info) { - if (configure_default(actuator_info) != hardware_interface::return_type::OK) { - return hardware_interface::return_type::ERROR; + if (hardware_interface::SystemInterface::on_init(actuator_info) != CallbackReturn::SUCCESS) { + return CallbackReturn::ERROR; } - return hardware_interface::return_type::OK; + return CallbackReturn::SUCCESS; } std::vector @@ -367,16 +370,14 @@ GazeboSystem::export_command_interfaces() return std::move(this->dataPtr->command_interfaces_); } -hardware_interface::return_type GazeboSystem::start() +CallbackReturn GazeboSystem::on_activate(const rclcpp_lifecycle::State & previous_state) { - status_ = hardware_interface::status::STARTED; - return hardware_interface::return_type::OK; + return CallbackReturn::SUCCESS; } -hardware_interface::return_type GazeboSystem::stop() +CallbackReturn GazeboSystem::on_deactivate(const rclcpp_lifecycle::State & previous_state) { - status_ = hardware_interface::status::STOPPED; - return hardware_interface::return_type::OK; + return CallbackReturn::SUCCESS; } hardware_interface::return_type GazeboSystem::read()