Browse Source

BHBF.h命名采取功能维度

master
Lizongdi 2 weeks ago
parent
commit
d99c4090d7
  1. 20
      RBcore/BHBF.c
  2. 2
      RBcore/TL720D.c
  3. 4
      RBcore/client_setting.c
  4. 4
      RBcore/daemon_task.c
  5. 52
      RBcore/include/BHBF.h
  6. 14
      RBcore/msp_Timer.c
  7. 16
      README.md
  8. 4
      controller/msp_MK32.c
  9. 4
      motor/msp_motor_leisai.c
  10. 130
      project/paint_robot_new/paint_robot_new.c
  11. 18
      project/paint_robot_new/paint_robot_new_motors.c

20
RBcore/BHBF.c

@ -64,19 +64,19 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
static int bTimerStarted = 0; //直线行驶距离单次触发标志
switch (pstMsg->m_uiMsgID)
{
case RBCORE_CMD_STOP_ALL:
case CMD_STOP_ALL:
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_STOP, NULL, 0);
break;
}
case TIMER_CMD_RESET_STRAIGHT:
case RESET_STRAIGHT_DRIVE:
{
uiLastSendTick = 0;
bTimerStarted = 0;
break;
}
case TIMER_CMD_STRAIGHT_DRIVE:
case CMD_STRAIGHT_DRIVE:
{
BHBF_straight_drive_Cmd stCmd = {0};
if (pstMsg->m_uiDataLen >= sizeof(stCmd))
@ -129,13 +129,13 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
{
aiMotorSpeed[0] = 0;
aiMotorSpeed[1] = 0;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_STRAIGHT_DRIVE, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_STRAIGHT_DRIVE_FINISH, NULL, 0);
}
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
break;
}
case TIMER_CMD_TURN_ANGLE:
case CMD_TURN_ANGLE:
{
int iTargetAngle = 0;
if (pstMsg->m_uiDataLen >= sizeof(int))
@ -146,7 +146,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
{
aiMotorSpeed[0] = 0;
aiMotorSpeed[1] = 0;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_TURN_ANGLE, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_TURN_ANGLE_FINISH, NULL, 0);
}
else if (abs(g_RF_Angle_Roll - iTargetAngle) <= 1000)
{
@ -160,7 +160,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg)
aiMotorSpeed[0] = -g_dletAngle ;
aiMotorSpeed[1] = g_dletAngle ;
}
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
break;
}

2
RBcore/TL720D.c

@ -128,7 +128,7 @@ static void decode_TL720D(const char *buf, uint32_t _iSize)
if ((int32_t)(uiNowTick - uiLastSendTick) >= 50)
{
uiLastSendTick = uiNowTick;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_TL720D_ROLL, (void *)&g_stTL720D.RF_Angle_Roll, sizeof(int32_t));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, GET_TL720D_ROLL, (void *)&g_stTL720D.RF_Angle_Roll, sizeof(int32_t));
MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_TL720D, NULL, 0);
}
}

4
RBcore/client_setting.c

@ -85,7 +85,7 @@ void decode_PV(const char *_pBuffer, uint32_t _iSize)
MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_MK32_SERIAL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_MK32_UDP, NULL, 0);// udp还没实现这里先防止报错
decoded_PV=decoded_PV_variable;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_PV, (void *)&decoded_PV, sizeof(decoded_PV));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, GET_PV, (void *)&decoded_PV, sizeof(decoded_PV));
}
}
else if (*(_pBuffer + 2) == 0x02 && *(_pBuffer + 3) == 0x01) //设置PV
@ -111,7 +111,7 @@ static void SendIV_ModuleHandler(const Msg_t *pstMsg)
switch (pstMsg->m_uiMsgID)
{
case SENDIV_SET_IV:
case CMD_SEND_IV:
{
IV_struct_define IV = { 0 };
if (pstMsg->m_uiDataLen >= sizeof(IV))

4
RBcore/daemon_task.c

@ -98,7 +98,7 @@ void daemon_PollComError(void)
if ((int32_t)(uiNowTick - uiLastSendTick) >= 1000)
{
uiLastSendTick = uiNowTick;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_DAEMON_CODE, &g_iCom_Error_Status, sizeof(int32_t));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, GET_DAEMON_CODE, &g_iCom_Error_Status, sizeof(int32_t));
}
}
else
@ -109,7 +109,7 @@ void daemon_PollComError(void)
{
SET_BIT_1(&g_iCom_Error_Status, i); // 判定模块异常
g_auiComErrorCount[i] = COM_ERROR_TIMEOUT_THRESHOLD; // 计数封顶,避免溢出
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_DAEMON_CODE, &g_iCom_Error_Status, sizeof(int32_t));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, GET_DAEMON_CODE, &g_iCom_Error_Status, sizeof(int32_t));
}
}
}

52
RBcore/include/BHBF.h

@ -76,30 +76,29 @@ extern "C"{
typedef enum {
CMD_SHOW_INFO, // 终端信息展示
CMD_STOP_ALL, // 机器人停止(建议各个控制硬件的模块都要实现)
GET_VEHICLE_SPEED, // 获取机器人速度(内部速度归一化)
MOTOR_SET_SPEED, // 设置速度
MOTOR_POWER_ENABLE, // 电机上电
MOTOR_POWER_DISABLE, // 电机失电
MOTOR_CMD_STOP_AFTER, // 先关枪后停车
RBCORE_CMD_STOP_ALL, // 此命令统一调用机器人各个模块的COMMON_CMD_STOP_ALL
CUSTOM_GET_PV, // 获取PV
CUSTOM_GET_MK32, // 获取MK32
CUSTOM_GET_TL720D_ROLL, // 获取陀螺仪横滚角(IV显示)
CUSTOM_GET_SPEED, // 获取速度(电机回码)
CUSTOM_GET_FAULT_CODE, // 获取错误码(电机回码)
CUSTOM_GET_DAEMON_CODE, // 获取daemon错误码
CUSTOM_GET_MOTOR_OK, // 获取电机初始化完毕
CUSTOM_CMD_PAINTGUN, // 控制喷枪
CUSTOM_CMD_STRAIGHT_DRIVE, // RBCORE_CMD_STRAIGHT_DRIVE命令停止后回调
CUSTOM_CMD_TURN_ANGLE, // RBCORE_CMD_TURN_ANGLE命令停止后回调
CUSTOM_SET_STOP_OFF_PAINT, // 停车关枪标志位置1
CUSTOM_RESET_PAINT, // 停车关枪逻辑中用于重置开枪状态
SENDIV_START = 0x0400, // *IV发送线程命令(一般低优先级事项也放到这)*
SENDIV_SET_IV, // 设置IV
DAEMON_START = 0x0500, // *守护线程命令
CMD_STOP, // 机器人停止(建议各个控制硬件的模块都要实现)
CMD_STRAIGHT_DRIVE, // 机器人直线行驶命令格式为BHBF_straight_drive_Cmd
RESET_STRAIGHT_DRIVE, // CMD_STRAIGHT_DRIVE命令支持计时前进,这里重置计时
CMD_TURN_ANGLE, // 机器人转向目标角度(带PID)
CMD_SEND_IV, // 发送IV
GET_VEHICLE_SPEED, // 获取机器人速度(旋钮值)
GET_VEHICLE_REAL_SPEED, // 获取机器人速度(电机回码)
SET_VEHICLE_SPEED, // 设置速度
CMD_MOTOR_POWER_ENABLE, // 电机上电
CMD_MOTOR_POWER_DISABLE, // 电机失电
CMD_STOP_ALL, // 此命令统一调用机器人各个模块的CMD_STOP
GET_PV, // 获取PV
GET_MK32, // 获取MK32
GET_TL720D_ROLL, // 获取陀螺仪横滚角(IV显示)
GET_MOTOR_FAULT_CODE, // 获取错误码(电机回码)
GET_DAEMON_CODE, // 获取daemon错误码
GET_MOTOR_OK, // 获取电机初始化完毕
CMD_PAINTGUN, // 控制喷枪
CMD_STRAIGHT_DRIVE_FINISH, // CMD_STRAIGHT_DRIVE命令停止后回调
CMD_TURN_ANGLE_FINISH, // CMD_TURN_ANGLE命令停止后回调
CMD_STOP_AFTER_PAINTOFF, // 先关枪后停车
SET_STOP_OFF_PAINT, // 停车关枪CMD_STOP_AFTER_PAINTOFF标志位置1
RESET_PAINT, // 停车关枪CMD_STOP_AFTER_PAINTOFF逻辑中用于重置开枪状态
DAEMON_SET_MK32_SBUS, // 置位ComError_MK32_SBus
DAEMON_SET_TL720D, // 置位ComError_TL720D
DAEMON_SET_LEFT_MOTOR, // 置位ComError_LS_LeftMotor
@ -107,11 +106,6 @@ typedef enum {
DAEMON_SET_BUTTON_RESET, // 置位ComError_Remote_Button_Reset_State
DAEMON_SET_MK32_SERIAL, // 置位ComError_MK32_Serial
DAEMON_SET_MK32_UDP, // 置位ComError_MK32_UDP
TIMER_START = 0x0600, // *2ms定时器命令
TIMER_CMD_STRAIGHT_DRIVE, // 机器人直线行驶命令格式为BHBF_straight_drive_Cmd
TIMER_CMD_RESET_STRAIGHT, // 上一条命令支持计时前进,这里重置计时
TIMER_CMD_TURN_ANGLE, // 机器人转向目标角度(带PID)
} BHBF_Cmd_e;
#define THREAD_DEFAULT_STACK 4096

14
RBcore/msp_Timer.c

@ -65,13 +65,13 @@ static void Timer_ModuleHandler(const Msg_t *pstMsg)
static int bTimerStarted = 0; //直线行驶距离单次触发标志
switch (pstMsg->m_uiMsgID)
{
case TIMER_CMD_RESET_STRAIGHT:
case RESET_STRAIGHT_DRIVE:
{
uiLastSendTick = 0;
bTimerStarted = 0;
break;
}
case TIMER_CMD_STRAIGHT_DRIVE:
case CMD_STRAIGHT_DRIVE:
{
BHBF_straight_drive_Cmd stCmd = {0};
if (pstMsg->m_uiDataLen >= sizeof(stCmd))
@ -124,13 +124,13 @@ static void Timer_ModuleHandler(const Msg_t *pstMsg)
{
aiMotorSpeed[0] = 0;
aiMotorSpeed[1] = 0;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_STRAIGHT_DRIVE, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_STRAIGHT_DRIVE_FINISH, NULL, 0);
}
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
break;
}
case TIMER_CMD_TURN_ANGLE:
case CMD_TURN_ANGLE:
{
int iTargetAngle = 0;
if (pstMsg->m_uiDataLen >= sizeof(int))
@ -141,7 +141,7 @@ static void Timer_ModuleHandler(const Msg_t *pstMsg)
{
aiMotorSpeed[0] = 0;
aiMotorSpeed[1] = 0;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_TURN_ANGLE, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_TURN_ANGLE_FINISH, NULL, 0);
}
else if (abs(g_RF_Angle_Roll - iTargetAngle) <= 1000)
{
@ -155,7 +155,7 @@ static void Timer_ModuleHandler(const Msg_t *pstMsg)
aiMotorSpeed[0] = -g_dletAngle ;
aiMotorSpeed[1] = g_dletAngle ;
}
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
break;
}

16
README.md

@ -3,22 +3,22 @@
```mermaid
graph TB
subgraph RBcore
RBCORE_CMD_STOP_ALL
CMD_STOP_ALL
end
subgraph motor
MOTOR_POWER_ENABLE
MOTOR_POWER_DISABLE
CMD_MOTOR_POWER_ENABLE
CMD_MOTOR_POWER_DISABLE
m0(电机断电)
end
subgraph custom
CUSTOM_GET_MK32
CUSTOM_GET_MOTOR_OK
GET_MK32
GET_MOTOR_OK
c0((电机初始化完毕))
c1((按下急停))
end
a((Read_MK32))-->CUSTOM_GET_MK32-->MOTOR_POWER_ENABLE-->CUSTOM_GET_MOTOR_OK-->c0
c1-->MOTOR_POWER_DISABLE-->m0
c1-->RBCORE_CMD_STOP_ALL-->CMD_STOP_ALL
a((Read_MK32))-->GET_MK32-->CMD_MOTOR_POWER_ENABLE-->GET_MOTOR_OK-->c0
c1-->CMD_MOTOR_POWER_DISABLE-->m0
c1-->CMD_STOP_ALL-->CMD_STOP
```

4
controller/msp_MK32.c

@ -115,7 +115,7 @@ void decode_MK32(const char *buf, uint32_t _iSize)
if ((int32_t)(uiNowTick - uiLastSendTick) >= 10)
{
uiLastSendTick = uiNowTick;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_MK32, (void *)&RB_MK32,
MsgCenter_SendTo(MODULE_NAME_CUSTOM, GET_MK32, (void *)&RB_MK32,
sizeof(RB_MK32));
MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_MK32_SBUS, NULL, 0);
}
@ -217,6 +217,6 @@ WEAK void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
}
else
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP, NULL, 0);
}
}

4
motor/msp_motor_leisai.c

@ -406,7 +406,7 @@ static int LeiSai_ParseResponse(Motor_Instance_t *pstMotor, const uint8_t *pucDa
{
pstMotor->m_eState = MOTOR_STATE_ERROR;
}
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_FAULT_CODE, uiFaultCode, sizeof(uiFaultCode));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, GET_MOTOR_FAULT_CODE, uiFaultCode, sizeof(uiFaultCode));
break;
}
case LEISAI_OD_VELOCITY_ACTUAL:
@ -418,7 +418,7 @@ static int LeiSai_ParseResponse(Motor_Instance_t *pstMotor, const uint8_t *pucDa
| (pucData[7] << 24));
iRealVelocity[1] = MotorMgr_SpeedConvertex(pstMotor, iRealVelocity[0]);
iRealVelocity[0] = pstMotor->m_stConfig.m_ucMotorID;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_SPEED, iRealVelocity, sizeof(iRealVelocity));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, GET_VEHICLE_REAL_SPEED, iRealVelocity, sizeof(iRealVelocity));
break;
}
default:

130
project/paint_robot_new/paint_robot_new.c

@ -50,7 +50,7 @@ static PV_struct_define g_stPV;
static IV_struct_define g_stIV;
static int g_Is_All_Button_Reset = 0; // 1表示按钮正常工作,0表示需要复位
static int g_ichangLineState = 0; // 换道状态,0表示起始状态,1表示第一次旋转完成,2表示计时行走 完成
static int g_iRobot_Move_State = 0; // 机器人状态0表示默认,1表示调用TIMER_CMD_STRAIGHT_DRIVE
static int g_iRobot_Move_State = 0; // 机器人状态0表示默认,1表示调用CMD_STRAIGHT_DRIVE
static int g_iLeft_Compensation = 0;
static int g_iRight_Compensation = 0;
@ -84,8 +84,8 @@ static int32_t RunTime_DistanceCm_SpeedE_2MPMin(void)
*----------------------------------------------*/
static void E_Robot_Stop(void)
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_POWER_DISABLE, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_MOTOR_POWER_DISABLE, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STOP_ALL, NULL, 0);
g_Is_All_Button_Reset = 0;
}
@ -96,7 +96,7 @@ static void Vertical_Lane_Change_From_Left_To_Right_UP_Control(void)
if (0 == g_ichangLineState)
{
iTargetAngle = g_stCV.RobotLeftAngleValue;
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
}
else if (1 == g_ichangLineState)
{
@ -106,12 +106,12 @@ static void Vertical_Lane_Change_From_Left_To_Right_UP_Control(void)
.m_iTime = RunTime_DistanceCm_SpeedE_2MPMin(),
.m_iSpeed = g_stCV.Lane_Change_Speed_m_per_min
};
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
}
else if (2 == g_ichangLineState)
{
iTargetAngle = g_stCV.RobotUpAngleValue;
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
}
}
@ -122,7 +122,7 @@ static void Vertical_Lane_Change_From_Left_To_Right_Down_Control(void)
if (0 == g_ichangLineState)
{
iTargetAngle = g_stCV.RobotRightAngleValue;
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
}
else if (1 == g_ichangLineState)
{
@ -132,12 +132,12 @@ static void Vertical_Lane_Change_From_Left_To_Right_Down_Control(void)
.m_iTime = RunTime_DistanceCm_SpeedE_2MPMin(),
.m_iSpeed = g_stCV.Lane_Change_Speed_m_per_min
};
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
}
else if (2 == g_ichangLineState)
{
iTargetAngle = g_stCV.RobotUpAngleValue;
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
}
}
@ -148,7 +148,7 @@ static void Vertical_Lane_Change_From_Right_To_Left_UP_Control(void)
if (0 == g_ichangLineState)
{
iTargetAngle = g_stCV.RobotRightAngleValue;
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
}
else if (1 == g_ichangLineState)
{
@ -158,12 +158,12 @@ static void Vertical_Lane_Change_From_Right_To_Left_UP_Control(void)
.m_iTime = RunTime_DistanceCm_SpeedE_2MPMin(),
.m_iSpeed = g_stCV.Lane_Change_Speed_m_per_min
};
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
}
else if (2 == g_ichangLineState)
{
iTargetAngle = g_stCV.RobotUpAngleValue;
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
}
}
@ -174,7 +174,7 @@ static void Vertical_Lane_Change_From_Right_To_Left_Down_Control(void)
if (0 == g_ichangLineState)
{
iTargetAngle = g_stCV.RobotLeftAngleValue;
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
}
else if (1 == g_ichangLineState)
{
@ -184,19 +184,19 @@ static void Vertical_Lane_Change_From_Right_To_Left_Down_Control(void)
.m_iTime = RunTime_DistanceCm_SpeedE_2MPMin(),
.m_iSpeed = g_stCV.Lane_Change_Speed_m_per_min
};
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
}
else if (2 == g_ichangLineState)
{
iTargetAngle = g_stCV.RobotUpAngleValue;
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle));
}
}
static void Lane_Change_State_Reset(void)
{
g_ichangLineState = 0;
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_RESET_STRAIGHT, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_RBCORE, RESET_STRAIGHT_DRIVE, NULL, 0);
}
static void Robot_Move_Forward(void)
@ -206,7 +206,7 @@ static void Robot_Move_Forward(void)
int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理
aiMotorSpeed[0] = g_iVehicleSpeed * 10;
aiMotorSpeed[1] = g_iVehicleSpeed * 10;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
}
@ -219,7 +219,7 @@ static void Robot_Paint_SP(void)
if(g_stIV.CurrentSpeed != 0)
{
g_stAngleError_Ctl.m_iPaintState = 0;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
}
}
}
@ -237,7 +237,7 @@ static void Robot_Move_Forward_PID(void)
.m_iTime = -1,
.m_iSpeed = g_iVehicleSpeed
};
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
}
}
@ -248,7 +248,7 @@ static void Robot_Move_Backward(void)
int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理
aiMotorSpeed[0] = -g_iVehicleSpeed * 10;
aiMotorSpeed[1] = -g_iVehicleSpeed * 10;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
}
@ -263,7 +263,7 @@ static void Robot_Move_Backward_PID(void)
.m_iTime = -1,
.m_iSpeed = g_iVehicleSpeed
};
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
}
}
@ -274,7 +274,7 @@ static void Robot_Paint_ON(void)
if (0 == g_bIsStopOffPaint)
{
g_stAngleError_Ctl.m_iPaintState = 0;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
}
}
}
@ -285,7 +285,7 @@ static void Robot_Paint_OFF(void)
{
g_bIsStopOffPaint = 0;
g_stAngleError_Ctl.m_iPaintState = 1;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
}
}
@ -293,17 +293,17 @@ static void Robot_Stop_After(void)
{
if (0 == g_iPaint)
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_CMD_STOP_AFTER, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP_AFTER_PAINTOFF, NULL, 0);
}
else
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP, NULL, 0);
}
}
static void Robot_Stop(void)
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP, NULL, 0);
}
static void Robot_Move_Left(void)
@ -313,7 +313,7 @@ static void Robot_Move_Left(void)
int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理
aiMotorSpeed[0] = -g_stCV.LeftTurnSpeed;
aiMotorSpeed[1] = g_stCV.RightTurnSpeed;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
}
@ -324,7 +324,7 @@ static void Robot_Move_Right(void)
int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理
aiMotorSpeed[0] = g_stCV.LeftTurnSpeed;
aiMotorSpeed[1] = -g_stCV.RightTurnSpeed;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
}
@ -470,7 +470,7 @@ static void Move_Halt_AngleError(void)
{
if (Rd_GetTime() - uiLastTime >= 600 * g_stCV.Paint_Gun_Shutdown_Distance / g_stIV.RobotMoveSpeed)
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP, NULL, 0);
}
return;
}
@ -483,7 +483,7 @@ static void Move_Halt_AngleError(void)
{
if(Rd_GetTime() - g_stAngleError_Ctl.m_ipaintOffCount > 1000)
{
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_STOP_ALL, NULL, 0);//先关枪
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_STOP, NULL, 0);//先关枪
g_stAngleError_Ctl.m_iAnglelock = 1;
return;
}
@ -500,8 +500,8 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
// 急停
if (_pstMK32->CH8_SE == -1000 && _pstMK32->CH9_SF == -1000)
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_POWER_DISABLE, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_MOTOR_POWER_DISABLE, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STOP_ALL, NULL, 0);
g_Is_All_Button_Reset = 0;
return;
}
@ -536,7 +536,7 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
if (_iMode == 2 || _iMode == 3)
{
g_ichangLineState = 0;
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_RESET_STRAIGHT, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_RBCORE, RESET_STRAIGHT_DRIVE, NULL, 0);
}
}
@ -550,14 +550,14 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
if (0 == g_bIsStopOffPaint)
{
g_stAngleError_Ctl.m_iPaintState = 0;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
}
}
else
{
g_bIsStopOffPaint = 0;
g_stAngleError_Ctl.m_iPaintState = 1;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
}
}
}
@ -572,7 +572,7 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
{
aiMotorSpeed[0] = g_iVehicleSpeed * 10;
aiMotorSpeed[1] = g_iVehicleSpeed * 10;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
}
else if (_iMode == 2 || _iMode == 3)
@ -587,7 +587,7 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
.m_iTime = -1,
.m_iSpeed = g_iVehicleSpeed
};
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
}
}
return;
@ -600,7 +600,7 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
{
aiMotorSpeed[0] = -g_iVehicleSpeed * 10;
aiMotorSpeed[1] = -g_iVehicleSpeed * 10;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
}
else if (_iMode == 2 || _iMode == 3)
@ -615,7 +615,7 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
.m_iTime = -1,
.m_iSpeed = g_iVehicleSpeed
};
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
}
}
return;
@ -626,11 +626,11 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
{
if ((_iMode == 2 || _iMode == 3) && 0 == g_iPaint)
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_CMD_STOP_AFTER, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP_AFTER_PAINTOFF, NULL, 0);
}
else
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP, NULL, 0);
}
return;
}
@ -647,7 +647,7 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
{
aiMotorSpeed[0] = g_iVehicleSpeed * 10;
aiMotorSpeed[1] = g_iVehicleSpeed * 10;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
}
else if (_iMode == 2 || _iMode == 3)
@ -662,7 +662,7 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
.m_iTime = -1,
.m_iSpeed = g_iVehicleSpeed
};
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
}
}
}
@ -674,7 +674,7 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
{
aiMotorSpeed[0] = -g_iVehicleSpeed * 10;
aiMotorSpeed[1] = -g_iVehicleSpeed * 10;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
}
else if (_iMode == 2 || _iMode == 3)
@ -689,7 +689,7 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
.m_iTime = -1,
.m_iSpeed = g_iVehicleSpeed
};
MsgCenter_SendTo(MODULE_NAME_RBCORE, TIMER_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd));
}
}
}
@ -699,7 +699,7 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
{
aiMotorSpeed[0] = g_stCV.LeftTurnSpeed;
aiMotorSpeed[1] = -g_stCV.RightTurnSpeed;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
}
else if (abs(angle - 180) <= g_stCV.Joy_Sticker_Angle_Allowance || abs(angle - (-180)) <= g_stCV.Joy_Sticker_Angle_Allowance)
@ -708,12 +708,12 @@ void MK32_11111Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
{
aiMotorSpeed[0] = -g_stCV.LeftTurnSpeed;
aiMotorSpeed[1] = g_stCV.RightTurnSpeed;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
MsgCenter_SendTo(MODULE_NAME_MOTOR, SET_VEHICLE_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed));
}
}
else
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_STOP, NULL, 0);
}
}
@ -727,16 +727,16 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
static int iMotorOK = 0;
switch (pstMsg->m_uiMsgID)
{
case CUSTOM_RESET_PAINT:
case RESET_PAINT:
{
g_iPaint = 1;
break;
}
case CUSTOM_SET_STOP_OFF_PAINT:
case SET_STOP_OFF_PAINT:
{
g_bIsStopOffPaint = 1;
}
case CUSTOM_GET_DAEMON_CODE:
case GET_DAEMON_CODE:
{
if (pstMsg->m_uiDataLen >= sizeof(int32_t))
{
@ -744,7 +744,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
}
break;
}
case CUSTOM_GET_FAULT_CODE:
case GET_MOTOR_FAULT_CODE:
{
uint32_t uiFailtCode[2] = {0};
if (pstMsg->m_uiDataLen >= sizeof(uiFailtCode))
@ -763,7 +763,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
}
break;
}
case CUSTOM_GET_SPEED:
case GET_VEHICLE_REAL_SPEED:
{
int32_t iCurrentSpeed[2] = {0};
if (pstMsg->m_uiDataLen >= sizeof(iCurrentSpeed))
@ -781,7 +781,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
}
break;
}
case CUSTOM_GET_TL720D_ROLL:
case GET_TL720D_ROLL:
{
if (pstMsg->m_uiDataLen >= sizeof(int32_t))
{
@ -789,7 +789,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
}
break;
}
case CUSTOM_GET_PV:
case GET_PV:
{
if (pstMsg->m_uiDataLen >= sizeof(g_stPV))
{
@ -797,28 +797,28 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
}
break;
}
case CUSTOM_GET_MOTOR_OK:
case GET_MOTOR_OK:
{
iMotorOK = 1;
break;
}
case CUSTOM_CMD_STRAIGHT_DRIVE:
case CMD_STRAIGHT_DRIVE_FINISH:
{
g_ichangLineState = 2; // 走到这说明换道直线走完了
break;
}
case CUSTOM_CMD_TURN_ANGLE:
case CMD_TURN_ANGLE_FINISH:
{
g_ichangLineState = 1; // 走到这说明换道第一次转完了
break;
}
case CMD_STOP_ALL:
case CMD_STOP:
{
HAL_GPIO_WritePin(OUT_1_GPIO_Port, OUT_1_Pin, 1);
g_stAngleError_Ctl.m_iPaintState = 1;
break;
}
case CUSTOM_CMD_PAINTGUN:
case CMD_PAINTGUN:
{
int paintstate = -1;
if (pstMsg->m_uiDataLen >= sizeof(paintstate))
@ -829,7 +829,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
if (0 == paintstate) g_iPaint = 0;
break;
}
case CUSTOM_GET_MK32:
case GET_MK32:
{
if (pstMsg->m_uiDataLen >= sizeof(g_stMK32))
{
@ -842,7 +842,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
&& g_stMK32.CH7_SD == 0 && g_stMK32.IsOnline == 1)
{
g_iS2LastValue = g_stMK32.CH13_S2; //防止第一次值不正确
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_POWER_ENABLE, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_MOTOR_POWER_ENABLE, NULL, 0);
g_Is_All_Button_Reset = 1;
}
}
@ -859,11 +859,11 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
// 遥控器失联或者电机报错
if (g_stMK32.IsOnline == 0 || g_stIV.Left_Motor_Err != 0 || g_stIV.Right_Motor_Err != 0)
{
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STOP_ALL, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STOP_ALL, NULL, 0);
if (g_stMK32.IsOnline == 0)
{
g_Is_All_Button_Reset = 0;
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_POWER_DISABLE, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_MOTOR, CMD_MOTOR_POWER_DISABLE, NULL, 0);
}
break;
}
@ -941,7 +941,7 @@ void Custom_Task(void *argument)
{
uiLastSendTick = uiNowTick;
g_stIV.SBUS_State = g_stMK32.IsOnline;
MsgCenter_SendTo(MODULE_NAME_SENDIV, SENDIV_SET_IV, (void *)&g_stIV, sizeof(g_stIV));
MsgCenter_SendTo(MODULE_NAME_SENDIV, CMD_SEND_IV, (void *)&g_stIV, sizeof(g_stIV));
}
}
}

18
project/paint_robot_new/paint_robot_new_motors.c

@ -67,7 +67,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
static uint32_t uiLastTime = 0;
switch (pstMsg->m_uiMsgID)
{
case MOTOR_SET_SPEED:
case SET_VEHICLE_SPEED:
{
int aiMotorSpeed[2] = {0};
if (pstMsg->m_uiDataLen >= sizeof(aiMotorSpeed))
@ -87,12 +87,12 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
uiLastTime = Rd_GetTime();
break;
}
case MOTOR_POWER_ENABLE:
case CMD_MOTOR_POWER_ENABLE:
{
g_isMotorInit = 0;
break;
}
case MOTOR_POWER_DISABLE:
case CMD_MOTOR_POWER_DISABLE:
{
HAL_GPIO_WritePin(OUT_0_GPIO_Port, OUT_0_Pin, 1);
break;
@ -105,14 +105,14 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
}
break;
}
case MOTOR_CMD_STOP_AFTER:
case CMD_STOP_AFTER_PAINTOFF:
{
static int iIsDelayStop = 0;
if (1 == g_iLastVehicleMove)
{
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_SET_STOP_OFF_PAINT, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_STOP_ALL, NULL, 0);//先关枪
MsgCenter_SendTo(MODULE_NAME_CUSTOM, SET_STOP_OFF_PAINT, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CMD_STOP, NULL, 0);//先关枪
iIsDelayStop = 1;
}
@ -124,7 +124,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
{
memset(g_aiMotorSpeed, 0, sizeof(g_aiMotorSpeed));
iIsDelayStop = 0;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_RESET_PAINT, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_CUSTOM, RESET_PAINT, NULL, 0);
}
break;
}
@ -134,7 +134,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
}
break;
}
case CMD_STOP_ALL:
case CMD_STOP:
{
memset(g_aiMotorSpeed, 0, sizeof(g_aiMotorSpeed));
uiLastTime = Rd_GetTime();
@ -237,7 +237,7 @@ void MotorTask(void *argument)
MotorMgr_SpeedModeInit(g_apstMotors[1]);
g_isMotorInit = 1;
g_iInitOnce = 1;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_MOTOR_OK, NULL, 0);
MsgCenter_SendTo(MODULE_NAME_CUSTOM, GET_MOTOR_OK, NULL, 0);
}
else if (g_isMotorInit > 0)
{

Loading…
Cancel
Save