0
$\begingroup$

In this page of the documentation of ros2 control There is no mention of how to make the PID controller actually work. If I run the yaml file example provided

test_pid_controller:
  ros__parameters:
    dof_names:
      - joint1

    command_interface: position

    reference_and_state_interfaces: ["position"]

    gains:
      joint1: {p: 1.0, i: 2.0, d: 10.0, i_clamp_max: 5.0, i_clamp_min: -5.0}

I get a no 'type' param was provided error

I modified the yaml file to be as follow:

controller_manager:
  ros__parameters:
    update_rate: 100 # Hz

    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster

    test_pid_controller:
      type: pid_controllers/MyController #I tried anything because no info. provided

test_pid_controller:
  ros__parameters:
    dof_names:
      - joint0

    command_interface: effort

    reference_and_state_interfaces: ["effort"]

    gains:
      joint0: {p: 1.0, i: 2.0, d: 10.0, i_clamp_max: 5.0, i_clamp_min: -5.0}

and the launch file as:


from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
    declared_arguments = []

    declared_arguments.append(
        DeclareLaunchArgument(
            "joint0_controller",
            default_value="test_pid_controller",
        )
    )

  
    joint0_controller = LaunchConfiguration("joint0_controller")


    robot_description_content = Command(
        [
            PathJoinSubstitution([FindExecutable(name="xacro")]),
            " ",
            PathJoinSubstitution(
                [
                    FindPackageShare("odrive_demo_description"),
                    "urdf",
                    "odrive.urdf.xacro",
                ]
            ),
        
        ]
    )
    robot_description = {"robot_description": robot_description_content}

    robot_controllers = PathJoinSubstitution(
        [
            FindPackageShare("odrive_demo_bringup"),
            "config",
            "odrive_multi_interface_forward_controllers.yaml",
        ]
    )

    control_node = Node(
        package="controller_manager",
        executable="ros2_control_node",
        output="both",
        parameters=[robot_description, robot_controllers],
    )

    robot_state_pub_node = Node(
        package="robot_state_publisher",
        executable="robot_state_publisher",
        output="both",
        parameters=[robot_description],
    )

    joint_state_broadcaster_spawner = Node(
        package="controller_manager",
        executable="spawner",
        arguments=["joint_state_broadcaster", "-c", "/controller_manager"],
    )

    joint0_controller_spawner = Node(
        package="controller_manager",
        executable="spawner",
        arguments=[joint0_controller, "-c", "/controller_manager"],
        condition=IfCondition(enable_joint0),
    )

  

    nodes = [
        control_node,
        robot_state_pub_node,
        joint_state_broadcaster_spawner,
        joint0_controller_spawner,
    
    ]

    return LaunchDescription(declared_arguments + nodes)

The error I get is this:

 Loader for controller 'test_pid_controller' (type 'pid_controllers/MyController') not found.
[ros2_control_node-1] [INFO] [1716809582.226275154] [controller_manager]: Available classes:
[ros2_control_node-1] [INFO] [1716809582.226280982] [controller_manager]:   controller_manager/test_controller
[ros2_control_node-1] [INFO] [1716809582.226284774] [controller_manager]:   controller_manager/test_controller_failed_init
[ros2_control_node-1] [INFO] [1716809582.226288265] [controller_manager]:   controller_manager/test_controller_with_interfaces
[ros2_control_node-1] [INFO] [1716809582.226291837] [controller_manager]:   diff_drive_controller/DiffDriveController
[ros2_control_node-1] [INFO] [1716809582.226295379] [controller_manager]:   effort_controllers/JointGroupEffortController
[ros2_control_node-1] [INFO] [1716809582.226298651] [controller_manager]:   force_torque_sensor_broadcaster/ForceTorqueSensorBroadcaster
[ros2_control_node-1] [INFO] [1716809582.226302046] [controller_manager]:   forward_command_controller/ForwardCommandController
[ros2_control_node-1] [INFO] [1716809582.226305513] [controller_manager]:   forward_command_controller/MultiInterfaceForwardCommandController
[ros2_control_node-1] [INFO] [1716809582.226309029] [controller_manager]:   imu_sensor_broadcaster/IMUSensorBroadcaster
[ros2_control_node-1] [INFO] [1716809582.226312409] [controller_manager]:   joint_state_broadcaster/JointStateBroadcaster
[ros2_control_node-1] [INFO] [1716809582.226315616] [controller_manager]:   joint_trajectory_controller/JointTrajectoryController
[ros2_control_node-1] [INFO] [1716809582.226318992] [controller_manager]:   position_controllers/JointGroupPositionController
[ros2_control_node-1] [INFO] [1716809582.226322531] [controller_manager]:   range_sensor_broadcaster/RangeSensorBroadcaster
[ros2_control_node-1] [INFO] [1716809582.226325760] [controller_manager]:   tricycle_controller/TricycleController
[ros2_control_node-1] [INFO] [1716809582.226329079] [controller_manager]:   velocity_controllers/JointGroupVelocityController
[ros2_control_node-1] [INFO] [1716809582.226333573] [controller_manager]:   ackermann_steering_controller/AckermannSteeringController
[ros2_control_node-1] [INFO] [1716809582.226339461] [controller_manager]:   admittance_controller/AdmittanceController
[ros2_control_node-1] [INFO] [1716809582.226343049] [controller_manager]:   bicycle_steering_controller/BicycleSteeringController
[ros2_control_node-1] [INFO] [1716809582.226346316] [controller_manager]:   controller_manager/test_chainable_controller
[ros2_control_node-1] [INFO] [1716809582.226349625] [controller_manager]:   tricycle_steering_controller/TricycleSteeringController

I installed control-toolbox using apt but still no use.

I know the issue is with the type of the controller, what is the correct type?

$\endgroup$

1 Answer 1

2
$\begingroup$

See this section: You have to use type: pid_controller/PidController. (I have to admit, this could be documented clearer).

controller_manager:
  ros__parameters:
    update_rate: 10  # Hz

    test_pid_controller:
        type: pid_controller/PidController

test_pid_controller:
  ros__parameters:
    dof_names:
      - joint0
    <etc>

Since a recent change we also support a configuration like

controller_manager:
  ros__parameters:
    update_rate: 10  # Hz

test_pid_controller:
  ros__parameters:
    type: pid_controller/PidController
    dof_names:
      - joint0
    <etc>
$\endgroup$
3
  • $\begingroup$ Thanks a lot Christopher, I tried type: pid_controller/PidController but I still got the same error from the control manger [ros2_control_node-1] [ERROR] [1716872181.723049299] [controller_manager]: Loader for controller 'test_pid_controller' (type 'pid_controller/PidController') not found. Am I launching it correctly? Do I need to install something else? $\endgroup$ Commented May 28 at 5:00
  • $\begingroup$ It seems that it is not installed (from your console output in the original question). If you install sudo apt-get install ros-$ROS_DISTRO-ros2-controllersit should be installed. Which distro are you using? PID Controller is only available for Jazzy+Rolling. $\endgroup$ Commented May 28 at 9:10
  • $\begingroup$ I'm using humble, that is why. I will update to Jazzy and test it again. Thank you Christopher. $\endgroup$ Commented May 28 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.