From aa232e98620cdc31d0de18a0527b58f47ce394a2 Mon Sep 17 00:00:00 2001 From: ws <1621320660@qq.com> Date: Wed, 30 Apr 2025 13:20:30 +0800 Subject: [PATCH] =?UTF-8?q?=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- User/device/djiMotor.c | 2 +- User/module/ball.cpp | 19 +++++-------------- User/task/ballTask.cpp | 5 ++++- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/User/device/djiMotor.c b/User/device/djiMotor.c index e2042c4..1172199 100644 --- a/User/device/djiMotor.c +++ b/User/device/djiMotor.c @@ -159,7 +159,7 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) } #else -static osEventFlagsId_t eventReceive; +//static osEventFlagsId_t eventReceive; static osThreadId_t thread_alert; /** * @brief 自定义大疆电机回调函数 diff --git a/User/module/ball.cpp b/User/module/ball.cpp index 1ea8443..67dfadf 100644 --- a/User/module/ball.cpp +++ b/User/module/ball.cpp @@ -29,7 +29,7 @@ Ball ::Ball() if(i <=3) { hand_Motor[i]->type = M3508;//设置电机类型 - PID_init(&speed_pid[i],PID_POSITION,M3508_speed_PID,16000, 10000);//pid初始化 + PID_init(&speed_pid[i],PID_POSITION,M3508_speed_PID,16000, 1000);//pid初始化 } result[i] = 0; speedSet[i] = 0; @@ -87,9 +87,9 @@ void Ball::ballHadling(void) if (ball_state == 1) //读光电 有球 0 无球 1 { - osDelay(200); // 延时200ms - speedm=4500; - speedm1=4500; + osDelay(100); // 延时200ms + speedm=2500; + speedm1=2500; currentState1 = BALL_REVERSE; // 切换到反转状态 } @@ -100,7 +100,6 @@ void Ball::ballHadling(void) if (ball_state == 0) { - //flag=2; //抽象的计次 speedm=0; // 停止电机 speedm1=0; currentState1 = BALL_CLOSE; // 切换到完成状态 @@ -115,15 +114,7 @@ void Ball::ballHadling(void) HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); currentState1 = BALL_FINISH; // 切换到完成状态 } - // if (flag == 2) - // { - // if(ball_state == 0) - // { - // HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); - // currentState1 = BALL_FINISH; // 切换到完成状态 - // } - - // } + break; case BALL_FINISH: diff --git a/User/task/ballTask.cpp b/User/task/ballTask.cpp index ff14774..eda35f3 100644 --- a/User/task/ballTask.cpp +++ b/User/task/ballTask.cpp @@ -37,7 +37,10 @@ void FunctionBall(void *argument) vofa[1] = -ball.hand_Motor[0]->speed_rpm; // 发送电机角度数据 vofa[2] = ball.hand_Motor[1]->speed_rpm; // 发送电机速度数据 vofa[3] = ball.hand_Motor[2]->speed_rpm; // 发送电机速度数据 - + vofa[4] = ball.result[0]; + vofa[5] = ball.result[1]; + vofa[6] = ball.result[2]; + vofa_tx_main(vofa); // 发送数据到虚拟串口 tick += delay_tick; /* 计算下一个唤醒时刻 */