No p gain specified for pid (I want to use my custom controller gains)
Hello,
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: jointstatecontroller: type: jointstatecontroller/JointStateController publish_rate: 50
joint_position_controller:
type: my_position_controller/MyJointPositionController
joint:
- joint1
- joint2
kp:
- 10
- 10
kd:
- 1
- 1
ki:
- 0.1
- 0.1
mypositioncontroller/MyJointPositionController is using a positionjointinterface 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];
position_joint_handles_[i].setCommand(Out_[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!
Asked by mikell on 2023-01-30 05:24:07 UTC
Answers
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.
Asked by Mike Scheutzow on 2023-01-31 09:43:02 UTC
Comments