Browse Source

解决电机初始化后导致CAN没数据问题,根因是发太快了导致CAN无接收

master
Lizongdi 16 hours ago
parent
commit
033a0d3b27
  1. 1
      motor/msp_motor_leisai.c
  2. 2
      project/paint_robot_new/paint_robot_new.c
  3. 9
      project/paint_robot_new/paint_robot_new_motors.c

1
motor/msp_motor_leisai.c

@ -420,6 +420,7 @@ static int LeiSai_ParseResponse(Motor_Instance_t *pstMotor, const uint8_t *pucDa
iRealVelocity[1] = MotorMgr_SpeedConvertex(pstMotor, iRealVelocity[0]); iRealVelocity[1] = MotorMgr_SpeedConvertex(pstMotor, iRealVelocity[0]);
iRealVelocity[0] = pstMotor->m_stConfig.m_ucMotorID; iRealVelocity[0] = pstMotor->m_stConfig.m_ucMotorID;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, MOTOR_CMD_GET_SPEED, iRealVelocity, sizeof(iRealVelocity)); MsgCenter_SendTo(MODULE_NAME_CUSTOM, MOTOR_CMD_GET_SPEED, iRealVelocity, sizeof(iRealVelocity));
log_d("iRealVelocity[1] = %d", iRealVelocity[1]);
break; break;
} }
default: default:

2
project/paint_robot_new/paint_robot_new.c

@ -85,7 +85,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg)
if (1 == iCurrentSpeed[0]) if (1 == iCurrentSpeed[0])
{ {
g_stIV.CurrentSpeed = iCurrentSpeed[1]; g_stIV.CurrentSpeed = iCurrentSpeed[1];
log_i("g_stIV.CurrentSpeed = %d", g_stIV.CurrentSpeed); log_d("speed = %d", g_stIV.CurrentSpeed);
} }
} }
break; break;

9
project/paint_robot_new/paint_robot_new_motors.c

@ -167,13 +167,22 @@ void MotorTask(void *argument)
{ {
// 处理消息 // 处理消息
MsgCenter_ProcessWait(g_uiMotorModuleID, 2); MsgCenter_ProcessWait(g_uiMotorModuleID, 2);
Rd_Delay(2);
MotorMgr_RequestPosition(g_apstMotors[0]); MotorMgr_RequestPosition(g_apstMotors[0]);
Rd_Delay(2);
MotorMgr_RequestPosition(g_apstMotors[1]); MotorMgr_RequestPosition(g_apstMotors[1]);
Rd_Delay(2);
MotorMgr_RequestFault(g_apstMotors[0]); MotorMgr_RequestFault(g_apstMotors[0]);
Rd_Delay(2);
MotorMgr_RequestFault(g_apstMotors[1]); MotorMgr_RequestFault(g_apstMotors[1]);
Rd_Delay(2);
MotorMgr_RequestVelocity(g_apstMotors[0]); MotorMgr_RequestVelocity(g_apstMotors[0]);
Rd_Delay(2);
MotorMgr_RequestVelocity(g_apstMotors[1]); MotorMgr_RequestVelocity(g_apstMotors[1]);
Rd_Delay(2);
MotorMgr_SetTargetSpeed(g_apstMotors[0], g_aiMotorSpeed[0]); MotorMgr_SetTargetSpeed(g_apstMotors[0], g_aiMotorSpeed[0]);
Rd_Delay(2);
MotorMgr_SetTargetSpeed(g_apstMotors[1], g_aiMotorSpeed[1]); MotorMgr_SetTargetSpeed(g_apstMotors[1], g_aiMotorSpeed[1]);
Rd_Delay(2);
} }
} }

Loading…
Cancel
Save