From 3dbc0a7b0a68ed73b583813001c09f3591367e8c Mon Sep 17 00:00:00 2001 From: NeoZng Date: Wed, 14 Dec 2022 17:15:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DHT=E7=94=B5=E6=9C=BA=E8=A7=A3?= =?UTF-8?q?=E7=AE=97bug=EF=BC=8C=E5=BE=85=E6=B7=BB=E5=8A=A0=E9=9B=B6?= =?UTF-8?q?=E4=BD=8D=E6=A0=A1=E5=87=86=E3=80=82=E4=BF=AE=E5=A4=8Dbsp=5Fcan?= =?UTF-8?q?=20module=20id=E6=9C=AA=E5=88=9D=E5=A7=8B=E5=8C=96=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 8 +++++++- application/robot_def.h | 20 ++++++++++---------- bsp/bsp_can.c | 1 + modules/algorithm/controller.h | 2 +- modules/master_machine/master_process.h | 7 ++++--- modules/motor/HT04.c | 6 +++--- modules/motor/motor_def.h | 13 +++++++------ 7 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7516960..10ac569 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -42,7 +42,13 @@ "quaternionekf.h": "c", "shoot.h": "c", "lk9025.h": "c", - "ht04.h": "c" + "ht04.h": "c", + "rtc.h": "c", + "tim.h": "c", + "usb_device.h": "c", + "gpio.h": "c", + "rng.h": "c", + "cmsis_os.h": "c" }, "C_Cpp.default.configurationProvider": "ms-vscode.makefile-tools", "C_Cpp.intelliSenseEngineFallback": "enabled", diff --git a/application/robot_def.h b/application/robot_def.h index 5d97123..af9b547 100644 --- a/application/robot_def.h +++ b/application/robot_def.h @@ -55,14 +55,14 @@ // 机器人状态 typedef enum { - ROBOT_STOP, + ROBOT_STOP=0, ROBOT_READY, } Robot_Status_e; // 应用状态 typedef enum { - APP_OFFLINE, + APP_OFFLINE=0, APP_ONLINE, APP_ERROR, } App_Status_e; @@ -74,7 +74,7 @@ typedef enum */ typedef enum { - CHASSIS_ZERO_FORCE, // 电流零输入 + CHASSIS_ZERO_FORCE=0, // 电流零输入 CHASSIS_ROTATE, // 小陀螺模式 CHASSIS_NO_FOLLOW, // 不跟随,允许全向平移 CHASSIS_FOLLOW_GIMBAL_YAW, // 跟随模式,底盘叠加角度环控制 @@ -83,7 +83,7 @@ typedef enum // 云台模式设置 typedef enum { - GIMBAL_ZERO_FORCE, // 电流零输入 + GIMBAL_ZERO_FORCE=0, // 电流零输入 GIMBAL_FREE_MODE, // 云台自由运动模式,即与底盘分离(底盘此时应为NO_FOLLOW)反馈值为电机total_angle;似乎可以改为全部用IMU数据? GIMBAL_GYRO_MODE, // 云台陀螺仪反馈模式,反馈值为陀螺仪pitch,total_yaw_angle,底盘可以为小陀螺和跟随模式 } gimbal_mode_e; @@ -91,24 +91,24 @@ typedef enum // 发射模式设置 typedef enum { - SHOOT_ON = 0, - SHOOT_OFF, + SHOOT_OFF = 0, + SHOOT_ON, } shoot_mode_e; typedef enum { - FRICTION_OFF, // 摩擦轮关闭 + FRICTION_OFF=0, // 摩擦轮关闭 FRICTION_ON, // 摩擦轮开启 } friction_mode_e; typedef enum { - LID_CLOSE, // 弹舱盖打开 - LID_OPEN, // 弹舱盖关闭 + LID_OPEN=0, // 弹舱盖打开 + LID_CLOSE, // 弹舱盖关闭 } lid_mode_e; typedef enum { - LOAD_STOP, // 停止发射 + LOAD_STOP=0, // 停止发射 LOAD_REVERSE, // 反转 LOAD_1_BULLET, // 单发 LOAD_3_BULLET, // 三发 diff --git a/bsp/bsp_can.c b/bsp/bsp_can.c index f018026..930cf47 100644 --- a/bsp/bsp_can.c +++ b/bsp/bsp_can.c @@ -79,6 +79,7 @@ CANInstance *CANRegister(CAN_Init_Config_s *config) instance[idx]->tx_id = config->tx_id; // 好像没用,可以删掉 instance[idx]->rx_id = config->rx_id; instance[idx]->can_module_callback = config->can_module_callback; + instance[idx]->id=config->id; CANAddFilter(instance[idx]); // 添加CAN过滤器规则 return instance[idx++]; // 返回指针 diff --git a/modules/algorithm/controller.h b/modules/algorithm/controller.h index 853ccfd..42aff66 100644 --- a/modules/algorithm/controller.h +++ b/modules/algorithm/controller.h @@ -28,7 +28,7 @@ // PID 优化环节使能标志位 typedef enum { - NONE = 0b00000000, // 0000 0000 + PID_IMPROVE_NONE = 0b00000000, // 0000 0000 Integral_Limit = 0b00000001, // 0000 0001 Derivative_On_Measurement = 0b00000010, // 0000 0010 Trapezoid_Intergral = 0b00000100, // 0000 0100 diff --git a/modules/master_machine/master_process.h b/modules/master_machine/master_process.h index 4bc5c03..efb25da 100644 --- a/modules/master_machine/master_process.h +++ b/modules/master_machine/master_process.h @@ -52,13 +52,14 @@ typedef enum typedef enum { - MODE_AIM = 0, - MODE_SMALL_BUFF = 1, - MODE_BIG_BUFF = 2 + VISION_MODE_AIM = 0, + VISION_MODE_SMALL_BUFF = 1, + VISION_MODE_BIG_BUFF = 2 } Work_Mode_e; typedef enum { + BULLET_SPEED_NONE = 0, BIG_AMU_10 = 10, SMALL_AMU_15 = 15, BIG_AMU_16 = 16, diff --git a/modules/motor/HT04.c b/modules/motor/HT04.c index 7eb249a..5172eff 100644 --- a/modules/motor/HT04.c +++ b/modules/motor/HT04.c @@ -50,14 +50,14 @@ static void HTMotorDecode(CANInstance *motor_can) measure->last_angle = measure->total_angle; tmp = (uint16_t)((rxbuff[1] << 8) | rxbuff[2]); - measure->total_angle = RAD_2_ANGLE * uint_to_float(tmp, P_MAX, P_MIN, 16); + measure->total_angle = RAD_2_ANGLE * uint_to_float(tmp, P_MIN, P_MAX, 16); tmp = (uint16_t)((rxbuff[3] << 4) | (rxbuff[4] >> 4)); - measure->speed_aps = RAD_2_ANGLE * SPEED_SMOOTH_COEF * uint_to_float(tmp, V_MAX, V_MIN, 12) + + measure->speed_aps = RAD_2_ANGLE * SPEED_SMOOTH_COEF * uint_to_float(tmp, V_MIN, V_MAX, 12) + (1 - SPEED_SMOOTH_COEF) * measure->speed_aps; tmp = (uint16_t)(((rxbuff[4] & 0x0f) << 8) | rxbuff[5]); - measure->real_current = CURRENT_SMOOTH_COEF * uint_to_float(tmp, T_MAX, T_MIN, 12) + + measure->real_current = CURRENT_SMOOTH_COEF * uint_to_float(tmp, T_MIN, T_MAX, 12) + (1 - CURRENT_SMOOTH_COEF) * measure->real_current; } diff --git a/modules/motor/motor_def.h b/modules/motor/motor_def.h index 04ebaa1..bbe4ea2 100644 --- a/modules/motor/motor_def.h +++ b/modules/motor/motor_def.h @@ -45,7 +45,7 @@ typedef enum /* 反馈来源设定,若设为OTHER_FEED则需要指定数据来源指针,详见Motor_Controller_s*/ typedef enum { - MOTOR_FEED, + MOTOR_FEED=0, OTHER_FEED, } Feedback_Source_e; @@ -94,11 +94,12 @@ typedef struct /* 电机类型枚举 */ typedef enum { - GM6020 = 0, - M3508 = 1, - M2006 = 2, - LK9025 = 3, - HT04 = 4, + MOTOR_TYPE_NONE = 0, + GM6020, + M3508, + M2006, + LK9025, + HT04, } Motor_Type_e; /**