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) { diff --git a/application/robot_def.h b/application/robot_def.h index ef05828..d6f12aa 100644 --- a/application/robot_def.h +++ b/application/robot_def.h @@ -26,7 +26,7 @@ /* 机器人重要参数定义,注意根据不同机器人进行修改,浮点数需要以.0或f结尾,无符号以u结尾 */ // 云台参数 -#define YAW_CHASSIS_ALIGN_ECD 8015 // 云台和底盘对齐指向相同方向时的电机编码器值,若对云台有机械改动需要修改 +#define YAW_CHASSIS_ALIGN_ECD 8192 // 云台和底盘对齐指向相同方向时的电机编码器值,若对云台有机械改动需要修改 #define YAW_ECD_GREATER_THAN_4096 0 // ALIGN_ECD值是否大于4096,是为1,否为0;用于计算云台偏转角度 #define PITCH_HORIZON_ECD 3412 // 云台处于水平位置时编码器值,若对云台有机械改动需要修改 #define PITCH_MAX_ANGLE 0 // 云台竖直方向最大角度 (注意反馈如果是陀螺仪,则填写陀螺仪的角度)