I want to use ROS2 control PID controller plugin with my external sensor. The documentations mention how to configure the yaml file and I did mine as follows:

    update_rate: 100 # Hz

      type: joint_state_broadcaster/JointStateBroadcaster

        type: pid_controller/PidController

      - joint0
      - joint1
    command_interface: effort

    reference_and_state_interfaces: ["/test_pid_controller/measured_state"]
    use_external_measured_states: true

      joint0: {p: 1.0, i: 1.0, d: 0.0, i_clamp_max: 5.0, i_clamp_min: -5.0}
      joint1: {p: 1.0, i: 0.0, d: 0.0, i_clamp_max: 0.1, i_clamp_min: 0.1}

Below is what I'm facing now.

  • First thing I noticed is that now there is a new topic that is available and has one subscriber which is test_pid_controller/measured_state as expected, however the test_pid_controller/reference is also being available and has one subscriber.
  • Second, when I publish to the test_pid_controller/measured_state my robot doesn't respond, yet it responds when I publish to test_pid_controller/reference.
  • Third, the test_pid_controller/controller_state has always some zero values like error and output. (probably because there is no feedback yet)
  • Finally, I want to know if I configured my yaml file correctly or not, and how should I integrate my sensor's feedback so the controller actually work? what topic should I publish to and what is the message I should I use?

1 Answer 1


Reference and state seem to be fine as input to the PID? State should be the feedback of the control loop, and you obviously need also a reference signal.

You already have linked to the documentation, where the expected message type on both topics is given (see also ros2 topic list -t)

  • $\begingroup$ So if I understand correctly I should publish my sensor's feedback to the test_pid_controller/measured_state topic and and set my reference point using the test_pid_controller/reference? I will test that $\endgroup$ Commented Jul 2 at 13:15

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.