mirror of
https://gitee.com/dlmu-cone/half-steering-basic-framework
synced 2026-10-24 01:52:20 +08:00
new brench
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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°附近保持上次符号,避免来回跳变
|
||||
|
||||
Reference in New Issue
Block a user