|
|
|
@ -58,6 +58,11 @@ static IV_struct_define g_stIV; |
|
|
|
|
|
|
|
#define IV_SEND_TIME 500 // IV上报周期(单位毫秒)
|
|
|
|
|
|
|
|
static int32_t RunTime_DistanceCm_SpeedE_2MPMin(void) |
|
|
|
{ |
|
|
|
return (600 * (g_stPV.LaneChangeDistance + g_stCV.Vertical_ChangeLane_Compensation) / g_stCV.Lane_Change_Speed_m_per_min); |
|
|
|
} |
|
|
|
|
|
|
|
static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
{ |
|
|
|
if (NULL == pstMsg) |
|
|
|
@ -65,6 +70,8 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
static int iLeft_Compensation = 0; |
|
|
|
static int iRight_Compensation = 0; |
|
|
|
switch (pstMsg->m_uiMsgID) |
|
|
|
{ |
|
|
|
case CUSTOM_GET_FAULT_CODE: |
|
|
|
@ -106,6 +113,76 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
case CUSTOM_CMD_STRAIGHT_DRIVE: |
|
|
|
{ |
|
|
|
BHBF_straight_drive_Cmd stCmd = {0}; |
|
|
|
if (pstMsg->m_uiDataLen >= sizeof(stCmd)) |
|
|
|
{ |
|
|
|
RD_MEMCPY(&stCmd, pstMsg->m_aucData, sizeof(stCmd)); |
|
|
|
int iTargetAngle = g_stCV.RobotUpAngleValue; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle)); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
case CUSTOM_CMD_TURN_ANGLE: |
|
|
|
{ |
|
|
|
int iTargetAngle = 0; |
|
|
|
if (pstMsg->m_uiDataLen >= sizeof(int)) |
|
|
|
{ |
|
|
|
RD_MEMCPY(&iTargetAngle, pstMsg->m_aucData, sizeof(int)); |
|
|
|
if (iTargetAngle == g_stCV.RobotUpAngleValue) |
|
|
|
{ |
|
|
|
log_d("change line success"); |
|
|
|
} |
|
|
|
else if (iTargetAngle == g_stCV.RobotLeftAngleValue) |
|
|
|
{ |
|
|
|
if (g_stPV.RunMode == 2)//竖直从右往左作业 下端 向左换道 最终头朝上
|
|
|
|
{ |
|
|
|
BHBF_straight_drive_Cmd stCmd = { |
|
|
|
.m_iMode = 1, |
|
|
|
.m_iAngle = g_stCV.RobotLeftAngleValue + iLeft_Compensation, |
|
|
|
.m_iTime = RunTime_DistanceCm_SpeedE_2MPMin() |
|
|
|
}; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd)); |
|
|
|
} |
|
|
|
else if (g_stPV.RunMode == 3)//竖直从左往右作业 上端 向右换道 最终头朝上
|
|
|
|
{ |
|
|
|
BHBF_straight_drive_Cmd stCmd = { |
|
|
|
.m_iMode = -1, |
|
|
|
.m_iAngle = g_stCV.RobotLeftAngleValue - iRight_Compensation, |
|
|
|
.m_iTime = RunTime_DistanceCm_SpeedE_2MPMin() |
|
|
|
}; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd)); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (iTargetAngle == g_stCV.RobotRightAngleValue) |
|
|
|
{ |
|
|
|
if (g_stPV.RunMode == 2)//竖直从右往左作业 上端 向左换道 最终头朝上
|
|
|
|
{ |
|
|
|
BHBF_straight_drive_Cmd stCmd = { |
|
|
|
.m_iMode = -1, |
|
|
|
.m_iAngle = g_stCV.RobotRightAngleValue + iLeft_Compensation, |
|
|
|
.m_iTime = RunTime_DistanceCm_SpeedE_2MPMin() |
|
|
|
}; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd)); |
|
|
|
} |
|
|
|
else if (g_stPV.RunMode == 3)//竖直从左往右作业 下端 向右换道 最终头朝上
|
|
|
|
{ |
|
|
|
BHBF_straight_drive_Cmd stCmd = { |
|
|
|
.m_iMode = 1, |
|
|
|
.m_iAngle = g_stCV.RobotRightAngleValue - iRight_Compensation, |
|
|
|
.m_iTime = RunTime_DistanceCm_SpeedE_2MPMin() |
|
|
|
}; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd)); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (iTargetAngle == g_stCV.RobotDownAngleValue) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
case CUSTOM_CMD_PAINTGUN: |
|
|
|
{ |
|
|
|
int paintstate = -1; |
|
|
|
@ -153,19 +230,42 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &paintstate, sizeof(int)); |
|
|
|
} |
|
|
|
|
|
|
|
int iTargetAngle = 0; |
|
|
|
// 根据模式判断换道(仅在竖直向左或向右生效)
|
|
|
|
if (g_stPV.RunMode == 2 || g_stPV.RunMode == 3) |
|
|
|
if (g_stMK32.CH4_SA == 1000) |
|
|
|
{ |
|
|
|
if (g_stMK32.CH4_SA == -1000) |
|
|
|
if (g_stPV.RunMode == 2)//竖直从右往左作业 下端 向左换道 最终头朝上
|
|
|
|
{ |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_MANUAL_TURNRIGHT, NULL, 0); |
|
|
|
iTargetAngle = g_stCV.RobotLeftAngleValue; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle)); |
|
|
|
} |
|
|
|
else if (g_stPV.RunMode == 3)//竖直从左往右作业 下端 向右换道 最终头朝上
|
|
|
|
{ |
|
|
|
iTargetAngle = g_stCV.RobotRightAngleValue; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle)); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
else if(g_stMK32.CH4_SA == 1000) |
|
|
|
else if (g_stMK32.CH4_SA == -1000) |
|
|
|
{ |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_MANUAL_TURNLEFT, NULL, 0); |
|
|
|
if (g_stPV.RunMode == 2)//竖直从右往左作业 上端 向左换道 最终头朝上
|
|
|
|
{ |
|
|
|
iTargetAngle = g_stCV.RobotRightAngleValue; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle)); |
|
|
|
} |
|
|
|
else if (g_stPV.RunMode == 3)//竖直从左往右作业 上端 向右换道 最终头朝上
|
|
|
|
{ |
|
|
|
iTargetAngle = g_stCV.RobotLeftAngleValue; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_TURN_ANGLE, &iTargetAngle, sizeof(iTargetAngle)); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
else // 重置前进计时器以便下一次换道重新计数
|
|
|
|
{ |
|
|
|
if (g_stPV.RunMode == 2 || g_stPV.RunMode == 3) |
|
|
|
{ |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_RESET_STRAIGHT, NULL, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 自动巡航
|
|
|
|
@ -199,8 +299,12 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
int iMode[2] = {1, g_stCV.RobotUpAngleValue + g_stPV.Vertical_Calibration}; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_VERTICAL, iMode, sizeof(iMode)); |
|
|
|
BHBF_straight_drive_Cmd stCmd = { |
|
|
|
.m_iMode = 1, |
|
|
|
.m_iAngle = g_stCV.RobotUpAngleValue + g_stPV.Vertical_Calibration, |
|
|
|
.m_iTime = -1 |
|
|
|
}; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd)); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (abs(angle - (-90)) <= g_stCV.Joy_Sticker_Angle_Allowance) |
|
|
|
@ -211,8 +315,12 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
int iMode[2] = {-1 , g_stCV.RobotUpAngleValue + g_stPV.Vertical_Calibration}; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_VERTICAL, iMode, sizeof(iMode)); |
|
|
|
BHBF_straight_drive_Cmd stCmd = { |
|
|
|
.m_iMode = -1, |
|
|
|
.m_iAngle = g_stCV.RobotUpAngleValue + g_stPV.Vertical_Calibration, |
|
|
|
.m_iTime = -1 |
|
|
|
}; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STRAIGHT_DRIVE, &stCmd, sizeof(stCmd)); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (abs(angle - 0) <= g_stCV.Joy_Sticker_Angle_Allowance) |
|
|
|
|