|
|
|
@ -21,6 +21,8 @@ |
|
|
|
#include "lua_base.h" |
|
|
|
#include "Protobuf/PSource/bsp_PV.pb.h" |
|
|
|
#include "Protobuf/PSource/msp_MK32.pb.h" |
|
|
|
#include "Protobuf/PSource/bsp_CV.pb.h" |
|
|
|
#include "Protobuf/PSource/bsp_IV.pb.h" |
|
|
|
|
|
|
|
/*----------------------------------------------*
|
|
|
|
* 外部变量说明 * |
|
|
|
@ -42,8 +44,10 @@ |
|
|
|
* 模块级变量 * |
|
|
|
*----------------------------------------------*/ |
|
|
|
static uint32_t g_uiCustomModuleID = 0; |
|
|
|
SP_MSP_MK32_Button g_stMK32; |
|
|
|
PV_struct_define g_stPV; |
|
|
|
static SP_MSP_MK32_Button g_stMK32; |
|
|
|
static PV_struct_define g_stPV; |
|
|
|
static CV_struct_define g_stCV; |
|
|
|
static IV_struct_define g_stIV; |
|
|
|
|
|
|
|
/*----------------------------------------------*
|
|
|
|
* 常量定义 * |
|
|
|
@ -52,8 +56,6 @@ PV_struct_define g_stPV; |
|
|
|
/*----------------------------------------------*
|
|
|
|
* 宏定义 * |
|
|
|
*----------------------------------------------*/ |
|
|
|
#define JOY_STICKER_VALUE_ALLOWANCE 600 //摇杆行程死区
|
|
|
|
#define JOY_STICKER_ANGLE_ALLOWANCE 30 //摇杆角度死区
|
|
|
|
|
|
|
|
static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
{ |
|
|
|
@ -64,6 +66,14 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
|
|
|
|
switch (pstMsg->m_uiMsgID) |
|
|
|
{ |
|
|
|
case CUSTOM_GET_CV: |
|
|
|
{ |
|
|
|
if (pstMsg->m_uiDataLen >= sizeof(g_stCV)) |
|
|
|
{ |
|
|
|
RD_MEMCPY(&g_stCV, pstMsg->m_aucData, sizeof(g_stCV)); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
case CUSTOM_GET_PV: |
|
|
|
{ |
|
|
|
if (pstMsg->m_uiDataLen >= sizeof(g_stPV)) |
|
|
|
@ -79,7 +89,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
RD_MEMCPY(&g_stMK32, pstMsg->m_aucData, sizeof(g_stMK32)); |
|
|
|
} |
|
|
|
|
|
|
|
if (abs(g_stMK32.CH2_LY_V) <= JOY_STICKER_VALUE_ALLOWANCE && abs(g_stMK32.CH3_LY_H) <= JOY_STICKER_VALUE_ALLOWANCE) |
|
|
|
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) |
|
|
|
{ |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STOP_ALL, NULL, 0); |
|
|
|
break; |
|
|
|
@ -87,19 +97,19 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
|
|
|
|
int angle = atan2(g_stMK32.CH2_LY_V, g_stMK32.CH3_LY_H) * 180 / M_PI; |
|
|
|
|
|
|
|
if (abs(angle - 90) <= JOY_STICKER_ANGLE_ALLOWANCE) |
|
|
|
if (abs(angle - 90) <= g_stCV.Joy_Sticker_Angle_Allowance) |
|
|
|
{ |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_MANUAL_FORWARD, NULL, 0); |
|
|
|
} |
|
|
|
else if (abs(angle - (-90)) <= JOY_STICKER_ANGLE_ALLOWANCE) |
|
|
|
else if (abs(angle - (-90)) <= g_stCV.Joy_Sticker_Angle_Allowance) |
|
|
|
{ |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_MANUAL_BACKWARD, NULL, 0); |
|
|
|
} |
|
|
|
else if (abs(angle - 0) <= JOY_STICKER_ANGLE_ALLOWANCE) |
|
|
|
else if (abs(angle - 0) <= g_stCV.Joy_Sticker_Angle_Allowance) |
|
|
|
{ |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_MANUAL_TURNRIGHT, NULL, 0); |
|
|
|
} |
|
|
|
else if (abs(angle - 180) <= JOY_STICKER_ANGLE_ALLOWANCE) |
|
|
|
else if (abs(angle - 180) <= g_stCV.Joy_Sticker_Angle_Allowance) |
|
|
|
{ |
|
|
|
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_MANUAL_TURNLEFT, NULL, 0); |
|
|
|
} |
|
|
|
@ -129,8 +139,8 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
lua_print("CH14_LT \t%d\n", g_stMK32.CH14_LT); |
|
|
|
lua_print("CH15_RT \t%d\n", g_stMK32.CH15_RT); |
|
|
|
lua_print("PV Info\n"); |
|
|
|
lua_print("RunMode = %d\nRobotSpeed = %d\nLaneChangeDistance = %d\nVertical_Calibration = %d\nIV_IsRestart_Notified = %d\nTimeStamp = %ld\n", |
|
|
|
g_stPV.RunMode, g_stPV.RobotSpeed, g_stPV.LaneChangeDistance, (int)g_stPV.Vertical_Calibration, g_stPV.IV_IsRestart_Notified, g_stPV.TimeStamp); |
|
|
|
lua_print("{%d, %d, %d, %d, %d, %d}\n", |
|
|
|
g_stPV.RunMode, g_stPV.RobotSpeed, g_stPV.LaneChangeDistance, (int)g_stPV.Vertical_Calibration, g_stPV.IV_IsRestart_Notified, (int)g_stPV.TimeStamp); |
|
|
|
break; |
|
|
|
} |
|
|
|
default: |
|
|
|
@ -144,6 +154,7 @@ void Custom_Task(void *argument) |
|
|
|
while(1) |
|
|
|
{ |
|
|
|
MsgCenter_ProcessWait(g_uiCustomModuleID, 2); |
|
|
|
MsgCenter_SendTo(MODULE_NAME_SENDIV, CUSTOM_SET_IV, (void *)&g_stIV, sizeof(g_stIV)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|