|
|
|
@ -55,7 +55,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
static int iSpeed = -1; // 表示由RD1转换来的速度值
|
|
|
|
static int iVehicleSpeed = -1; // 表示由RD1转换来的速度值
|
|
|
|
int aiMotorSpeed[2] = {0}; //0索引表示左,1索引表示右,多轮时到对应motor的MOTOR_CMD_SET_SPEED命令自行处理
|
|
|
|
switch (pstMsg->m_uiMsgID) |
|
|
|
{ |
|
|
|
@ -67,20 +67,20 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
} |
|
|
|
case RBCORE_CMD_MANUAL_FORWARD: |
|
|
|
{ |
|
|
|
if (iSpeed >= 0) |
|
|
|
if (iVehicleSpeed >= 0) |
|
|
|
{ |
|
|
|
aiMotorSpeed[0] = iSpeed; |
|
|
|
aiMotorSpeed[1] = iSpeed; |
|
|
|
aiMotorSpeed[0] = iVehicleSpeed * 10; |
|
|
|
aiMotorSpeed[1] = iVehicleSpeed * 10; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed)); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
case RBCORE_CMD_MANUAL_BACKWARD: |
|
|
|
{ |
|
|
|
if (iSpeed >= 0) |
|
|
|
if (iVehicleSpeed >= 0) |
|
|
|
{ |
|
|
|
aiMotorSpeed[0] = -iSpeed; |
|
|
|
aiMotorSpeed[1] = -iSpeed; |
|
|
|
aiMotorSpeed[0] = -iVehicleSpeed * 10; |
|
|
|
aiMotorSpeed[1] = -iVehicleSpeed * 10; |
|
|
|
MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_SET_SPEED, aiMotorSpeed, sizeof(aiMotorSpeed)); |
|
|
|
} |
|
|
|
break; |
|
|
|
@ -109,8 +109,7 @@ static void RBcore_ModuleHandler(const Msg_t *pstMsg) |
|
|
|
{ |
|
|
|
if (pstMsg->m_uiDataLen >= sizeof(int)) |
|
|
|
{ |
|
|
|
RD_MEMCPY(&iSpeed, pstMsg->m_aucData, sizeof(int)); |
|
|
|
iSpeed *= 10; |
|
|
|
RD_MEMCPY(&iVehicleSpeed, pstMsg->m_aucData, sizeof(int)); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
|