ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ros2_control hardware interface startup

asked 2022-11-02 05:03:06 -0500

Rekabuk gravatar image

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 ros2_control start "ros2_hoverboard_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>
edit retag flag offensive close merge delete

Comments

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

Rekabuk gravatar image Rekabuk  ( 2022-11-02 06:50:15 -0500 )edit

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
Rekabuk gravatar image Rekabuk  ( 2022-11-02 07:05:17 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-11-02 15:51:41 -0500

Rekabuk gravatar image

updated 2022-11-03 06:22:57 -0500

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 !

edit flag offensive delete link more

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.

gvdhoorn gravatar image gvdhoorn  ( 2022-11-03 03:40:09 -0500 )edit

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

Rekabuk gravatar image Rekabuk  ( 2022-11-03 06:22:08 -0500 )edit

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

Dead7alone gravatar image Dead7alone  ( 2023-07-25 07:48:36 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-11-02 05:03:06 -0500

Seen: 613 times

Last updated: Nov 03 '22