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

Migrating from Foxy to Galactic #138

Merged
merged 8 commits into from
Oct 4, 2021
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
2 changes: 2 additions & 0 deletions .github/workflows/ci-build-semi-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
env:
- {ROS_DISTRO: rolling, ROS_REPO: main}
- {ROS_DISTRO: rolling, ROS_REPO: testing}
env:
UPSTREAM_WORKSPACE: ros2_control_demos.repos
steps:
- uses: actions/checkout@v1
- uses: 'ros-industrial/industrial_ci@master'
Expand Down
4 changes: 4 additions & 0 deletions ros2_control_demo_hardware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ find_package(ament_cmake REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)


## COMPILE
add_library(
Expand All @@ -35,6 +37,7 @@ ament_target_dependencies(
hardware_interface
pluginlib
rclcpp
rclcpp_lifecycle
)

pluginlib_export_plugin_description_file(hardware_interface ros2_control_demo_hardware.xml)
Expand Down Expand Up @@ -64,5 +67,6 @@ ament_export_dependencies(
hardware_interface
pluginlib
rclcpp
rclcpp_lifecycle
)
ament_package()
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,26 @@
#include <string>
#include <vector>

#include "hardware_interface/base_interface.hpp"
#include "hardware_interface/handle.hpp"
#include "hardware_interface/hardware_info.hpp"
#include "hardware_interface/system_interface.hpp"
#include "hardware_interface/types/hardware_interface_return_values.hpp"
#include "hardware_interface/types/hardware_interface_status_values.hpp"
#include "rclcpp/macros.hpp"
#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
#include "rclcpp_lifecycle/state.hpp"
#include "ros2_control_demo_hardware/visibility_control.h"

using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;

namespace ros2_control_demo_hardware
{
class DiffBotSystemHardware
: public hardware_interface::BaseInterface<hardware_interface::SystemInterface>
class DiffBotSystemHardware : public hardware_interface::SystemInterface
{
public:
RCLCPP_SHARED_PTR_DEFINITIONS(DiffBotSystemHardware);

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type configure(const hardware_interface::HardwareInfo & info) override;
CallbackReturn on_init(const hardware_interface::HardwareInfo & info) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
std::vector<hardware_interface::StateInterface> export_state_interfaces() override;
Expand All @@ -46,10 +47,10 @@ class DiffBotSystemHardware
std::vector<hardware_interface::CommandInterface> export_command_interfaces() override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type start() override;
CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type stop() override;
CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type read() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,26 @@
#include <string>
#include <vector>

#include "rclcpp/macros.hpp"

#include "hardware_interface/base_interface.hpp"
#include "hardware_interface/handle.hpp"
#include "hardware_interface/hardware_info.hpp"
#include "hardware_interface/system_interface.hpp"
#include "hardware_interface/types/hardware_interface_return_values.hpp"
#include "hardware_interface/types/hardware_interface_status_values.hpp"
#include "rclcpp/macros.hpp"
#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
#include "rclcpp_lifecycle/state.hpp"
#include "ros2_control_demo_hardware/visibility_control.h"

using hardware_interface::return_type;
using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;

namespace ros2_control_demo_hardware
{
class RRBotSystemMultiInterfaceHardware
: public hardware_interface::BaseInterface<hardware_interface::SystemInterface>
class RRBotSystemMultiInterfaceHardware : public hardware_interface::SystemInterface
{
public:
RCLCPP_SHARED_PTR_DEFINITIONS(RRBotSystemMultiInterfaceHardware);

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
return_type configure(const hardware_interface::HardwareInfo & info) override;
CallbackReturn on_init(const hardware_interface::HardwareInfo & info) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
std::vector<hardware_interface::StateInterface> export_state_interfaces() override;
Expand All @@ -50,21 +48,21 @@ class RRBotSystemMultiInterfaceHardware
std::vector<hardware_interface::CommandInterface> export_command_interfaces() override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
return_type prepare_command_mode_switch(
hardware_interface::return_type prepare_command_mode_switch(
const std::vector<std::string> & start_interfaces,
const std::vector<std::string> & stop_interfaces) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
return_type start() override;
CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
return_type stop() override;
CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
return_type read() override;
hardware_interface::return_type read() override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
return_type write() override;
hardware_interface::return_type write() override;

private:
// Parameters for the RRBot simulation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,29 @@
#include <string>
#include <vector>

#include "hardware_interface/base_interface.hpp"
#include "hardware_interface/handle.hpp"
#include "hardware_interface/hardware_info.hpp"
#include "hardware_interface/system_interface.hpp"
#include "hardware_interface/types/hardware_interface_return_values.hpp"
#include "hardware_interface/types/hardware_interface_status_values.hpp"
#include "rclcpp/macros.hpp"
#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
#include "rclcpp_lifecycle/state.hpp"
#include "ros2_control_demo_hardware/visibility_control.h"

using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;

namespace ros2_control_demo_hardware
{
class RRBotSystemPositionOnlyHardware
: public hardware_interface::BaseInterface<hardware_interface::SystemInterface>
class RRBotSystemPositionOnlyHardware : public hardware_interface::SystemInterface
{
public:
RCLCPP_SHARED_PTR_DEFINITIONS(RRBotSystemPositionOnlyHardware);

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type configure(const hardware_interface::HardwareInfo & info) override;
CallbackReturn on_init(const hardware_interface::HardwareInfo & info) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
CallbackReturn on_configure(const rclcpp_lifecycle::State & previous_state) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
std::vector<hardware_interface::StateInterface> export_state_interfaces() override;
Expand All @@ -46,10 +50,10 @@ class RRBotSystemPositionOnlyHardware
std::vector<hardware_interface::CommandInterface> export_command_interfaces() override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type start() override;
CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type stop() override;
CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type read() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,28 @@
#include <string>
#include <vector>

#include "hardware_interface/base_interface.hpp"
#include "hardware_interface/handle.hpp"
#include "hardware_interface/hardware_info.hpp"
#include "hardware_interface/system_interface.hpp"
#include "hardware_interface/types/hardware_interface_return_values.hpp"
#include "hardware_interface/types/hardware_interface_status_values.hpp"
#include "rclcpp/macros.hpp"
#include "rclcpp_lifecycle/state.hpp"
#include "ros2_control_demo_hardware/visibility_control.h"

using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;

namespace ros2_control_demo_hardware
{
class RRBotSystemWithSensorHardware
: public hardware_interface::BaseInterface<hardware_interface::SystemInterface>
class RRBotSystemWithSensorHardware : public hardware_interface::SystemInterface
{
public:
RCLCPP_SHARED_PTR_DEFINITIONS(RRBotSystemWithSensorHardware);

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type configure(const hardware_interface::HardwareInfo & info) override;
CallbackReturn on_init(const hardware_interface::HardwareInfo & info) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
CallbackReturn on_configure(const rclcpp_lifecycle::State & previous_state) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
std::vector<hardware_interface::StateInterface> export_state_interfaces() override;
Expand All @@ -50,10 +53,10 @@ class RRBotSystemWithSensorHardware
std::vector<hardware_interface::CommandInterface> export_command_interfaces() override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type start() override;
CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type stop() override;
CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
hardware_interface::return_type read() override;
Expand Down
1 change: 1 addition & 0 deletions ros2_control_demo_hardware/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<depend>hardware_interface</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>

<test_depend>ament_cmake_gtest</test_depend>

Expand Down
34 changes: 15 additions & 19 deletions ros2_control_demo_hardware/src/diffbot_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@

namespace ros2_control_demo_hardware
{
hardware_interface::return_type DiffBotSystemHardware::configure(
const hardware_interface::HardwareInfo & info)
CallbackReturn DiffBotSystemHardware::on_init(const hardware_interface::HardwareInfo & info)
{
base_x_ = 0.0;
base_y_ = 0.0;
base_theta_ = 0.0;

if (configure_default(info) != hardware_interface::return_type::OK)
if (hardware_interface::SystemInterface::on_init(info) != CallbackReturn::SUCCESS)
{
return hardware_interface::return_type::ERROR;
return CallbackReturn::ERROR;
}

hw_start_sec_ = stod(info_.hardware_parameters["example_param_hw_start_duration_sec"]);
Expand All @@ -52,7 +51,7 @@ hardware_interface::return_type DiffBotSystemHardware::configure(
rclcpp::get_logger("DiffBotSystemHardware"),
"Joint '%s' has %zu command interfaces found. 1 expected.", joint.name.c_str(),
joint.command_interfaces.size());
return hardware_interface::return_type::ERROR;
return CallbackReturn::ERROR;
}

if (joint.command_interfaces[0].name != hardware_interface::HW_IF_VELOCITY)
Expand All @@ -61,7 +60,7 @@ hardware_interface::return_type DiffBotSystemHardware::configure(
rclcpp::get_logger("DiffBotSystemHardware"),
"Joint '%s' have %s command interfaces found. '%s' expected.", joint.name.c_str(),
joint.command_interfaces[0].name.c_str(), hardware_interface::HW_IF_VELOCITY);
return hardware_interface::return_type::ERROR;
return CallbackReturn::ERROR;
}

if (joint.state_interfaces.size() != 2)
Expand All @@ -70,7 +69,7 @@ hardware_interface::return_type DiffBotSystemHardware::configure(
rclcpp::get_logger("DiffBotSystemHardware"),
"Joint '%s' has %zu state interface. 2 expected.", joint.name.c_str(),
joint.state_interfaces.size());
return hardware_interface::return_type::ERROR;
return CallbackReturn::ERROR;
}

if (joint.state_interfaces[0].name != hardware_interface::HW_IF_POSITION)
Expand All @@ -79,7 +78,7 @@ hardware_interface::return_type DiffBotSystemHardware::configure(
rclcpp::get_logger("DiffBotSystemHardware"),
"Joint '%s' have '%s' as first state interface. '%s' expected.", joint.name.c_str(),
joint.state_interfaces[0].name.c_str(), hardware_interface::HW_IF_POSITION);
return hardware_interface::return_type::ERROR;
return CallbackReturn::ERROR;
}

if (joint.state_interfaces[1].name != hardware_interface::HW_IF_VELOCITY)
Expand All @@ -88,12 +87,11 @@ hardware_interface::return_type DiffBotSystemHardware::configure(
rclcpp::get_logger("DiffBotSystemHardware"),
"Joint '%s' have '%s' as second state interface. '%s' expected.", joint.name.c_str(),
joint.state_interfaces[1].name.c_str(), hardware_interface::HW_IF_VELOCITY);
return hardware_interface::return_type::ERROR;
return CallbackReturn::ERROR;
}
}

status_ = hardware_interface::status::CONFIGURED;
return hardware_interface::return_type::OK;
return CallbackReturn::SUCCESS;
}

std::vector<hardware_interface::StateInterface> DiffBotSystemHardware::export_state_interfaces()
Expand Down Expand Up @@ -122,7 +120,8 @@ std::vector<hardware_interface::CommandInterface> DiffBotSystemHardware::export_
return command_interfaces;
}

hardware_interface::return_type DiffBotSystemHardware::start()
CallbackReturn DiffBotSystemHardware::on_activate(
const rclcpp_lifecycle::State & /*previous_state*/)
{
RCLCPP_INFO(rclcpp::get_logger("DiffBotSystemHardware"), "Starting ...please wait...");

Expand All @@ -144,14 +143,13 @@ hardware_interface::return_type DiffBotSystemHardware::start()
}
}

status_ = hardware_interface::status::STARTED;

RCLCPP_INFO(rclcpp::get_logger("DiffBotSystemHardware"), "System Successfully started!");

return hardware_interface::return_type::OK;
return CallbackReturn::SUCCESS;
}

hardware_interface::return_type DiffBotSystemHardware::stop()
CallbackReturn DiffBotSystemHardware::on_deactivate(
const rclcpp_lifecycle::State & /*previous_state*/)
{
RCLCPP_INFO(rclcpp::get_logger("DiffBotSystemHardware"), "Stopping ...please wait...");

Expand All @@ -162,11 +160,9 @@ hardware_interface::return_type DiffBotSystemHardware::stop()
rclcpp::get_logger("DiffBotSystemHardware"), "%.1f seconds left...", hw_stop_sec_ - i);
}

status_ = hardware_interface::status::STOPPED;

RCLCPP_INFO(rclcpp::get_logger("DiffBotSystemHardware"), "System successfully stopped!");

return hardware_interface::return_type::OK;
return CallbackReturn::SUCCESS;
}

hardware_interface::return_type DiffBotSystemHardware::read()
Expand Down
Loading