From 7551a32b1317205a76f21aa7b100cb24f416f769 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Thu, 10 Sep 2026 09:22:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E4=BC=98=E5=8C=96=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RBcore/BHBF.c | 17 +++++++++++++- RBcore/client_setting.c | 2 +- RBcore/include/BHBF.h | 22 ++++++++++--------- motor/msp_motor_leisai.c | 4 ++-- project/paint_robot_new/paint_robot_new.c | 12 +++++----- .../paint_robot_new/paint_robot_new_motors.c | 2 +- 6 files changed, 38 insertions(+), 21 deletions(-) diff --git a/RBcore/BHBF.c b/RBcore/BHBF.c index 9004f98..fd945ac 100644 --- a/RBcore/BHBF.c +++ b/RBcore/BHBF.c @@ -59,7 +59,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg) static int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理 switch (pstMsg->m_uiMsgID) { - case RBCORE_CMD_STOP_ALL: + case COMMON_CMD_STOP_ALL: { MsgCenter_SendTo(MODULE_NAME_MOTOR, pstMsg->m_uiMsgID, NULL, 0); break; @@ -102,6 +102,21 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg) aiMotorSpeed[1] = -g_stCV.RightTurnSpeed; MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed)); } + break; + } + case RBCORE_CMD_VERTICAL: + { + + break; + } + case RBCORE_CMD_HORIZONTAL_LEFT: + { + + break; + } + case RBCORE_CMD_HORIZONTAL_RIGHT: + { + break; } case RBCORE_GET_VEHICLE_SPEED: diff --git a/RBcore/client_setting.c b/RBcore/client_setting.c index d66f2d4..17e5bd3 100644 --- a/RBcore/client_setting.c +++ b/RBcore/client_setting.c @@ -110,7 +110,7 @@ static void SendIV_ModuleHandler(const Msg_t *pstMsg) switch (pstMsg->m_uiMsgID) { - case CUSTOM_SET_IV: + case SENDIV_SET_IV: { if (pstMsg->m_uiDataLen >= sizeof(IV)) { diff --git a/RBcore/include/BHBF.h b/RBcore/include/BHBF.h index 5e216cc..5b50b1f 100644 --- a/RBcore/include/BHBF.h +++ b/RBcore/include/BHBF.h @@ -73,13 +73,12 @@ extern "C"{ #define MODULE_NAME_SENDIV "sendiv" typedef enum { - LUA_SHOW_INFO, - MOTOR_SET_SPEED, // 设置速度 - MOTOR_GET_SPEED, // 获取速度 - MOTOR_GET_FAULT_CODE, // 获取错误码 - MOTOR_CMD_END = 0x0100, + COMMON_CMD_SHOW_INFO, // 终端信息展示 + COMMON_CMD_STOP_ALL, // 机器人停止 + MOTOR_START = 0x0100, // *电机命令开始* + MOTOR_SET_SPEED, // 设置速度 + RBCORE_START = 0x0200, // *机器人共性命令开始* - RBCORE_CMD_STOP_ALL, // 机器人停止 RBCORE_CMD_MANUAL_FORWARD, // 机器人手动前进 RBCORE_CMD_MANUAL_BACKWARD, // 机器人手动后退 RBCORE_CMD_MANUAL_TURNLEFT, // 机器人手动左转 @@ -87,15 +86,18 @@ typedef enum { RBCORE_CMD_VERTICAL, // 机器人竖直前进(带PID) RBCORE_CMD_HORIZONTAL_LEFT, // 机器人水平向左(带PID) RBCORE_CMD_HORIZONTAL_RIGHT, // 机器人水平向右(带PID) - RBCORE_GET_VEHICLE_SPEED, // 获取机器人速度 - RBCORE_CMD_END = 0x0200, + RBCORE_GET_VEHICLE_SPEED, // 获取机器人速度(内部速度归一化) + CUSTOM_START = 0x0300, // *机器人特性命令开始* CUSTOM_GET_PV, // 获取PV - CUSTOM_SET_IV, // 设置IV CUSTOM_GET_MK32, // 获取MK32 CUSTOM_GET_TL720D_ROLL, // 获取陀螺仪横滚角 + CUSTOM_GET_SPEED, // 获取速度(电机回码) + CUSTOM_GET_FAULT_CODE, // 获取错误码(电机回码) CUSTOM_CMD_PAINTGUN, // 控制喷枪 - CUSTOM_CMD_END = 0x0300, + SENDIV_START = 0x0400, // *IV发送线程命令(一般低优先级事项也放到这)* + + SENDIV_SET_IV, // 设置IV } BHBF_Cmd_e; /*==============================================* diff --git a/motor/msp_motor_leisai.c b/motor/msp_motor_leisai.c index 2d5c418..a1da045 100644 --- a/motor/msp_motor_leisai.c +++ b/motor/msp_motor_leisai.c @@ -406,7 +406,7 @@ static int LeiSai_ParseResponse(Motor_Instance_t *pstMotor, const uint8_t *pucDa { pstMotor->m_eState = MOTOR_STATE_ERROR; } - MsgCenter_SendTo(MODULE_NAME_CUSTOM, MOTOR_GET_FAULT_CODE, uiFaultCode, sizeof(uiFaultCode)); + MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_FAULT_CODE, uiFaultCode, sizeof(uiFaultCode)); break; } case LEISAI_OD_VELOCITY_ACTUAL: @@ -418,7 +418,7 @@ static int LeiSai_ParseResponse(Motor_Instance_t *pstMotor, const uint8_t *pucDa | (pucData[7] << 24)); iRealVelocity[1] = MotorMgr_SpeedConvertex(pstMotor, iRealVelocity[0]); iRealVelocity[0] = pstMotor->m_stConfig.m_ucMotorID; - MsgCenter_SendTo(MODULE_NAME_CUSTOM, MOTOR_GET_SPEED, iRealVelocity, sizeof(iRealVelocity)); + MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_SPEED, iRealVelocity, sizeof(iRealVelocity)); log_d("iRealVelocity[1] = %d", iRealVelocity[1]); break; } diff --git a/project/paint_robot_new/paint_robot_new.c b/project/paint_robot_new/paint_robot_new.c index 7404224..512fb74 100644 --- a/project/paint_robot_new/paint_robot_new.c +++ b/project/paint_robot_new/paint_robot_new.c @@ -67,7 +67,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) switch (pstMsg->m_uiMsgID) { - case MOTOR_GET_FAULT_CODE: + case CUSTOM_GET_FAULT_CODE: { uint32_t uiFailtCode[2] = {0}; if (pstMsg->m_uiDataLen >= sizeof(uiFailtCode)) @@ -76,7 +76,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) } break; } - case MOTOR_GET_SPEED: + case CUSTOM_GET_SPEED: { int32_t iCurrentSpeed[2] = {0}; if (pstMsg->m_uiDataLen >= sizeof(iCurrentSpeed)) @@ -145,7 +145,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) if (abs(g_stMK32.CH2_LY_V) <= g_stCV.Joy_Sticker_Value_Allowance && abs(g_stMK32.CH3_LY_H) <= g_stCV.Joy_Sticker_Value_Allowance) { - MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STOP_ALL, NULL, 0); + MsgCenter_SendTo(MODULE_NAME_RBCORE, COMMON_CMD_STOP_ALL, NULL, 0); break; } @@ -169,11 +169,11 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) } else { - MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STOP_ALL, NULL, 0); + MsgCenter_SendTo(MODULE_NAME_RBCORE, COMMON_CMD_STOP_ALL, NULL, 0); } break; } - case LUA_SHOW_INFO: + case COMMON_CMD_SHOW_INFO: { lua_print("MK32 Info\nRxIndex:%d\tIsOnline:%d\n", g_stMK32.RxIndex, g_stMK32.IsOnline); lua_print("CH0_RY_H\t%d\n", g_stMK32.CH0_RY_H); @@ -214,7 +214,7 @@ void Custom_Task(void *argument) if ((int32_t)(uiNowTick - uiLastSendTick) >= IV_SEND_TIME) { uiLastSendTick = uiNowTick; - MsgCenter_SendTo(MODULE_NAME_SENDIV, CUSTOM_SET_IV, (void *)&g_stIV, sizeof(g_stIV)); + MsgCenter_SendTo(MODULE_NAME_SENDIV, SENDIV_SET_IV, (void *)&g_stIV, sizeof(g_stIV)); } } } diff --git a/project/paint_robot_new/paint_robot_new_motors.c b/project/paint_robot_new/paint_robot_new_motors.c index c9ef1f6..4e821ff 100644 --- a/project/paint_robot_new/paint_robot_new_motors.c +++ b/project/paint_robot_new/paint_robot_new_motors.c @@ -72,7 +72,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg) g_aiMotorSpeed[1] = MotorMgr_SpeedConvert(g_apstMotors[1], aiMotorSpeed[1]); break; } - case RBCORE_CMD_STOP_ALL: + case COMMON_CMD_STOP_ALL: { for (int i = 0; i < 2; i++) {