Browse Source

优化部分变量

paint_robot_new-v1.5
Lizongdi 1 week ago
parent
commit
baebe9bf56
  1. 2
      RBcore/BHBF.c
  2. 4
      RBcore/client_setting.c
  3. 5
      RBcore/msp_PID.c
  4. 4
      RBcore/msp_Timer.c

2
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:

4
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));

5
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;

4
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; //上一次时间戳,用于控制直线行驶距离
@ -75,7 +75,7 @@ static void Timer_ModuleHandler(const Msg_t *pstMsg)
}
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) // 这里换道完成认为第一步旋转已经完成不再根据计时卡状态

Loading…
Cancel
Save