Browse Source

修改变量名并修正陀螺仪逻辑

paint_robot_new-v1.5
Lizongdi 1 week ago
parent
commit
d748d34499
  1. 17
      RBcore/BHBF.c
  2. 12
      RBcore/TL720D.c
  3. 10
      project/paint_robot_new/paint_robot_new_motors.c

17
RBcore/BHBF.c

@ -55,7 +55,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
return;
}
static int iSpeed = -1; // 表示由RD1转换来的速度值
static int iVehicleSpeed = -1; // 表示由RD1转换来的速度值
int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理
switch (pstMsg->m_uiMsgID)
{
@ -67,20 +67,20 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
}
case RBCORE_CMD_MANUAL_FORWARD:
{
if (iSpeed >= 0)
if (iVehicleSpeed >= 0)
{
aiMotorSpeed[0] = iSpeed;
aiMotorSpeed[1] = iSpeed;
aiMotorSpeed[0] = iVehicleSpeed * 10;
aiMotorSpeed[1] = iVehicleSpeed * 10;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
break;
}
case RBCORE_CMD_MANUAL_BACKWARD:
{
if (iSpeed >= 0)
if (iVehicleSpeed >= 0)
{
aiMotorSpeed[0] = -iSpeed;
aiMotorSpeed[1] = -iSpeed;
aiMotorSpeed[0] = -iVehicleSpeed * 10;
aiMotorSpeed[1] = -iVehicleSpeed * 10;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
break;
@ -109,8 +109,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
{
if (pstMsg->m_uiDataLen >= sizeof(int))
{
RD_MEMCPY(&iSpeed, pstMsg->m_aucData, sizeof(int));
iSpeed *= 10;
RD_MEMCPY(&iVehicleSpeed, pstMsg->m_aucData, sizeof(int));
}
break;
}

12
RBcore/TL720D.c

@ -89,6 +89,12 @@ static int16_t getDeci(uint8_t *data)
static int check_TL720D(char *_pBuffer, uint32_t _iSize)
{
uint8_t check_sum = 0;
if (_pBuffer[0] != 0x68) return -1;
if (_pBuffer[1] != 0x1f) return -1;
if (_pBuffer[2] != 0x00) return -1;
if (_pBuffer[3] != 0x84) return -1;
for(uint8_t i = 1; i < 31; i++)
{
check_sum += (uint8_t)_pBuffer[i];
@ -99,11 +105,6 @@ static int check_TL720D(char *_pBuffer, uint32_t _iSize)
return 0;
}
if (_pBuffer[0] != 0x68) return -1;
if (_pBuffer[1] != 0x1f) return -1;
if (_pBuffer[2] != 0x00) return -1;
if (_pBuffer[3] != 0x84) return -1;
return 32;
}
@ -139,7 +140,6 @@ void Read_TL720D(void *argument)
while(1)
{
rd_ComRead(g_ptrs485_1, pcBuffer, 64);
Rd_Delay(1);
}
}

10
project/paint_robot_new/paint_robot_new_motors.c

@ -63,7 +63,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
return;
}
static int iSpeed = 1;
static int iVehicleSpeed = 1;
static uint32_t uiLastTime = 0;
switch (pstMsg->m_uiMsgID)
{
@ -101,7 +101,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
{
if (pstMsg->m_uiDataLen >= sizeof(int))
{
RD_MEMCPY(&iSpeed, pstMsg->m_aucData, sizeof(int));
RD_MEMCPY(&iVehicleSpeed, pstMsg->m_aucData, sizeof(int));
}
break;
}
@ -120,7 +120,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
if (1 == iIsDelayStop)
{
if (Rd_GetTime() - uiLastTime >= 600 * g_stCV.Paint_Gun_Shutdown_Distance / iSpeed)
if (Rd_GetTime() - uiLastTime >= 600 * g_stCV.Paint_Gun_Shutdown_Distance / iVehicleSpeed)
{
memset(g_aiMotorSpeed, 0, sizeof(g_aiMotorSpeed));
iIsDelayStop = 0;
@ -143,8 +143,8 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
}
case COMMON_CMD_SHOW_INFO:
{
lua_print("iSpeed = %d\nuiLastTime = %d\ng_isMotorInit = %d\ng_iLastVehicleMove = %d\n",
iSpeed, uiLastTime, g_isMotorInit, g_iLastVehicleMove);
lua_print("iVehicleSpeed = %d\nuiLastTime = %d\ng_isMotorInit = %d\ng_iLastVehicleMove = %d\n",
iVehicleSpeed, uiLastTime, g_isMotorInit, g_iLastVehicleMove);
break;
}
default:

Loading…
Cancel
Save