Browse Source

只有开过枪才生效延时停车

paint_robot_new-v1.5
Lizongdi 2 weeks ago
parent
commit
0092e19300
  1. 1
      RBcore/include/BHBF.h
  2. 14
      project/paint_robot_new/paint_robot_new.c
  3. 5
      project/paint_robot_new/paint_robot_new_motors.c

1
RBcore/include/BHBF.h

@ -103,6 +103,7 @@ typedef enum {
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

14
project/paint_robot_new/paint_robot_new.c

@ -114,8 +114,14 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
static int iRight_Compensation = 0;
static int iVehicleSpeed = 1;
static int iIsStopOffPaint = 0;
static int iPaint = 1;
switch (pstMsg->m_uiMsgID)
{
case CUSTOM_RESET_PAINT:
{
iPaint = 1;
break;
}
case CUSTOM_SET_STOP_OFF_PAINT:
{
iIsStopOffPaint = 1;
@ -257,6 +263,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
RD_MEMCPY(&paintstate, pstMsg->m_aucData, sizeof(paintstate));
HAL_GPIO_WritePin(OUT_1_GPIO_Port, OUT_1_Pin, paintstate);
}
if (0 == paintstate) iPaint = 0;
break;
}
case CUSTOM_GET_MK32:
@ -439,9 +446,10 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
// 【注意!!!】摇杆行程死区判断开始,除摇杆以外按键在上边都处理完,不然走不下去
if (abs(g_stMK32.CH2_LY_V) <= g_stCV.Joy_Sticker_Value_Allowance && abs(g_stMK32.CH3_LY_H) <= g_stCV.Joy_Sticker_Value_Allowance)
{
if (g_stPV.RunMode == 2 || g_stPV.RunMode == 3)
if ((g_stPV.RunMode == 2 || g_stPV.RunMode == 3) && 0 == iPaint)
{
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_CMD_STOP_AFTER, NULL, 0);
log_e("MOTOR_CMD_STOP_AFTER");
}
else
{
@ -530,8 +538,8 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
lua_print("PV Info\n");
lua_print("{%d, %d, %d, %d, %d, %ld}\n",
g_stPV.RunMode, g_stPV.RobotSpeed, g_stPV.LaneChangeDistance, (int)g_stPV.Vertical_Calibration, g_stPV.IV_IsRestart_Notified, (long long)g_stPV.TimeStamp);
lua_print("\ng_Paint_State = %d\ng_angle_protect_lock = %d\ng_ipaintOffCount = %d\ng_Is_All_Button_Reset = %d\n",
g_Paint_State, g_angle_protect_lock, g_ipaintOffCount, g_Is_All_Button_Reset);
lua_print("\niPaint = %d\ng_Paint_State = %d\ng_angle_protect_lock = %d\ng_ipaintOffCount = %d\ng_Is_All_Button_Reset = %d\n",
iPaint, g_Paint_State, g_angle_protect_lock, g_ipaintOffCount, g_Is_All_Button_Reset);
break;
}
default:

5
project/paint_robot_new/paint_robot_new_motors.c

@ -62,6 +62,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
}
int iSpeed = 1;
static uint32_t uiLastTime = 0;
switch (pstMsg->m_uiMsgID)
{
case MOTOR_SET_SPEED:
@ -81,6 +82,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
{
g_iLastVehicleMove = 1;
}
uiLastTime = Rd_GetTime();
break;
}
case MOTOR_POWER_ENABLE:
@ -103,7 +105,6 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
}
case MOTOR_CMD_STOP_AFTER:
{
static uint32_t uiLastTime = 0;
static int iIsDelayStop = 0;
if (1 == g_iLastVehicleMove)
@ -121,6 +122,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);
}
break;
}
@ -133,6 +135,7 @@ static void Motor_ModuleHandler(const Msg_t *pstMsg)
case COMMON_CMD_STOP_ALL:
{
memset(g_aiMotorSpeed, 0, sizeof(g_aiMotorSpeed));
uiLastTime = Rd_GetTime();
break;
}
default:

Loading…
Cancel
Save