lbr-stack / lbr_fri_ros2_stack

ROS 1/2 integration for KUKA LBR IIWA 7/14 and Med 7/14
https://lbr-stack.readthedocs.io/en/latest/
Apache License 2.0
121 stars 34 forks source link

Question regarding internal PID Controller Values #171

Closed StephanSchwarz96 closed 2 months ago

StephanSchwarz96 commented 2 months ago

Hello,

first of all, thanks for the great work! I am currently using the stack to control the robot using the "/lbr/command/joint_position" command, similar to the joint_sine_overlay example. I implemented my own limit check and publish small steps along my trajectory (within the limits).

Unfortunately, the robot moves very slow. After some digging in the lbr_fri_ros2 package I found, that an additional pid control is used with extra checks.

What I am curious about is, why the pid parameter are set multiplied by the step_size: pid.initPid(pid_parameters.p dt, pid_parameters.i dt, pid_parameters.d dt, pid_parameters.i_max dt, pid_parameters.i_min * dt, pid_parameters.antiwindup);

After looking into the ros control_toolbox, this does not make much sense to me since it results in a very slow motion. Is there anything I am missing?

Thanks for any advice!

mhubii commented 2 months ago

hi @StephanSchwarz96 sorry for the late reply. True, there is a PID to ensure smooth motion. The idea here was to ensure PID work across all robot communication rates. Alternative suggestions are very welcome!

To your question, have you tried increasing the P gain? You can do this e.g. here:

https://github.com/lbr-stack/lbr_fri_ros2_stack/blob/036b23b2f91af70e1ca490e0c81660b6b17ae114/lbr_ros2_control/config/lbr_system_interface.xacro#L24

The notation ^|1.0 defaults to 1.0 when unspecified and takes another value when specified in the include, i.e. in the URDF:

https://github.com/lbr-stack/lbr_fri_ros2_stack/blob/036b23b2f91af70e1ca490e0c81660b6b17ae114/lbr_description/urdf/iiwa7/iiwa7_description.urdf.xacro#L289

StephanSchwarz96 commented 2 months ago

Hi @mhubii thanks for the reply! Right now I just bridged the internal PID control since my program ensures smooth motions, but it is good to know about having this additional option.

mhubii commented 2 months ago

okay I see @StephanSchwarz96 , did you remove the PID and re-compile? Thank you for the help.

May I ask if you launch app.launch.py or bringup.launch.py?

StephanSchwarz96 commented 2 months ago

Tbh I simply skipped the computation of the pid controller in:

void JointPIDArray::compute(const value_array_t& command_target, const double* state,
                            const std::chrono::nanoseconds& dt, value_array_t& command) {

  std::for_each(command.begin(), command.end(), [&, i = 0](double& command_i) mutable {
      command_i = command_target[i];
      // command_i += pid_controllers_[i].computeCommand(command_target[i] - state[i], dt.count());
      ++i;
  });
}

I tried to remove more of the existing pid controller structure for performance but had some issues (still working on it) and it worked by just passing my own command.

I launch app.launch.py.

mhubii commented 2 months ago

thank you for sharing