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

Any PID-based "controller_interface::ControllerInterface" implementations/examples for ROS2?

asked 2022-04-06 03:52:11 -0600

updated 2022-04-06 04:10:50 -0600

ROS2 has the forward_command_controller::ForwardCommandController base class, and position/effort/velocity-based sub-classes, but all they do is to set the joint position/velocity/effort value directly on the respective joint interface, without any error-based feedback control loop.

Is there an equivalent PID-based implementation of the controller_interface::ControllerInterface interface that has an error-feedback loop between control input and state output that could be applied across interfaces (such as, effort control with positional error feedback)? I've seen other PID controllers that are independent of the ros2_control framework, which I am not referring to. I'm specifically looking for a PID based controller that works within the pluggable ros2_control framework.

More specifically, say I have a <ros2_control> tag as below in my URDF:

<ros2_control name="pole" type="system">
    <hardware>
      <plugin>my_hardware/MyHardwareInterface</plugin>
      <param name="blah">some_value</param>
    </hardware>
    <joint name="pole_joint">

      <state_interface name="position"/>             <<<<<<<< POSITION (TARGET VALUE)

      <command_interface name="effort">          <<<<<<<< EFFORT (CONTROL INPUT)
        <param name="min">0.0</param>
        <param name="max">1.0</param>
        <param name="initial_value">0.0</param>
      </command_interface>
    </joint>
</ros2_control>

I want to define a controller for the pole_joint's position, but I need a PID-based feedback loop, since the control and state interfaces are different. (Furthermore, even if the command and state interfaces were the same, the hardware will not offer "instant" enforcement of the target value, which the ForwardCommandController seems to assume). Am I going to be forced to implement a PID mechanism within the MyHardwareInterface class, or is it possible to utilize an off-the-shelf PID-based ros2_controller that would work universally with any hardware interface (and for any command/state interface combination for feedback control)?

Some instructions or link to an example implementation+configuration would be greatly appreciated.

Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-04-06 12:24:34 -0600

shonigmann gravatar image

I am not aware of anything that has made it into the upstream ros2_controllers repo, but there was some in progress work on this that you may find useful.

ros2_controllers#198 has a bit of discussion, and I did make a fork with a functional* PID controller (* see my comment for a few caveats). My work on this had stalled out and was never upstreamed because I had wanted to include joint limits, but the upstream ros2_control repo has yet to finalize how these are going to be implemented.

A few other notes if you do follow my rough implementation as a starting point:

  • PID values are passed in as a parameters from your controllers.yaml file. They are expected in the form of:

Yaml Format

my_controller:
  ros__parameters:
    gains:
      joint_1:
        p: 10.0
        i: 1.0
        d: 0.0
      ...

or equivalently as a parameter with the name gains.joint_1.p

  • gains are only updated in the controller when the controller in the on_configure() method. If you want to be able to change them on the fly without reloading the controller, you'd need to add a parameter callback. There's a bit of a safety vs convenience tradeoff there.
  • the joint limit implementation I was using is deprecated and might require that you pull a specific commit of ros2_control. if you don't need it, it may be worth removing them. If you do remove them, consider submitting a PR to ros2_controllers with the simpler "first pass" solution. I'm sure many people would find it useful
  • its been a while since I've worked on this and my fork is ~70 commits behind master, so there is a good chance it won't work without merging in some of the more recent changes
edit flag offensive delete link more

Comments

Thanks for the links and explanation, @shonigmann! Fortunately, I am not blocked on such a controller being available immediately, but that might change. If I do end up taking a stab at it at a later date, I'll definitely submit a PR.

alikureishy gravatar image alikureishy  ( 2022-04-06 13:57:38 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2022-04-06 03:52:11 -0600

Seen: 538 times

Last updated: Apr 06 '22