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

[ros2_control] Combined hw_interface for arm and gripper

asked 2021-08-04 15:12:50 -0600

AndyZe gravatar image

updated 2021-08-04 15:14:31 -0600

We have a robot that's a little unusual in that the manufacturer combined gripper control and arm joint control into a single, unified API. Thus, we can't really instantiate 2 objects to control gripper and arm separately. We aren't sure how to control the gripper and the arm in a combined fashion.

Our first attempt has a controllers.yaml like this:

joint_trajectory_controller:
  type: joint_trajectory_controller/JointTrajectoryController

# The gripper controller just relays position commands
gripper_controller:
  type: forward_command_controller/ForwardCommandController

joint_trajectory_controller:
  ros__parameters:
    joints:
      - joint_1
      - joint_2
      - joint_3
      - joint_4
      - joint_5
      - joint_6
      - joint_7

gripper_controller:
  ros__parameters:
    joints:
      - finger_joint
    interface_name: position

Our custom interface inherits like this:

class OurMultInterfaceHardware : public hardware_interface::BaseInterface<hardware_interface::SystemInterface

When launching on hardware, we can see from some print statements that OurMultiInterfaceHardware gets instantiated twice, which will not work with the manufacturer's API. It works fine in simulation.

The important parts from the launch file:

robot_controller_spawner = Node(
    package="controller_manager",
    executable="spawner.py",
    arguments=[robot_controller, gripp, "-c", "/controller_manager"],
)

gripper_controller_spawner = Node(
    package="controller_manager",
    executable="spawner.py",
    arguments=[gripper_controller, "-c", "/controller_manager"],
)

nodes_to_start = [
    control_node,
    robot_state_publisher_node,
    rviz_node,
    joint_state_broadcaster_spawner,
    robot_controller_spawner,
    gripper_controller_spawner,
]

I think the crux of the question is, does each controller that gets spawned require its own hardware interface?

edit retag flag offensive close merge delete

Comments

In ros 1 you could start multiple controllers with a single controller_manager. <node name="arm_controller_spawner" pkg="controller_manager" type="spawner" output="screen" args="arm_joint_state_controller arm_controller gripper_controller"/> but I don't know about ros2 here

Humpelstilzchen gravatar image Humpelstilzchen  ( 2021-08-05 00:34:48 -0600 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2021-08-05 12:23:51 -0600

First of all, your configuration looks correct, and the launch file is also.

Generally, controllers do not initialize hardware interfaces not they can instantiate it. Hardware is (at current Foxy version) instantiated automatically when controller manager is started. This can be tested by commenting out spawners.

Spawning of controllers is happening independently from hardware. Corresponding interfaces of the controller and hardware must exist and match.

The issue could be that you are “instantiating” ros2_control-macro in URDF twice. Can you check this?

edit flag offensive delete link more
1

answered 2021-08-05 08:31:48 -0600

AndyZe gravatar image

The problem was that we tried to include a modular ros2_control xacro for the gripper, like this from the gripper xacro:

<!-- ros2 control include -->
<xacro:include filename="$(find my_robot_description)/grippers/robotiq_2f_85/urdf/robotiq_my_robot.ros2_control.xacro" />
<xacro:robotiq_my_robot_ros2_control
name="MyRobotGripperInterfaceHardware" prefix="${prefix}"
use_fake_hardware="${use_fake_hardware}"
fake_sensor_commands="${fake_sensor_commands}"
tf_prefix=""
robot_ip="${robot_ip}" />

The second ros2_control xacro spawned a second copy of the hardware_interface.

So it seems like there can only be one inclusion of ros2_control xacro "stuff".

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-08-04 15:12:50 -0600

Seen: 749 times

Last updated: Aug 05 '21