Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Commit b96dcd6

Browse files
Update upstream PID API (#395)
1 parent 507c2ad commit b96dcd6

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

gazebo_ros2_control/src/gazebo_system.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ bool GazeboSystem::extractPID(
240240
<< " max_integral_error = " << max_integral_error << "\t"
241241
<< "antiwindup =" << std::boolalpha << antiwindup);
242242

243-
pid.initPid(kp, ki, kd, max_integral_error, min_integral_error, antiwindup);
243+
pid.initialize(kp, ki, kd, max_integral_error, min_integral_error, antiwindup);
244244
}
245245
return are_pids_set;
246246
}
@@ -306,7 +306,7 @@ bool GazeboSystem::extractPIDFromParameters(
306306
<< " kd = " << kd << "\t"
307307
<< " max_integral_error = " << max_integral_error << "\t"
308308
<< "antiwindup =" << std::boolalpha << antiwindup << " from node parameters");
309-
pid.initPid(kp, ki, kd, max_integral_error, min_integral_error, antiwindup);
309+
pid.initialize(kp, ki, kd, max_integral_error, min_integral_error, antiwindup);
310310
}
311311

312312
return are_pids_set;
@@ -815,8 +815,6 @@ hardware_interface::return_type GazeboSystem::write(
815815
this->dataPtr->joint_position_[mimic_joint.mimicked_joint_index];
816816
}
817817

818-
uint64_t dt = sim_period.nanoseconds();
819-
820818
for (unsigned int j = 0; j < this->dataPtr->joint_names_.size(); j++) {
821819
if (this->dataPtr->sim_joints_[j]) {
822820
if (this->dataPtr->joint_control_methods_[j] & POSITION) {
@@ -833,13 +831,13 @@ hardware_interface::return_type GazeboSystem::write(
833831
} else if (this->dataPtr->joint_control_methods_[j] & VELOCITY_PID) {
834832
double vel_goal = this->dataPtr->joint_velocity_cmd_[j];
835833
double vel = this->dataPtr->sim_joints_[j]->GetVelocity(0);
836-
double cmd = this->dataPtr->vel_pid[j].computeCommand(vel_goal - vel, dt);
834+
double cmd = this->dataPtr->vel_pid[j].compute_command(vel_goal - vel, sim_period);
837835
this->dataPtr->sim_joints_[j]->SetForce(0, cmd);
838836

839837
} else if (this->dataPtr->joint_control_methods_[j] & POSITION_PID) {
840838
double pos_goal = this->dataPtr->joint_position_cmd_[j];
841839
double pos = this->dataPtr->sim_joints_[j]->Position(0);
842-
double cmd = this->dataPtr->pos_pid[j].computeCommand(pos_goal - pos, dt);
840+
double cmd = this->dataPtr->pos_pid[j].compute_command(pos_goal - pos, sim_period);
843841
this->dataPtr->sim_joints_[j]->SetForce(0, cmd);
844842

845843
} else if (this->dataPtr->is_joint_actuated_[j] && this->dataPtr->hold_joints_) {

0 commit comments

Comments
 (0)