From a3e0cb1a87f2f2b654e4f5841da582105b11ddd8 Mon Sep 17 00:00:00 2001 From: zcj <2487150395@qq.com> Date: Thu, 16 May 2024 01:53:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=82=AE=E5=8F=B0=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=9C=BA?= =?UTF-8?q?=E6=A2=B0=E6=94=B9=E5=A4=B4=EF=BC=8C=E8=B0=83=E6=95=B4=E4=B8=80?= =?UTF-8?q?=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/chassis/chassis.c | 2 ++ application/cmd/robot_cmd.c | 24 +++++++++++++++++++----- application/gimbal/gimbal.c | 6 +++--- application/robot_def.h | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/application/chassis/chassis.c b/application/chassis/chassis.c index f556d89..4bfc4a7 100644 --- a/application/chassis/chassis.c +++ b/application/chassis/chassis.c @@ -285,10 +285,12 @@ void ChassisTask() chassis_cmd_recv.wz = 4500; if(chassis_cmd_recv.wz < -4500) chassis_cmd_recv.wz = -4500; + break; case CHASSIS_FIXED: chassis_cmd_recv.vx=0; chassis_cmd_recv.vy=0; chassis_cmd_recv.wz = 0; + break; default: break; diff --git a/application/cmd/robot_cmd.c b/application/cmd/robot_cmd.c index f581311..ae2be56 100644 --- a/application/cmd/robot_cmd.c +++ b/application/cmd/robot_cmd.c @@ -310,9 +310,18 @@ static void MouseKeySet() { chassis_cmd_send.vx = rc_data[TEMP].key[KEY_PRESS].a * 60000 - rc_data[TEMP].key[KEY_PRESS].d * 60000; // 系数待测 chassis_cmd_send.vy = rc_data[TEMP].key[KEY_PRESS].w * 60000 - rc_data[TEMP].key[KEY_PRESS].s * 60000; + switch (rc_data[TEMP].key_count[KEY_PRESS][Key_Q] % 2) + { + case 0: + gimbal_cmd_send.yaw -= (float)rc_data[TEMP].mouse.x / 660; // 系数待测 + gimbal_cmd_send.pitch += (float)rc_data[TEMP].mouse.y / 660; + break; + case 1 : + gimbal_cmd_send.yaw -= (float)rc_data[TEMP].mouse.x / 660 * 3; // 系数待测 + gimbal_cmd_send.pitch += (float)rc_data[TEMP].mouse.y / 660 * 3; + break; + } - gimbal_cmd_send.yaw -= (float)rc_data[TEMP].mouse.x / 660 * 9; // 系数待测 - gimbal_cmd_send.pitch += (float)rc_data[TEMP].mouse.y / 660 *5 ; aim_select.suggest_fire = 0; if (rc_data[TEMP].mouse.press_l && (!rc_data[TEMP].mouse.press_r)) // 左键发射模式 @@ -407,14 +416,19 @@ static void MouseKeySet() { case 0: chassis_cmd_send.chassis_mode = CHASSIS_FOLLOW_GIMBAL_YAW; - gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE; break; default: chassis_cmd_send.chassis_mode = CHASSIS_ROTATE; - gimbal_cmd_send.gimbal_mode = GIMBAL_GYRO_MODE; break; } - switch (rc_data[TEMP].key[KEY_PRESS].shift) // V键开启连发// + switch (rc_data[TEMP].key[KEY_PRESS].z) // Z键开关吊射模式 + { + case 1: + chassis_cmd_send.chassis_mode = CHASSIS_VERTICAL_YAW; + //chassis_cmd_send.vx=chassis_cmd_send.vy=0; //吊射时底盘不动 + break; + } + switch (rc_data[TEMP].key[KEY_PRESS].shift) //shift开关超电// { case 0: chassis_cmd_send.P_SuperCap=0; diff --git a/application/gimbal/gimbal.c b/application/gimbal/gimbal.c index f584aa0..e866141 100644 --- a/application/gimbal/gimbal.c +++ b/application/gimbal/gimbal.c @@ -66,15 +66,15 @@ void GimbalInit() }, .controller_param_init_config = { .angle_PID = { - .Kp = 0.35f,//20, // 65 + .Kp = 0.35f, .Ki = 0, - .Kd = 0.005f,//1, + .Kd = 0.005f, .Improve = PID_Trapezoid_Intergral | PID_Integral_Limit | PID_Derivative_On_Measurement, .IntegralLimit = 100,//100 .MaxOut = 500,//500 }, .speed_PID = { - .Kp = 6000,//11000, // 50 + .Kp = 6000, .Ki = 1000, // 350 .Kd = 0,//15000, // 0 .Improve = PID_Trapezoid_Intergral | PID_Integral_Limit | PID_Derivative_On_Measurement, diff --git a/application/robot_def.h b/application/robot_def.h index 668af13..d79330c 100644 --- a/application/robot_def.h +++ b/application/robot_def.h @@ -26,7 +26,7 @@ /* 机器人重要参数定义,注意根据不同机器人进行修改,浮点数需要以.0或f结尾,无符号以u结尾 */ // 云台参数 -#define YAW_CHASSIS_ALIGN_ECD 3.641593 // 云台和底盘对齐指向相同方向时的电机position值,需要加上PI,因为单圈角度计算里增加了PI若对云台有机械改动需要修改 +#define YAW_CHASSIS_ALIGN_ECD 5.482276 // 云台和底盘对齐指向相同方向时的电机position值,需要加上PI,因为单圈角度计算里增加了PI若对云台有机械改动需要修改 #define YAW_ECD_GREATER_THAN_4096 0 // ALIGN_ECD值是否大于4096,是为1,否为0;用于计算云台偏转角度 #define PITCH_HORIZON_ECD 3412 // 云台处于水平位置时编码器值,若对云台有机械改动需要修改 #define PITCH_MAX_ANGLE 13 // 云台竖直方向最大角度 (注意反馈如果是陀螺仪,则填写陀螺仪的角度)