From baebe9bf561516a5fa6fb3c16b0d7cb614b2f92f Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Sun, 20 Sep 2026 15:05:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E5=8F=98?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RBcore/BHBF.c | 2 +- RBcore/client_setting.c | 4 ++-- RBcore/msp_PID.c | 5 +---- RBcore/msp_Timer.c | 6 +++--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/RBcore/BHBF.c b/RBcore/BHBF.c index 255870a..9902ea5 100644 --- a/RBcore/BHBF.c +++ b/RBcore/BHBF.c @@ -56,7 +56,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg) } static int iSpeed = -1; // 表示由RD1转换来的速度值 - static int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理 + int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理 switch (pstMsg->m_uiMsgID) { case RBCORE_CMD_STOP_ALL: diff --git a/RBcore/client_setting.c b/RBcore/client_setting.c index a6266d2..c5854a5 100644 --- a/RBcore/client_setting.c +++ b/RBcore/client_setting.c @@ -44,9 +44,7 @@ * 模块级变量 * *----------------------------------------------*/ static uint32_t g_uiIVModuleID = 0; -static PV_struct_define decoded_PV_variable = { 0 }; static PV_struct_define decoded_PV = { 0 }; -static IV_struct_define IV = { 0 }; static char g_IV_buffer[1024] = {0}; /*----------------------------------------------* * 常量定义 * @@ -74,6 +72,7 @@ int check_PV(char *_pBuffer, uint32_t _iSize) void decode_PV(const char *_pBuffer, uint32_t _iSize) { + PV_struct_define decoded_PV_variable = { 0 }; if (_pBuffer[2] == 0x01 && _pBuffer[3] == 0x01) //01 01 设置PV { pb_istream_t i_pv_stream; @@ -114,6 +113,7 @@ static void SendIV_ModuleHandler(const Msg_t *pstMsg) { case SENDIV_SET_IV: { + IV_struct_define IV = { 0 }; if (pstMsg->m_uiDataLen >= sizeof(IV)) { RD_MEMCPY(&IV, pstMsg->m_aucData, sizeof(IV)); diff --git a/RBcore/msp_PID.c b/RBcore/msp_PID.c index ed39f12..fb0d6ce 100644 --- a/RBcore/msp_PID.c +++ b/RBcore/msp_PID.c @@ -10,11 +10,7 @@ void Speedl_PID(double CurrentValue, double TargetValue, double Sys_T, double *Gain_speed); -double Desire_Angle = 0; -double PID_KP = 50; -double PID_KD = 12; //double Sys_T=0.01;//System time -double k_1_error = 0; /* PID @@ -62,6 +58,7 @@ double Angle_Tune_PID(double CurrentAngle, double TargetAngle, double Position_K int32_t PositionalPID(double pidTargetValue, double pidCurrentValue, double Kp, double Kd) { + static double k_1_error = 0; double Error = 0; double P_Error = 0; double D_Error = 0; diff --git a/RBcore/msp_Timer.c b/RBcore/msp_Timer.c index 1475da1..0e57f6e 100644 --- a/RBcore/msp_Timer.c +++ b/RBcore/msp_Timer.c @@ -58,7 +58,7 @@ static void Timer_ModuleHandler(const Msg_t *pstMsg) return; } - static int aiMotorSpeed[2] = {0}; + int aiMotorSpeed[2] = {0}; static int g_dletAngle = 0; //PID最终计算补偿值 static uint32_t uiLastSendTick = 0; //上一次时间戳,用于控制直线行驶距离 @@ -74,8 +74,8 @@ static void Timer_ModuleHandler(const Msg_t *pstMsg) break; } case TIMER_CMD_STRAIGHT_DRIVE: - { - static BHBF_straight_drive_Cmd stCmd = {0}; + { + BHBF_straight_drive_Cmd stCmd = {0}; if (pstMsg->m_uiDataLen >= sizeof(stCmd)) { if (1 == bstrgightfinish) // 这里换道完成认为第一步旋转已经完成不再根据计时卡状态