添加电机
This commit is contained in:
parent
dd27f0ba8b
commit
71466bc61e
@ -22,6 +22,8 @@ MOTOR_LK_Param_t chassis_motor_params[4] = {
|
||||
{BSP_CAN_1, 0x203, MOTOR_LK_MF9025, false},
|
||||
{BSP_CAN_1, 0x204, MOTOR_LK_MF9025, false}
|
||||
};
|
||||
MOTOR_LK_t *chassis_motors[4] = {NULL, NULL, NULL, NULL};
|
||||
|
||||
/* USER STRUCT END */
|
||||
|
||||
/* Private function --------------------------------------------------------- */
|
||||
@ -38,13 +40,34 @@ void Task_ctrl_chassis(void *argument) {
|
||||
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
|
||||
/* USER CODE INIT BEGIN */
|
||||
BSP_CAN_Init();
|
||||
|
||||
// 注册所有底盘电机
|
||||
for (int i = 0; i < 4; i++) {
|
||||
MOTOR_LK_Register(&chassis_motor_params[i]);
|
||||
}
|
||||
|
||||
// 延时等待电机稳定
|
||||
osDelay(100);
|
||||
|
||||
// 开启所有电机
|
||||
for (int i = 0; i < 4; i++) {
|
||||
MOTOR_LK_MotorOn(&chassis_motor_params[i]);
|
||||
}
|
||||
/* USER CODE INIT END */
|
||||
|
||||
while (1) {
|
||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||
/* USER CODE BEGIN */
|
||||
// 更新所有电机数据
|
||||
for (int i = 0; i < 4; i++) {
|
||||
MOTOR_LK_Update(&chassis_motor_params[i]);
|
||||
}
|
||||
|
||||
// 设置电机输出
|
||||
MOTOR_LK_SetOutput(&chassis_motor_params[0], 0.5f);
|
||||
MOTOR_LK_Ctrl(&chassis_motor_params[0]);
|
||||
MOTOR_LK_SetOutput(&chassis_motor_params[1], 0.5f);
|
||||
MOTOR_LK_SetOutput(&chassis_motor_params[2], 0.5f);
|
||||
MOTOR_LK_SetOutput(&chassis_motor_params[3], 0.5f);
|
||||
|
||||
/* USER CODE END */
|
||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user