ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

No p gain specified for pid (I want to use my custom controller gains)

asked 2023-01-30 04:24:07 -0500

mikell gravatar image


I know there are many questions about this error specifically but I dont find a solution when it comes to use a custom controller: I created my custom controller with PID parameters to tune (the logic is that I want to do some tests before I change some parameters). Here is my config file:

rrbot: joint_state_controller: type: joint_state_controller/JointStateController publish_rate: 50

    type: my_position_controller/MyJointPositionController
        - joint1
        - joint2
      - 10
      - 10
      - 1
      - 1
      - 0.1
      - 0.1

my_position_controller/MyJointPositionController is using a position_joint_interface and the idea is to use my own gain parameters to configure the position control. This is the code of the update loop into the control.cpp

void MyJointPositionController::update(const ros::Time& time,
                                            const ros::Duration& period) {
  delta_time += period;
  std::array<double, 2> Out_{};

  for (size_t i = 0; i < 2; ++i) {
    // compute position error
      current_pos_[i] = position_joint_handles_[i].getPosition();
      errorpos_[i] = command_position_[i] - current_pos_[i];

      // P term
      P_[i] = (errorpos_[i] * kp_[i]);

      // I term
      integral_[i] = integral_[i] + (errorpos_[i] * delta_time.toSec());
      I_[i] = ki_[i] * integral_[i];

      //D term
      derivative_[i] = errorpos_[i] / delta_time.toSec();
      D_[i] = kd_[i] * derivative_[i];

      Out_[i] = P_[i] + I_[i] + D_[i];


where kp_, kd_ and ki_ were declared in the initialization of the class.

My problem is, I launch my robot into gazebo (only the robot, not the controllers) and this error appears:

[ERROR] [1675072396.556337077, 0.170000000]: No p gain specified for pid.  Namespace: /rrbot/gazebo_ros_control/pid_gains/joint1
[ERROR] [1675072396.556816165, 0.170000000]: No p gain specified for pid.  Namespace: /rrbot/gazebo_ros_control/pid_gains/joint2

I have seen here that is not an actual error rather than a warning and if no PID gains are found gazebo will control my robot with "joint->SetAngle() or // joint->SetParam("vel") to control the joint."

There is a way to say gazebo not to use anything? like leave the robot with no controllers until I load my own controller? Cause if try to load my own controller I have the following error and I dont know if this is realted to the previous one:

WARN] [1675071221.798537, 21.885000]: Controller Spawner error while taking down controllers: unable to connect to service: [Errno 111] Connection refused
[rrbot/controller_spawner-1] process has died [pid 17418, exit code 1, cmd /opt/ros/noetic/lib/controller_manager/spawner joint_state_controller joint_position_controller __name:=controller_spawner __log:=/home/mikel/.ros/log/fef4f1fa-a080-11ed-9a6b-354ed0b55da0/rrbot-controller_spawner-1.log].
log file: /home/mikel/.ros/log/fef4f1fa-a080-11ed-9a6b-354ed0b55da0/rrbot-controller_spawner-1*.log

Hope can someone throw me light on this issue cause I dont understand my second error and I'm stuck.

Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-01-31 08:43:02 -0500

Mike Scheutzow gravatar image

No p gain specified for pid. Namespace: /rrbot/gazebo_ros_control/pid_gains/joint1

This was previously discussed in question #q293830.

The way I interpret skyofyao's answer is that for some types of controllers RobotHwSim will introduce another PID loop, and this PID is intended to help model the behavior of the motor that drives the joint. This pid_gains parameter is giving you the opportunity to describe how the motor model reacts to an input that exceeds its ability, for example if a full-scale step function is input.

This is different from the PID loop in your MyPositionJointController, which is modulating the control input sent to the motor. It's very possible that this control input asks the motor to do something it can not.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2023-01-30 04:24:07 -0500

Seen: 117 times

Last updated: Jan 31