From 26f210da124cee42bc01295f31fea504cee3e56d Mon Sep 17 00:00:00 2001 From: Zorua <3540226929@qq.com> Date: Sat, 17 Jan 2026 17:43:42 +0800 Subject: [PATCH] new brench --- application/chassis/chassis.c | 5 ++--- application/cmd/robot_cmd.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/application/chassis/chassis.c b/application/chassis/chassis.c index a4a260a..ccef766 100644 --- a/application/chassis/chassis.c +++ b/application/chassis/chassis.c @@ -240,7 +240,7 @@ static void MinmizeRotation(float *angle, const float *last_angle, float *speed) if(current_single<0.0f) current_single+=360.0f; - if (fabsf(norm_rotation) > threshold) { + if (norm_rotation > threshold) { 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); @@ -386,8 +386,8 @@ void ChassisTask() chassis_cmd_recv.wz = 0; break; case CHASSIS_FOLLOW_GIMBAL_YAW: // 跟随云台,不单独设置pid,以误差角度平方为速度输出 + // float single_round_offset = chassis_cmd_recv.offset_angle; float single_round_offset = chassis_cmd_recv.offset_angle; - // float single_round_offset = fmodf(chassis_cmd_recv.offset_angle, 360.0f); if(single_round_offset > 180.0f) { single_round_offset -= 360.0f; @@ -395,7 +395,6 @@ void ChassisTask() else if(single_round_offset < -180.0f) { single_round_offset += 360.0f; - } chassis_cmd_recv.wz = PIDCalculate(&chassis_follow_pid, single_round_offset, 0)/100; // chassis_cmd_recv.wz = PIDCalculate(&chassis_follow_pid, chassis_cmd_recv.offset_angle, 0)/100; diff --git a/application/cmd/robot_cmd.c b/application/cmd/robot_cmd.c index df058e1..b130af5 100644 --- a/application/cmd/robot_cmd.c +++ b/application/cmd/robot_cmd.c @@ -93,7 +93,7 @@ static void CalcOffsetAngle() new_offset -= 360.0f; else if (angle_diff < -180.0f) new_offset += 360.0f; - chassis_cmd_send .offset_angle = last_offset_angle *(1.0f - smooth_factor) + new_offset * smooth_factor; + chassis_cmd_send.offset_angle = last_offset_angle *(1.0f - smooth_factor) + new_offset * smooth_factor; last_offset_angle = chassis_cmd_send.offset_angle; // static float angle; // static float last_diff = 0.0f; // 用于在±180°附近保持上次符号,避免来回跳变