ros2_controllers icon indicating copy to clipboard operation
ros2_controllers copied to clipboard

Chained Controller exported reference interface unavailable

Open Teusner opened this issue 3 years ago • 1 comments

Bug

When we implement a chained controller, we need to export reference interfaces which will be (as far as I understood) seen by other controllers as command interfaces. The problem is that these exported reference interfaces don't seem to be available (as they appear unavailable). Here is the listing of the hardware interfaces.

> ros2 control list_hardware_interfaces
command interfaces
        joint1/position [available] [claimed]
        controller1/position [unavailable] [unclaimed]
[...]

It induces that the previous controller can't find the exported reference interface, configured as a command interface in this one, and this previous controller can't be properly initialized.

I may have miss something to make these exported reference interfaces available, it will be more clear when the documentation will be available :kissing_heart:. In my controller I had to add the following instructions to export my reference interfaces :

std::vector<hardware_interface::CommandInterface> Controller::on_export_reference_interfaces() {
        std::vector<hardware_interface::CommandInterface> command_interfaces;
        command_interfaces.emplace_back(hardware_interface::CommandInterface(get_node()->get_name(), "position", &reference_interfaces_[0]));
        return command_interfaces;
}
[...]
controller_interface::CallbackReturn Controller::on_configure(const rclcpp_lifecycle::State & /*previous_state*/) {
        [...]
        reference_interfaces_.resize(1, std::numeric_limits<double>::quiet_NaN());
        set_chained_mode(true);
        [...]
}
[...]
controller_interface::CallbackReturn Controller::on_activate(const rclcpp_lifecycle::State & /*previous_state*/) {
        std::fill(reference_interfaces_.begin(), reference_interfaces_.end(), std::numeric_limits<double>::quiet_NaN());
        return CallbackReturn::SUCCESS;
}

Question

  • Did I make the exported references available correctly ?
  • Is this a normal behavior and I forget to do something ?

Configuration

  • OS: Ubuntu 22.04
  • Version: ROS2 Humble
  • ROS2Control: installed from apt binary packages (http://packages.ros.org/ros2/ubuntu jammy/main amd64)

Teusner avatar Oct 28 '22 13:10 Teusner

Update It seems that it could be a ros2cli issues but I'm not sure...

> ros2 control list_controllers 
controller1     [controllers/Controller] unconfigured
ros2 control set_controller_state controller1 configure
usage: ros2 control set_controller_state [-h] [--spin-time SPIN_TIME] [-s] [-c CONTROLLER_MANAGER] [--include-hidden-nodes] controller_name {inactive,active}
ros2 control set_controller_state: error: argument state: invalid choice: 'configure' (choose from 'inactive', 'active')

(don't know if this has to be configure or configured, tried both, same output :sob: )

Can you confirm that exported reference interfaces are unavailable because my controller is unconfigured ? How can I then configure my controller (Updating the CLI, using a service call, ...) ?

Thanks in advance

Teusner avatar Nov 07 '22 13:11 Teusner