改动底盘最小运算角度

This commit is contained in:
fcl
2026-01-17 14:34:46 +08:00
parent 352d085334
commit 3fc78a8fcd

View File

@@ -232,7 +232,7 @@ static void MinmizeRotation(float *angle, const float *last_angle, float *speed)
while (norm_rotation < -180.0f) { while (norm_rotation < -180.0f) {
norm_rotation += 360.0f; norm_rotation += 360.0f;
} }
float threshold = 90.0f; float threshold = 110.0f;
float target_single=fmodf(target_angle,360.0f); float target_single=fmodf(target_angle,360.0f);
if(target_single<0.0f) target_single+=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) { 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; *angle = actual_angle + norm_rotation-180.0f+round_diff*360.0f;
*speed = -(*speed); *speed = -(*speed);
}else if(norm_rotation<-threshold){ }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; *angle = actual_angle + norm_rotation+180.0f+round_diff*360.0f;
*speed = -(*speed); *speed = -(*speed);
} }
ANGLE_LIMIT_360_TO_180_ABS(*angle); // ANGLE_LIMIT_360_TO_180_ABS(*angle);
// float rotation = *angle - *last_angle; // float rotation = *angle - *last_angle;
// ANGLE_LIMIT_360_TO_180_ABS(rotation); // ANGLE_LIMIT_360_TO_180_ABS(rotation);
// if (rotation > 90) { // if (rotation > 90) {