Browse Source

优化命令字

master
Lizongdi 12 hours ago
parent
commit
b336ce488f
  1. 8
      RBcore/BHBF.c
  2. 10
      RBcore/include/BHBF.h
  3. 4
      motor/msp_motor_leisai.c
  4. 4
      project/paint_robot_new/paint_robot_new.c
  5. 2
      project/paint_robot_new/paint_robot_new_motors.c

8
RBcore/BHBF.c

@ -70,7 +70,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
{ {
aiMotorSpeed[0] = iSpeed; aiMotorSpeed[0] = iSpeed;
aiMotorSpeed[1] = iSpeed; aiMotorSpeed[1] = iSpeed;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_CMD_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed)); MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
} }
break; break;
} }
@ -80,7 +80,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
{ {
aiMotorSpeed[0] = -iSpeed; aiMotorSpeed[0] = -iSpeed;
aiMotorSpeed[1] = -iSpeed; aiMotorSpeed[1] = -iSpeed;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_CMD_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed)); MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
} }
break; break;
} }
@ -90,7 +90,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
{ {
aiMotorSpeed[0] = -g_stCV.LeftTurnSpeed; aiMotorSpeed[0] = -g_stCV.LeftTurnSpeed;
aiMotorSpeed[1] = g_stCV.RightTurnSpeed; aiMotorSpeed[1] = g_stCV.RightTurnSpeed;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_CMD_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed)); MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
} }
break; break;
} }
@ -100,7 +100,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
{ {
aiMotorSpeed[0] = g_stCV.LeftTurnSpeed; aiMotorSpeed[0] = g_stCV.LeftTurnSpeed;
aiMotorSpeed[1] = -g_stCV.RightTurnSpeed; aiMotorSpeed[1] = -g_stCV.RightTurnSpeed;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_CMD_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed)); MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
} }
break; break;
} }

10
RBcore/include/BHBF.h

@ -75,13 +75,9 @@ extern "C"{
typedef enum { typedef enum {
LUA_SHOW_INFO, LUA_SHOW_INFO,
MOTOR_CMD_SET_SPEED, // 设置速度 MOTOR_SET_SPEED, // 设置速度
MOTOR_CMD_SET_POSITION, // 设置位置 MOTOR_GET_SPEED, // 获取速度
MOTOR_CMD_GET_SPEED, // 获取速度 MOTOR_GET_FAULT_CODE, // 获取错误码
MOTOR_CMD_GET_FAULT_CODE, // 获取错误码
MOTOR_CMD_SET_HOME, // 设置零点
MOTOR_CMD_SPEED_MODE, // 速度模式
MOTOR_CMD_POSITION_MODE, // 位置模式
MOTOR_CMD_END = 0x0100, MOTOR_CMD_END = 0x0100,
CMD_STOP_ALL, // 机器人停止 CMD_STOP_ALL, // 机器人停止

4
motor/msp_motor_leisai.c

@ -407,7 +407,7 @@ static int LeiSai_ParseResponse(Motor_Instance_t *pstMotor, const uint8_t *pucDa
{ {
pstMotor->m_eState = MOTOR_STATE_ERROR; pstMotor->m_eState = MOTOR_STATE_ERROR;
} }
MsgCenter_SendTo(MODULE_NAME_CUSTOM, MOTOR_CMD_GET_FAULT_CODE, uiFaultCode, sizeof(uiFaultCode)); MsgCenter_SendTo(MODULE_NAME_CUSTOM, MOTOR_GET_FAULT_CODE, uiFaultCode, sizeof(uiFaultCode));
break; break;
} }
case LEISAI_OD_VELOCITY_ACTUAL: case LEISAI_OD_VELOCITY_ACTUAL:
@ -419,7 +419,7 @@ static int LeiSai_ParseResponse(Motor_Instance_t *pstMotor, const uint8_t *pucDa
| (pucData[7] << 24)); | (pucData[7] << 24));
iRealVelocity[1] = MotorMgr_SpeedConvertex(pstMotor, iRealVelocity[0]); iRealVelocity[1] = MotorMgr_SpeedConvertex(pstMotor, iRealVelocity[0]);
iRealVelocity[0] = pstMotor->m_stConfig.m_ucMotorID; iRealVelocity[0] = pstMotor->m_stConfig.m_ucMotorID;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, MOTOR_CMD_GET_SPEED, iRealVelocity, sizeof(iRealVelocity)); MsgCenter_SendTo(MODULE_NAME_CUSTOM, MOTOR_GET_SPEED, iRealVelocity, sizeof(iRealVelocity));
log_d("iRealVelocity[1] = %d", iRealVelocity[1]); log_d("iRealVelocity[1] = %d", iRealVelocity[1]);
break; break;
} }

4
project/paint_robot_new/paint_robot_new.c

@ -67,7 +67,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
switch (pstMsg->m_uiMsgID) switch (pstMsg->m_uiMsgID)
{ {
case MOTOR_CMD_GET_FAULT_CODE: case MOTOR_GET_FAULT_CODE:
{ {
uint32_t uiFailtCode[2] = {0}; uint32_t uiFailtCode[2] = {0};
if (pstMsg->m_uiDataLen >= sizeof(uiFailtCode)) if (pstMsg->m_uiDataLen >= sizeof(uiFailtCode))
@ -76,7 +76,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
} }
break; break;
} }
case MOTOR_CMD_GET_SPEED: case MOTOR_GET_SPEED:
{ {
int32_t iCurrentSpeed[2] = {0}; int32_t iCurrentSpeed[2] = {0};
if (pstMsg->m_uiDataLen >= sizeof(iCurrentSpeed)) if (pstMsg->m_uiDataLen >= sizeof(iCurrentSpeed))

2
project/paint_robot_new/paint_robot_new_motors.c

@ -61,7 +61,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
switch (pstMsg->m_uiMsgID) switch (pstMsg->m_uiMsgID)
{ {
case MOTOR_CMD_SET_SPEED: case MOTOR_SET_SPEED:
{ {
int aiMotorSpeed[2] = {0}; int aiMotorSpeed[2] = {0};
if (pstMsg->m_uiDataLen >= sizeof(aiMotorSpeed)) if (pstMsg->m_uiDataLen >= sizeof(aiMotorSpeed))

Loading…
Cancel
Save