mirror of
https://gitee.com/dlmu-cone/half-steering-basic-framework
synced 2026-10-23 17:42:20 +08:00
改动底盘最小运算角度
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user