Robotics StackExchange | Archived questions

ros2_control hardware interface startup

Hi,

I've defined my my "hardware interface" in my robot xacro file (see below), but when I run the launch script I get the error below. My question 2-fold;

  1. Why do I get the error? Is ros2_control complaining it can't find an interface for these Joints?
  2. Does ros2control start "ros2hoverboard_hardwarex/HoverboardJoints" automatically or do I need to start it somehow?

Thank-you for your time,

Andrew

Error

[ros2_control_node-2] terminate called after throwing an instance of 'std::runtime_error'
[ros2_control_node-2]   what():  Wrong state or command interface configuration.
[ros2_control_node-2] missing state interfaces:
[ros2_control_node-2] ' left_wheel_joint/velocity ' ' left_wheel_joint/position '   ' right_wheel_joint/velocity '  ' right_wheel_joint/position '  
[ros2_control_node-2] missing command interfaces:
[ros2_control_node-2] ' left_wheel_joint/velocity ' ' right_wheel_joint/velocity '  

XACRO

   <ros2_control name="RealRobot" type="Actuator">
        <hardware>
            <plugin>ros2_hoverboard_hardwarex/HoverboardJoints</plugin>
       </hardware>

        <joint name="left_wheel_joint">
            <command_interface name="velocity">
                <param name="min">-10</param>
                <param name="max">10</param>
            </command_interface>
            <state_interface name="velocity"/>
            <state_interface name="position"/>
        </joint>
        <joint name="right_wheel_joint">
            <command_interface name="velocity">
                <param name="min">-10</param>
                <param name="max">10</param>
            </command_interface>
            <state_interface name="velocity"/>
            <state_interface name="position"/>
        </joint>
    </ros2_control>

Asked by Rekabuk on 2022-11-02 05:03:06 UTC

Comments

Removing the "name" param in the ros2_control tag seemed to help. Found that in this post: link text

Asked by Rekabuk on 2022-11-02 06:50:15 UTC

But now I get this error :-(

[ros2_control_node-2] terminate called after throwing an instance of 'std::runtime_error'
[ros2_control_node-2]   what():  no attribute name in ros2_control tag

Asked by Rekabuk on 2022-11-02 07:05:17 UTC

Answers

Ha! I did it :-)

Created my own ros2_control hardware interface for Humble :-)

Lot's of Googling and guess work, big thanks to Josh Newams and his videos. Ros now reports my interface and joints - now to get them moving.

Soo happy !

Asked by Rekabuk on 2022-11-02 15:51:41 UTC

Comments

We're also happy :) and would be even happier if you'd provide some detail on how you managed to solve your issue. That'd help future users of ros2_control perhaps avoid the struggle you had with it.

Asked by gvdhoorn on 2022-11-03 03:40:09 UTC

I wish I knew :-) I just kept Googling, watching videos and changing things untill it loaded. My code is here if it helps anyone. And the robot is here. Although it loads and connects with ros2_control there is a lot more to do :-) Andrew

Asked by Rekabuk on 2022-11-03 06:22:08 UTC

Had the same problem. I was missing the following line in my implementation in on_init() function

hardware_interface::SystemInterface::on_init(info)

so it should look like this (taken from demo code)

hardware_interface::CallbackReturn RRBotSystemPositionOnlyHardware::on_init(
    const hardware_interface::HardwareInfo &info)
{

    if (hardware_interface::SystemInterface::on_init(info) !=
        hardware_interface::CallbackReturn::SUCCESS)
    {
        return hardware_interface::CallbackReturn::ERROR;
    }
    // ...
}

edit: plus correct implementation in export_state_interfaces() and export_command_interfaces() functions. Code can be also copied from demo examples

Asked by Dead7alone on 2023-07-25 07:48:36 UTC