Implement PIDController to Wheelbot (#1023)

This commit is contained in:
avinashc99 2020-07-09 16:31:37 -05:00 committed by GitHub
parent eaeb8118b1
commit 07030127f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -45,20 +45,20 @@ double PIDController::getOutput(double setpoint_value, double measured_value) {
// Sign Check // Sign Check
bool same_sign; bool same_sign;
if ((error * output) > 0.0) { if ((error * output) > 0.0) {
same_sign = 1; same_sign = true;
} else { } else {
same_sign = 0; same_sign = false;
} }
//Saturation Check //Saturation Check
bool output_limited; bool output_limited = false;
if (output > out_max) { if (output > out_max) {
output = out_max; output = out_max;
output_limited = 1; output_limited = true;
} }
if (output < out_min) { if (output < out_min) {
output = out_min; output = out_min;
output_limited = 1; output_limited = true;
} }
//AND Gate Check //AND Gate Check

View File

@ -27,10 +27,10 @@ DifferentialDriveController::
desiredHeadingRate(0.0), desiredHeadingRate(0.0),
// PID Controller Initialization // PID Controller Initialization
headingctrl(PIDController(1.0, 0.08, 0.5, headingRateLimit, headingctrl(1.0, 0.08, 0.5, headingRateLimit,
-headingRateLimit, 0.1, 0.1)), -headingRateLimit, 0.1, 0.1),
wheelspeedctrl(PIDController(1.0, 0.082, 0.5, wheelSpeedLimit, wheelspeedctrl(1.0, 0.082, 0.5, wheelSpeedLimit,
-wheelSpeedLimit, 0.1, 0.1)) -wheelSpeedLimit, 0.1, 0.1)
{ } { }
void DifferentialDriveController::stop() { void DifferentialDriveController::stop() {