完结撒花
This commit is contained in:
parent
8f3afcdba5
commit
b57c09bce5
6
MDK-ARM/.vscode/keil-assistant.log
vendored
6
MDK-ARM/.vscode/keil-assistant.log
vendored
@ -156,3 +156,9 @@
|
||||
|
||||
[info] Log at : 2025/7/14|07:52:29|GMT+0800
|
||||
|
||||
[info] Log at : 2025/7/14|12:31:22|GMT+0800
|
||||
|
||||
[info] Log at : 2025/7/14|13:56:03|GMT+0800
|
||||
|
||||
[info] Log at : 2025/7/16|22:15:00|GMT+0800
|
||||
|
||||
|
6
MDK-ARM/.vscode/uv4.log
vendored
6
MDK-ARM/.vscode/uv4.log
vendored
@ -1,8 +1,4 @@
|
||||
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
|
||||
Build target 'R1'
|
||||
compiling ball.cpp...
|
||||
linking...
|
||||
Program Size: Code=32056 RO-data=1832 RW-data=284 ZI-data=32268
|
||||
FromELF: creating hex file...
|
||||
"R1\R1.axf" - 0 Error(s), 0 Warning(s).
|
||||
Build Time Elapsed: 00:00:05
|
||||
Build Time Elapsed: 00:00:01
|
||||
|
2
MDK-ARM/.vscode/uv4.log.lock
vendored
2
MDK-ARM/.vscode/uv4.log.lock
vendored
@ -1 +1 @@
|
||||
2025/7/14 7:54:12
|
||||
2025/7/16 22:18:46
|
@ -180,6 +180,16 @@
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>and1</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>5</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>nucbuf</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>6</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>drop_message,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow4>
|
||||
<Mm>
|
||||
@ -947,7 +957,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>User/device</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
@ -314,47 +314,6 @@ void Ball::ballDown(void)
|
||||
}
|
||||
}
|
||||
|
||||
// void Ball::Idle_control()
|
||||
// {
|
||||
// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); // 确保爪气缸关闭
|
||||
// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
|
||||
|
||||
// osThreadFlagsClear(EXTEND_OK);
|
||||
|
||||
// if (ready_key == SIDE) // 检测是否准备好
|
||||
// {
|
||||
// xiaomi.position = WAIT_POS;
|
||||
// if (feedback->position_deg >= WAIT_POS - 3)
|
||||
// {
|
||||
// // 只在READY_TELL未置位时发送,防止重复
|
||||
// if ((osThreadFlagsGet() & READY_TELL) == 0)
|
||||
// {
|
||||
// osThreadFlagsSet(task_struct.thread.shoot, READY_TELL);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// xiaomi.position = I_ANGLE; // 默认回到收回位置
|
||||
// }
|
||||
|
||||
// // 拨杆回到中间挡位时,回位并重置状态机
|
||||
// if (currentState1 == EXTEND_FINISH) // 转移后
|
||||
// {
|
||||
// xiaomi.position = I_ANGLE;
|
||||
// currentState1 = BALL_IDLE;
|
||||
// }
|
||||
// if (currentState1 == BALL_FINISH) // 运球完成
|
||||
// {
|
||||
// xiaomi.position = O_ANGLE;
|
||||
// currentState1 = BALL_IDLE;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// currentState1 = BALL_IDLE;
|
||||
// }
|
||||
// // xiaomi.position = I_ANGLE;
|
||||
// }
|
||||
|
||||
void Ball::Idle_control()
|
||||
{
|
||||
|
@ -1,113 +0,0 @@
|
||||
#include "TopDefine.h"
|
||||
#include "gimbal.hpp"
|
||||
#include "remote_control.h"
|
||||
#include "calc_lib.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
#define KP 0.12
|
||||
#define KD 0.008
|
||||
//可活动角度
|
||||
#define ANGLE_ALLOW 1.0f
|
||||
extern RC_ctrl_t rc_ctrl;
|
||||
NUC_t nuc;
|
||||
|
||||
const fp32 Gimbal:: Gimbal_speed_PID[3] = {50, 0.1, 0};
|
||||
const fp32 Gimbal:: Gimbal_angle_PID[3]= { 5, 0.01, 0};
|
||||
|
||||
#if GM6020ING ==1
|
||||
Gimbal::Gimbal()
|
||||
{
|
||||
// GM6020_Motor = get_motor_point(6);
|
||||
// GM6020_Motor->type = GM6020;
|
||||
// PID_init(&speed_pid,PID_POSITION,Gimbal_speed_PID,16000, 6000);
|
||||
// PID_init(&angle_pid,PID_POSITION,Gimbal_angle_PID,5000, 2000);
|
||||
|
||||
// result = 0;
|
||||
// angleSet = 0;
|
||||
|
||||
}
|
||||
|
||||
void Gimbal::gimbalFlow()
|
||||
{
|
||||
int16_t delta[1];
|
||||
//angleSet = angle1;
|
||||
delta[0] = PID_calc(&angle_pid,GM6020_Motor->total_angle,angleSet);
|
||||
result = PID_calc(&speed_pid, GM6020_Motor->speed_rpm, delta[0]);
|
||||
|
||||
CAN_cmd_1FF(0,0,result,0,&hcan1);
|
||||
osDelay(1);
|
||||
|
||||
}
|
||||
|
||||
void Gimbal::gimbalZero()
|
||||
{
|
||||
angleSet=0;
|
||||
//gimbalFlow();
|
||||
|
||||
}
|
||||
|
||||
void Gimbal::gimbalVision(const NUC_t &nuc)
|
||||
{
|
||||
int16_t delta[1];
|
||||
angleSet = nuc.vision.x;
|
||||
delta[0] = PID_calc(&angle_pid,GM6020_Motor->total_angle,angleSet);
|
||||
result = PID_calc(&speed_pid, GM6020_Motor->speed_rpm, delta[0]);
|
||||
|
||||
CAN_cmd_1FF(0,0,result,0,&hcan1);
|
||||
osDelay(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else
|
||||
Gimbal::Gimbal()
|
||||
{
|
||||
|
||||
Kp = KP;
|
||||
Kd = KD;
|
||||
allowRange = ANGLE_ALLOW;
|
||||
}
|
||||
|
||||
void Gimbal::gimbalInit(void)
|
||||
{
|
||||
int i;
|
||||
GO_M8010_init();
|
||||
for(i = 0;i < GO_NUM;i ++)
|
||||
{
|
||||
goData[i] = getGoPoint(i);//获取电机数据指针
|
||||
|
||||
angleSet[i] = 0;
|
||||
offestAngle[i] = 0;
|
||||
GO_M8010_send_data(&huart6, i,0,0,0,0,0,0);
|
||||
offestAngle[i] = goData[i]->Pos;
|
||||
HAL_Delay(100);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Gimbal::gimbalFlow(void)
|
||||
{
|
||||
|
||||
//angleSet[0] = map_fp32((float)rc_ctrl.ch[3],-800.0f,800.0f,-allowRange,allowRange) + offestAngle[0];
|
||||
GO_M8010_send_data(&huart6, 0,0,0,angleSet[0],1,KP,KD);
|
||||
osDelay(1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Gimbal::gimbalZero(void)
|
||||
{
|
||||
GO_M8010_send_data(&huart6, 0,0,0,0,0,0,0);
|
||||
}
|
||||
|
||||
void Gimbal::gimbalVision(const NUC_t &nuc)
|
||||
{
|
||||
angleSet[0] = nuc.vision.x;
|
||||
GO_M8010_send_data(&huart6, 0,0,0,angleSet[0],1,KP,KD);
|
||||
osDelay(1);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,57 +0,0 @@
|
||||
#ifndef GIMBAL_HPP
|
||||
#define GIMBAL_HPP
|
||||
|
||||
#include "GO_M8010_6_Driver.h"
|
||||
#include "djiMotor.h"
|
||||
#include "pid.h"
|
||||
#include "nuc.h"
|
||||
|
||||
class Gimbal
|
||||
{
|
||||
public:
|
||||
Gimbal();
|
||||
void gimbalFlow(void);//云台随遥控器转动
|
||||
void gimbalZero(void);//云台零阻尼模式
|
||||
void gimbalInit(void);//go初始化
|
||||
void gimbalVision(const NUC_t &nuc); // 接收 NUC_t 数据
|
||||
|
||||
int16_t result;
|
||||
//暂存要发送的扭矩
|
||||
//float result[GO_NUM];
|
||||
// float Kp;
|
||||
// float Kd;
|
||||
private:
|
||||
|
||||
#if GM6020ING == 1
|
||||
//GM6020电机数据
|
||||
motor_measure_t *GM6020_Motor;
|
||||
|
||||
static const float Gimbal_speed_PID[3];
|
||||
static const float Gimbal_angle_PID[3];
|
||||
|
||||
//电机速度pid结构体
|
||||
pid_type_def speed_pid;
|
||||
//位置环pid
|
||||
pid_type_def angle_pid;
|
||||
|
||||
float angleSet;
|
||||
|
||||
#else
|
||||
motor_measure_t *motorData[GO_NUM];
|
||||
//视觉发送的要调的角度
|
||||
float self_angleSet;
|
||||
GO_Motorfield* goData[GO_NUM];
|
||||
//暂存目标位置
|
||||
float angleSet[GO_NUM];
|
||||
float offestAngle[GO_NUM];//go数据
|
||||
float Kp;
|
||||
float Kd;
|
||||
float allowRange;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -39,7 +39,7 @@ const fp32 Shoot::M2006_angle_PID[3] = {15, 0.1, 0};
|
||||
#define CHANEGE_POS -205
|
||||
#define GO_ERROR 1.0f
|
||||
#define Tigger_DO -10
|
||||
#define Tigger_ZERO 115
|
||||
#define Tigger_ZERO 125
|
||||
#define Tigger_ERROR 3
|
||||
|
||||
float knob_increment;
|
||||
@ -273,8 +273,8 @@ void Shoot::shoot_control()
|
||||
{
|
||||
case VSION:
|
||||
//fire_pos = distance; // 视觉拟合的力
|
||||
fire_pos =shoot_fitting(distance)+and1;
|
||||
//fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置
|
||||
//fire_pos =shoot_fitting(distance)+and1;
|
||||
fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置
|
||||
|
||||
switch (rc_key)
|
||||
{
|
||||
@ -455,7 +455,7 @@ void Shoot::shoot_control()
|
||||
switch (mode_key)
|
||||
{
|
||||
case VSION:
|
||||
fire_pos = shoot_fitting(distance)+and1; // 视觉拟合的力
|
||||
fire_pos = shoot_fitting(distance)+and1;
|
||||
//fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置
|
||||
|
||||
switch (rc_key)
|
||||
@ -511,11 +511,10 @@ void Shoot::shoot_control()
|
||||
switch (rc_key)
|
||||
{
|
||||
case MIDDLE1:
|
||||
fire_pos = pass_fitting(pass_distance)+and2;
|
||||
fire_pos = shoot_fitting(distance)+and1;
|
||||
if ((shoot_thread & READY_TELL) && !(shoot_thread & EXTEND_OK))
|
||||
{
|
||||
// 只收到READY_TELL且未收到EXTEND_OK时,顶部蓄力流程
|
||||
ball_receive(); // ball_receive内部写go1.Pos
|
||||
ball_receive();
|
||||
}
|
||||
else if (shoot_thread & EXTEND_OK)
|
||||
{
|
||||
|
@ -1,47 +0,0 @@
|
||||
#include "TopDefine.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "userTask.h"
|
||||
#include <cmsis_os2.h>
|
||||
#include "gimbalTask.hpp"
|
||||
#include "gimbal.hpp"
|
||||
#include "main.h"
|
||||
#include "remote_control.h"
|
||||
#include "nuc.h"
|
||||
Gimbal gimbal;
|
||||
// NUC_t nucData; // 用于存储从队列接收的数据
|
||||
extern RC_ctrl_t rc_ctrl;
|
||||
int cnt1=0;
|
||||
|
||||
void FunctionGimbal(void *argument)
|
||||
{
|
||||
(void)argument; /* 未使用argument,消除警告 */
|
||||
|
||||
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CTRL_GIMBAL;
|
||||
|
||||
HAL_GPIO_WritePin(LED_G_GPIO_Port,LED_G_Pin,GPIO_PIN_SET);
|
||||
|
||||
uint32_t tick = osKernelGetTickCount();
|
||||
|
||||
while(1)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
task_struct.stack_water_mark.gimbal = osThreadGetStackSpace(osThreadGetId());
|
||||
#endif
|
||||
|
||||
//cnt1++;
|
||||
|
||||
// gimbal.gimbalFlow();
|
||||
// 从消息队列接收视觉数据
|
||||
// if (osMessageQueueGet(task_struct.msgq.nuc, &nucData, NULL, 0) == osOK)
|
||||
// {
|
||||
// // 使用接收到的视觉数据调整云台
|
||||
// //gimbal.gimbalVision(nucData);
|
||||
// }
|
||||
|
||||
osDelay(1);
|
||||
|
||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||
osDelayUntil(tick);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
#ifndef GIMBALTASK_HPP
|
||||
#define GIMBALTASK_HPP
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user