Browse Source

优化断言打印,解决后停车逻辑中再按开枪导致的喷枪开启后无法关闭

paint_robot_new-v1.5
Lizongdi 1 week ago
parent
commit
00ad2af94d
  1. 5
      bspMCU/bsp_pin.c
  2. 32
      project/paint_robot_new/paint_robot_new.c

5
bspMCU/bsp_pin.c

@ -50,11 +50,12 @@ void delay_us(int nus)
void hard_fault_handler_c(unsigned int *hardfault_args) void hard_fault_handler_c(unsigned int *hardfault_args)
{ {
unsigned int stacked_lr = hardfault_args[5];
unsigned int stacked_pc = hardfault_args[6]; // 程序计数器 unsigned int stacked_pc = hardfault_args[6]; // 程序计数器
unsigned int stacked_psr = hardfault_args[7]; // 状态寄存器 unsigned int stacked_psr = hardfault_args[7]; // 状态寄存器
uint32_t sp = (uint32_t)hardfault_args; uint32_t sp = (uint32_t)hardfault_args;
// 打印寄存器现场 // 打印寄存器现场
log_a("====== HardFault Detected ======\nPC = 0x%08X, PSR= 0x%08X\nHFSR = 0x%08X\tCFSR = 0x%08X\nBFAR = 0x%08X\tMMFAR= 0x%08X\nsp = 0x%08X\n", log_a("====== HardFault Detected ======\nPSR= 0x%08X\nPC = 0x%08X, LR = 0x%08X\nHFSR = 0x%08X\tCFSR = 0x%08X\nBFAR = 0x%08X\tMMFAR= 0x%08X\nsp = 0x%08X\n",
stacked_pc, stacked_psr, SCB->HFSR, SCB->CFSR, SCB->BFAR, SCB->MMFAR, sp); stacked_psr, stacked_pc, stacked_lr, SCB->HFSR, SCB->CFSR, SCB->BFAR, SCB->MMFAR, sp);
} }

32
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 IV_struct_define g_stIV;
static int g_Is_All_Button_Reset = 0; // 1表示按钮正常工作,0表示需要复位 static int g_Is_All_Button_Reset = 0; // 1表示按钮正常工作,0表示需要复位
static int g_ichangLineState = 0; // 换道状态,0表示起始状态,1表示第一次旋转完成,2表示计时行走 完成 static int g_ichangLineState = 0; // 换道状态,0表示起始状态,1表示第一次旋转完成,2表示计时行走 完成
static int g_bNotTable = 0; static int g_iRobot_Move_State = 0; // 机器人状态0表示默认,1表示调用TIMER_CMD_STRAIGHT_DRIVE
static int g_iLeft_Compensation = 0; static int g_iLeft_Compensation = 0;
static int g_iRight_Compensation = 0; static int g_iRight_Compensation = 0;
@ -498,7 +498,7 @@ static void Move_Halt_AngleError(void)
void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode) void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
{ {
if (0 == g_bNotTable) g_bNotTable = 1; g_iRobot_Move_State = 0;
// 急停 // 急停
if (_pstMK32->CH8_SE == -1000 && _pstMK32->CH9_SF == -1000) if (_pstMK32->CH8_SE == -1000 && _pstMK32->CH9_SF == -1000)
{ {
@ -562,22 +562,6 @@ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int)); MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &g_stAngleError_Ctl.m_iPaintState, sizeof(int));
} }
} }
else if(_iMode == 2 || _iMode == 3)
{
if (_pstMK32->CH13_S2 != g_iS2LastValue)
{
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));
}
else
{
//log_w("cannot open paint with 0 move speed !");
}
}
}
g_iS2LastValue = _pstMK32->CH13_S2;
} }
int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理 int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理
@ -595,6 +579,8 @@ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
} }
else if (_iMode == 2 || _iMode == 3) else if (_iMode == 2 || _iMode == 3)
{ {
g_iRobot_Move_State = 1;
Robot_Paint_SP();
if (0 == g_stAngleError_Ctl.m_iAnglelock) if (0 == g_stAngleError_Ctl.m_iAnglelock)
{ {
BHBF_straight_drive_Cmd stCmd = { BHBF_straight_drive_Cmd stCmd = {
@ -621,6 +607,8 @@ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
} }
else if (_iMode == 2 || _iMode == 3) else if (_iMode == 2 || _iMode == 3)
{ {
g_iRobot_Move_State = 1;
Robot_Paint_SP();
if (0 == g_stAngleError_Ctl.m_iAnglelock) if (0 == g_stAngleError_Ctl.m_iAnglelock)
{ {
BHBF_straight_drive_Cmd stCmd = { BHBF_straight_drive_Cmd stCmd = {
@ -666,6 +654,8 @@ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
} }
else if (_iMode == 2 || _iMode == 3) else if (_iMode == 2 || _iMode == 3)
{ {
g_iRobot_Move_State = 1;
Robot_Paint_SP();
if (0 == g_stAngleError_Ctl.m_iAnglelock) if (0 == g_stAngleError_Ctl.m_iAnglelock)
{ {
BHBF_straight_drive_Cmd stCmd = { BHBF_straight_drive_Cmd stCmd = {
@ -691,6 +681,8 @@ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode)
} }
else if (_iMode == 2 || _iMode == 3) else if (_iMode == 2 || _iMode == 3)
{ {
g_iRobot_Move_State = 1;
Robot_Paint_SP();
if (0 == g_stAngleError_Ctl.m_iAnglelock) if (0 == g_stAngleError_Ctl.m_iAnglelock)
{ {
BHBF_straight_drive_Cmd stCmd = { BHBF_straight_drive_Cmd stCmd = {
@ -931,8 +923,8 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
lua_print("PV Info\n"); lua_print("PV Info\n");
lua_print("{%d, %d, %d, %d, %d, %ld}\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); 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("\niPaint = %d\ng_stAngleError_Ctl.m_iPaintState = %d\ng_stAngleError_Ctl.m_iAnglelock = %d\ng_stAngleError_Ctl.m_ipaintOffCount = %d\ng_Is_All_Button_Reset = %d\ng_bNotTable = %d\n", lua_print("\niPaint = %d\ng_stAngleError_Ctl.m_iPaintState = %d\ng_stAngleError_Ctl.m_iAnglelock = %d\ng_stAngleError_Ctl.m_ipaintOffCount = %d\ng_Is_All_Button_Reset = %d\n",
g_iPaint, g_stAngleError_Ctl.m_iPaintState, g_stAngleError_Ctl.m_iAnglelock, g_stAngleError_Ctl.m_ipaintOffCount, g_Is_All_Button_Reset, g_bNotTable); g_iPaint, g_stAngleError_Ctl.m_iPaintState, g_stAngleError_Ctl.m_iAnglelock, g_stAngleError_Ctl.m_ipaintOffCount, g_Is_All_Button_Reset);
break; break;
} }
default: default:

Loading…
Cancel
Save