diff --git a/application/chassis/chassis.c b/application/chassis/chassis.c index 41b6e10..a4a260a 100644 --- a/application/chassis/chassis.c +++ b/application/chassis/chassis.c @@ -232,7 +232,7 @@ static void MinmizeRotation(float *angle, const float *last_angle, float *speed) while (norm_rotation < -180.0f) { norm_rotation += 360.0f; } - float threshold = 90.0f; + float threshold = 110.0f; float target_single=fmodf(target_angle,360.0f); if(target_single<0.0f) target_single+=360.0f; @@ -241,15 +241,15 @@ static void MinmizeRotation(float *angle, const float *last_angle, float *speed) if (fabsf(norm_rotation) > threshold) { - int32_t round_diff = (int32_t)(target_angle / 360.0f) - (int32_t)(actual_angle / 360.0f); + int32_t round_diff = (int32_t)((target_angle-actual_angle) / 360.0f); *angle = actual_angle + norm_rotation-180.0f+round_diff*360.0f; *speed = -(*speed); }else if(norm_rotation<-threshold){ - int32_t round_diff = (int32_t)(target_angle / 360.0f) - (int32_t)(actual_angle / 360.0f); + int32_t round_diff = (int32_t)((target_angle-actual_angle) / 360.0f); *angle = actual_angle + norm_rotation+180.0f+round_diff*360.0f; *speed = -(*speed); } - ANGLE_LIMIT_360_TO_180_ABS(*angle); + // ANGLE_LIMIT_360_TO_180_ABS(*angle); // float rotation = *angle - *last_angle; // ANGLE_LIMIT_360_TO_180_ABS(rotation); // if (rotation > 90) {