From 6c81dbf9980a7936a6e39893605cdd7f8da6d87d Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Tue, 1 Jun 2021 16:17:52 +0200 Subject: [PATCH] drive: fix to accept tilt values in the [0,360] range --- src/motors_movement/drivecontroller.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/motors_movement/drivecontroller.cpp b/src/motors_movement/drivecontroller.cpp index a2aa010..65ba45e 100644 --- a/src/motors_movement/drivecontroller.cpp +++ b/src/motors_movement/drivecontroller.cpp @@ -94,8 +94,9 @@ void DriveController::drive(int dir, int speed, int tilt){ // Calculate position error relative to the 0 delta = CURRENT_DATA_READ.IMUAngle; if(delta > 180) delta = delta - 360; - input = delta; + + if(tilt > 180) tilt = tilt - 360; setpoint = tilt; if(pid->Compute()){