From ca4b5727d944c2eb3fb21941561662d75e6118cc Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Mon, 7 Sep 2026 15:08:06 +0800 Subject: [PATCH] =?UTF-8?q?IV=E4=B8=8A=E6=8A=A5=E9=9C=80=E8=A6=81=E5=9C=A8?= =?UTF-8?q?=E8=B0=83=E7=94=A8MsgCenter=5FSendTo=E4=BD=8D=E7=BD=AE=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E9=A2=91=E7=8E=87=EF=BC=8C=E8=80=8C=E4=B8=8D=E8=A6=81?= =?UTF-8?q?=E5=9C=A8=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E5=86=85=E5=BB=B6=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RBcore/client_setting.c | 1 - project/paint_robot_new/paint_robot_new.c | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/RBcore/client_setting.c b/RBcore/client_setting.c index 8777d33..82c3f4f 100644 --- a/RBcore/client_setting.c +++ b/RBcore/client_setting.c @@ -126,7 +126,6 @@ static void SendIV_ModuleHandler(const Msg_t *pstMsg) g_IV_buffer[IV_o_stream.bytes_written + 3] = crc & 0xff;; rd_ComSend(g_ptlpuart, g_IV_buffer, IV_o_stream.bytes_written + 4); - Rd_Delay(1000); } break; } diff --git a/project/paint_robot_new/paint_robot_new.c b/project/paint_robot_new/paint_robot_new.c index b626e1d..aecf95a 100644 --- a/project/paint_robot_new/paint_robot_new.c +++ b/project/paint_robot_new/paint_robot_new.c @@ -57,6 +57,8 @@ static IV_struct_define g_stIV; * 宏定义 * *----------------------------------------------*/ +#define IV_SEND_TIME 500 // IV上报周期(单位毫秒) + static void Custom_ModuleHandler(const Msg_t *pstMsg) { if (NULL == pstMsg) @@ -89,6 +91,15 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) RD_MEMCPY(&g_stMK32, pstMsg->m_aucData, sizeof(g_stMK32)); } + int iSpeedSelection = 3 * (g_stMK32.CH11_RD1 + 1000) / 200; + int iVehicleSpeed = 1; + if (iSpeedSelection > 0) + { + iVehicleSpeed = g_stCV.Speed_m_per_min*iSpeedSelection/30; + } + g_stIV.RobotMoveSpeed = iVehicleSpeed; + MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_GET_VEHICLE_SPEED, (void *)&iVehicleSpeed, sizeof(int)); + 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); @@ -151,10 +162,17 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) void Custom_Task(void *argument) { g_uiCustomModuleID = MsgCenter_Register(MODULE_NAME_CUSTOM, Custom_ModuleHandler); + uint32_t uiLastSendTick = Rd_GetTime(); while(1) { MsgCenter_ProcessWait(g_uiCustomModuleID, 2); - MsgCenter_SendTo(MODULE_NAME_SENDIV, CUSTOM_SET_IV, (void *)&g_stIV, sizeof(g_stIV)); + + uint32_t uiNowTick = Rd_GetTime(); + if ((int32_t)(uiNowTick - uiLastSendTick) >= IV_SEND_TIME) + { + uiLastSendTick = uiNowTick; + MsgCenter_SendTo(MODULE_NAME_SENDIV, CUSTOM_SET_IV, (void *)&g_stIV, sizeof(g_stIV)); + } } }