完结撒花
This commit is contained in:
commit
4d90b38daf
12
MDK-ARM/.vscode/keil-assistant.log
vendored
12
MDK-ARM/.vscode/keil-assistant.log
vendored
@ -152,3 +152,15 @@
|
|||||||
|
|
||||||
[info] Log at : 2025/7/13|16:42:25|GMT+0800
|
[info] Log at : 2025/7/13|16:42:25|GMT+0800
|
||||||
|
|
||||||
|
[info] Log at : 2025/7/13|22:38:15|GMT+0800
|
||||||
|
|
||||||
|
[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
|
||||||
|
|
||||||
|
[info] Log at : 2025/7/16|22:26:06|GMT+0800
|
||||||
|
|
||||||
|
15
MDK-ARM/.vscode/uv4.log
vendored
15
MDK-ARM/.vscode/uv4.log
vendored
@ -1,18 +1,9 @@
|
|||||||
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
|
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
|
||||||
Build target 'R1'
|
Build target 'R1'
|
||||||
compiling userTask.c...
|
|
||||||
compiling remote_control.c...
|
|
||||||
compiling initTask.c...
|
|
||||||
compiling main.c...
|
|
||||||
compiling shootTask.cpp...
|
|
||||||
compiling djiMotor.c...
|
|
||||||
compiling nucTask.cpp...
|
|
||||||
compiling encodeCan.cpp...
|
|
||||||
compiling ballTask.cpp...
|
compiling ballTask.cpp...
|
||||||
compiling ball.cpp...
|
compiling shootTask.cpp...
|
||||||
compiling shoot.cpp...
|
|
||||||
linking...
|
linking...
|
||||||
Program Size: Code=32032 RO-data=1832 RW-data=284 ZI-data=32268
|
Program Size: Code=31984 RO-data=1832 RW-data=272 ZI-data=32264
|
||||||
FromELF: creating hex file...
|
FromELF: creating hex file...
|
||||||
"R1\R1.axf" - 0 Error(s), 0 Warning(s).
|
"R1\R1.axf" - 0 Error(s), 0 Warning(s).
|
||||||
Build Time Elapsed: 00:00:09
|
Build Time Elapsed: 00:00:05
|
||||||
|
2
MDK-ARM/.vscode/uv4.log.lock
vendored
2
MDK-ARM/.vscode/uv4.log.lock
vendored
@ -1 +1 @@
|
|||||||
2025/7/13 17:07:34
|
2025/7/16 22:30:59
|
@ -155,6 +155,9 @@
|
|||||||
</TargetDriverDllRegistry>
|
</TargetDriverDllRegistry>
|
||||||
<Breakpoint/>
|
<Breakpoint/>
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> 上层测试
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>0</count>
|
<count>0</count>
|
||||||
@ -169,26 +172,43 @@
|
|||||||
<Ww>
|
<Ww>
|
||||||
<count>2</count>
|
<count>2</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
|
<<<<<<< HEAD
|
||||||
<ItemText>ball,0x0A</ItemText>
|
<ItemText>ball,0x0A</ItemText>
|
||||||
|
=======
|
||||||
|
<ItemText>ball</ItemText>
|
||||||
|
>>>>>>> 上层测试
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>3</count>
|
<count>3</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
|
<<<<<<< HEAD
|
||||||
<ItemText>nucbuf</ItemText>
|
<ItemText>nucbuf</ItemText>
|
||||||
|
=======
|
||||||
|
<ItemText>and1</ItemText>
|
||||||
|
>>>>>>> 上层测试
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>4</count>
|
<count>4</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
|
<<<<<<< HEAD
|
||||||
<ItemText>nuc_v</ItemText>
|
<ItemText>nuc_v</ItemText>
|
||||||
|
=======
|
||||||
|
<ItemText>and1</ItemText>
|
||||||
|
>>>>>>> 上层测试
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>5</count>
|
<count>5</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
|
<<<<<<< HEAD
|
||||||
<ItemText>abc,0x0A</ItemText>
|
<ItemText>abc,0x0A</ItemText>
|
||||||
|
=======
|
||||||
|
<ItemText>nucbuf</ItemText>
|
||||||
|
>>>>>>> 上层测试
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>6</count>
|
<count>6</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
|
<<<<<<< HEAD
|
||||||
<ItemText>shoot_wait,0x0A</ItemText>
|
<ItemText>shoot_wait,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
@ -198,6 +218,11 @@
|
|||||||
</Ww>
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
=======
|
=======
|
||||||
|
>>>>>>> 上层测试
|
||||||
|
=======
|
||||||
|
<ItemText>drop_message,0x0A</ItemText>
|
||||||
|
</Ww>
|
||||||
|
</WatchWindow1>
|
||||||
>>>>>>> 上层测试
|
>>>>>>> 上层测试
|
||||||
<MemoryWindow4>
|
<MemoryWindow4>
|
||||||
<Mm>
|
<Mm>
|
||||||
@ -965,7 +990,7 @@
|
|||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>User/device</GroupName>
|
<GroupName>User/device</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
|
59
README.md
59
README.md
@ -5,19 +5,60 @@ r1上层
|
|||||||
## 外设
|
## 外设
|
||||||
|
|
||||||
+ CAN1
|
+ CAN1
|
||||||
- 扳机2006 id:0x205
|
+ 扳机2006 id:0x201
|
||||||
- 三摩擦 id:123
|
+ CAN2
|
||||||
|
+ 小米电机 id:1
|
||||||
+ UART
|
+ UART
|
||||||
- uart1 波特率4000000 id:2
|
+ uart1 波特率4000000 id:2
|
||||||
- uart6 nuc
|
+ uart6 nuc
|
||||||
- uart3 遥控器接收
|
+ uart3 遥控器接收
|
||||||
+ GPIO
|
+ GPIO
|
||||||
- PI6运球光电
|
+ PI6运球光电
|
||||||
- PE11 运球气缸
|
+ PE13 爪气缸
|
||||||
|
+ PE14 砸气缸
|
||||||
|
|
||||||
|
|
||||||
## 遥控器
|
## 遥控器
|
||||||
|
|
||||||
|
## 待解决
|
||||||
|
|
||||||
|
+ 用了将运球和伸缩绑定到一起 √
|
||||||
|
+ 串口收数加个滤波 √
|
||||||
|
|
||||||
|
## 思路
|
||||||
|
|
||||||
|
+ 👆 传球档 👆 配合档
|
||||||
|
+ 中 初始档 中 初始档
|
||||||
|
+ 👇 发射档 👇 运球档
|
||||||
|
+ 起步遥控档我直接蓄力准备接球 + 可多次的运球
|
||||||
|
+ 缩回转移球
|
||||||
|
+ 蓄力到位,收到掉落信号和已伸出信号
|
||||||
|
+ 根据视觉拟合信息的动态调整
|
||||||
|
+ 拨置👇发射清空掉落信号
|
||||||
|
|
||||||
|
+ 用一个攻守方档
|
||||||
|
+ 初始移动到最上面 更待蓄力(不管攻方守方都在最上面等待)
|
||||||
|
+ 攻方时拨下立马蓄力并伸出(可小角度)
|
||||||
|
+ 守方时不动并保持缩回
|
||||||
|
+ 👇 运球档正常运球
|
||||||
|
+ 中 初始档直接缩回
|
||||||
|
+ 👆 配合档 完成配合并伸出才能发射
|
||||||
|
|
||||||
|
+ 传球模式
|
||||||
|
+ 自动
|
||||||
|
+ 底盘的传球对准档拨下
|
||||||
|
+ 我的蓄力进入传球拟合
|
||||||
|
+ 继续拨下发射
|
||||||
|
+ 手动
|
||||||
|
+ 目前只能打固定距离
|
||||||
|
+ 切相同传球档 自动蓄力到传球力度
|
||||||
|
+ 发射档发射
|
||||||
|
+ 图传多距离
|
||||||
|
+ 传球档
|
||||||
|
+ 旋钮+看图传点位调整
|
||||||
|
|
||||||
|
+ 修复
|
||||||
|
+ 6.29 发射误操作导致没有拟合作用就射了(已修复)
|
||||||
|
+ 6.29 串口不稳定 重新拔插一下
|
||||||
|
+ 6.29 nuc位置更新慢
|
||||||
|
+ 6.29 添加光电上电保护防止跳尺(已添加)
|
||||||
|
|
@ -16,7 +16,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define ONE_CONTROL 0
|
#define ONE_CONTROL 1
|
||||||
|
|
||||||
//是否使用大疆DT7遥控器
|
//是否使用大疆DT7遥控器
|
||||||
#ifndef DT7
|
#ifndef DT7
|
||||||
|
@ -315,47 +315,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()
|
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 CHANEGE_POS -205
|
||||||
#define GO_ERROR 1.0f
|
#define GO_ERROR 1.0f
|
||||||
#define Tigger_DO -10
|
#define Tigger_DO -10
|
||||||
#define Tigger_ZERO 115
|
#define Tigger_ZERO 125
|
||||||
#define Tigger_ERROR 3
|
#define Tigger_ERROR 3
|
||||||
|
|
||||||
float knob_increment;
|
float knob_increment;
|
||||||
@ -171,6 +171,9 @@ int Shoot::GO_SendData(float pos, float limit)
|
|||||||
// sw[5] 👆 200 👇1800
|
// sw[5] 👆 200 👇1800
|
||||||
// 左旋 sw[7] 200 --1800
|
// 左旋 sw[7] 200 --1800
|
||||||
|
|
||||||
|
|
||||||
|
float and1=0.0f;
|
||||||
|
|
||||||
void Shoot::rc_mode()
|
void Shoot::rc_mode()
|
||||||
{
|
{
|
||||||
// 底部光电检测(假设0为到位,1为未到位,根据实际硬件调整)
|
// 底部光电检测(假设0为到位,1为未到位,根据实际硬件调整)
|
||||||
@ -222,23 +225,44 @@ void Shoot::rc_mode()
|
|||||||
{
|
{
|
||||||
ready_key = DEFENSE;
|
ready_key = DEFENSE;
|
||||||
}
|
}
|
||||||
|
//400--640为1 730--860为2 900到1200为3档中间 1300--1500为4
|
||||||
|
if(rc_ctrl.sw[7]<=300)
|
||||||
|
{
|
||||||
|
and1=0.0f;
|
||||||
|
}
|
||||||
|
if(rc_ctrl.sw[7]>=400&&rc_ctrl.sw[7]<=640)
|
||||||
|
{
|
||||||
|
and1=-2.0f;
|
||||||
|
}
|
||||||
|
if(rc_ctrl.sw[7]>=730&&rc_ctrl.sw[7]<=860)
|
||||||
|
{
|
||||||
|
and1=-1.0f;
|
||||||
|
}
|
||||||
|
if(rc_ctrl.sw[7]>=900&&rc_ctrl.sw[7]<=1200)
|
||||||
|
{
|
||||||
|
and1=0.0f;
|
||||||
|
}
|
||||||
|
if(rc_ctrl.sw[7]>=1300&&rc_ctrl.sw[7]<=1500)
|
||||||
|
{
|
||||||
|
and1=1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// 旋钮映射部分不变
|
// // 旋钮映射部分不变
|
||||||
const int knob_min = 200;
|
// const int knob_min = 200;
|
||||||
const int knob_max = 1800;
|
// const int knob_max = 1800;
|
||||||
const float map_min = 130.0f;
|
// const float map_min = 130.0f;
|
||||||
const float map_max = -60.0f;
|
// const float map_max = -60.0f;
|
||||||
int current_knob_value = rc_ctrl.sw[7];
|
// int current_knob_value = rc_ctrl.sw[7];
|
||||||
if (current_knob_value < knob_min)
|
// if (current_knob_value < knob_min)
|
||||||
current_knob_value = knob_min;
|
// current_knob_value = knob_min;
|
||||||
if (current_knob_value > knob_max)
|
// if (current_knob_value > knob_max)
|
||||||
current_knob_value = knob_max;
|
// current_knob_value = knob_max;
|
||||||
knob_increment = map_min + (map_max - map_min) * (current_knob_value - knob_min) / (knob_max - knob_min);
|
// knob_increment = map_min + (map_max - map_min) * (current_knob_value - knob_min) / (knob_max - knob_min);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ONE_CONTROL == 0
|
#if ONE_CONTROL == 0
|
||||||
|
|
||||||
float and1=0.0f;
|
|
||||||
void Shoot::shoot_control()
|
void Shoot::shoot_control()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -249,8 +273,8 @@ void Shoot::shoot_control()
|
|||||||
{
|
{
|
||||||
case VSION:
|
case VSION:
|
||||||
//fire_pos = distance; // 视觉拟合的力
|
//fire_pos = distance; // 视觉拟合的力
|
||||||
fire_pos =shoot_fitting(distance)+and1;
|
//fire_pos =shoot_fitting(distance)+and1;
|
||||||
//fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置
|
fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置
|
||||||
|
|
||||||
switch (rc_key)
|
switch (rc_key)
|
||||||
{
|
{
|
||||||
@ -415,8 +439,6 @@ void Shoot::RemoveError()
|
|||||||
|
|
||||||
#if ONE_CONTROL
|
#if ONE_CONTROL
|
||||||
|
|
||||||
//float and1=-1.5f;
|
|
||||||
float and1=0;
|
|
||||||
float and2=0;
|
float and2=0;
|
||||||
|
|
||||||
void Shoot::shoot_control()
|
void Shoot::shoot_control()
|
||||||
@ -433,7 +455,7 @@ void Shoot::shoot_control()
|
|||||||
switch (mode_key)
|
switch (mode_key)
|
||||||
{
|
{
|
||||||
case VSION:
|
case VSION:
|
||||||
fire_pos = shoot_fitting(distance)+and1; // 视觉拟合的力
|
fire_pos = shoot_fitting(distance)+and1;
|
||||||
//fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置
|
//fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置
|
||||||
|
|
||||||
switch (rc_key)
|
switch (rc_key)
|
||||||
@ -489,11 +511,10 @@ void Shoot::shoot_control()
|
|||||||
switch (rc_key)
|
switch (rc_key)
|
||||||
{
|
{
|
||||||
case MIDDLE1:
|
case MIDDLE1:
|
||||||
fire_pos = pass_fitting(pass_distance)+and2;
|
fire_pos = shoot_fitting(distance)+and1;
|
||||||
if ((shoot_thread & READY_TELL) && !(shoot_thread & EXTEND_OK))
|
if ((shoot_thread & READY_TELL) && !(shoot_thread & EXTEND_OK))
|
||||||
{
|
{
|
||||||
// 只收到READY_TELL且未收到EXTEND_OK时,顶部蓄力流程
|
ball_receive();
|
||||||
ball_receive(); // ball_receive内部写go1.Pos
|
|
||||||
}
|
}
|
||||||
else if (shoot_thread & EXTEND_OK)
|
else if (shoot_thread & EXTEND_OK)
|
||||||
{
|
{
|
||||||
@ -618,7 +639,7 @@ void Shoot ::ball_receive()
|
|||||||
break;
|
break;
|
||||||
case BAKC:
|
case BAKC:
|
||||||
control_pos = BOTTOM_POS;
|
control_pos = BOTTOM_POS;
|
||||||
limit_speed = TO_BOTTOM; // 慢速下来
|
limit_speed = 8.0f; // 慢速下来
|
||||||
if (feedback.fd_gopos >= BOTTOM_POS - 1.0f && feedback.fd_gopos <= BOTTOM_POS + 1.0f)
|
if (feedback.fd_gopos >= BOTTOM_POS - 1.0f && feedback.fd_gopos <= BOTTOM_POS + 1.0f)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -8,11 +8,7 @@
|
|||||||
#include "vofa.h"
|
#include "vofa.h"
|
||||||
extern RC_ctrl_t rc_ctrl;
|
extern RC_ctrl_t rc_ctrl;
|
||||||
Ball ball;
|
Ball ball;
|
||||||
//float vofa[8];
|
|
||||||
|
|
||||||
//检查光电
|
|
||||||
int abc=0;
|
|
||||||
int aaaa=146;
|
|
||||||
|
|
||||||
extern int speedm;
|
extern int speedm;
|
||||||
|
|
||||||
@ -32,20 +28,10 @@ void FunctionBall(void *argument)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
task_struct.stack_water_mark.ball = osThreadGetStackSpace(osThreadGetId());
|
task_struct.stack_water_mark.ball = osThreadGetStackSpace(osThreadGetId());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//abc=HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin);
|
|
||||||
abc=HAL_GPIO_ReadPin(BALL_GPIO_Port, BALL_Pin); // 0为到位
|
|
||||||
|
|
||||||
ball.rc_mode(); // 遥控器模式
|
ball.rc_mode(); // 遥控器模式
|
||||||
|
|
||||||
ball.ball_control(); // 控制球的动作
|
ball.ball_control(); // 控制球的动作
|
||||||
|
|
||||||
|
|
||||||
// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_SET); // 确保爪气缸关闭
|
|
||||||
// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_SET); // 确保下气缸关闭
|
|
||||||
// ball.xiaomi.position = aaaa;
|
|
||||||
// CAN_XiaoMi(1,&ball.xiaomi,&hcan2);
|
|
||||||
|
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
osDelayUntil(tick);
|
osDelayUntil(tick);
|
||||||
|
|
||||||
|
@ -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
|
|
@ -10,7 +10,7 @@ extern RC_ctrl_t rc_ctrl;
|
|||||||
Shoot shoot;
|
Shoot shoot;
|
||||||
NUC_t nucData; // 自瞄
|
NUC_t nucData; // 自瞄
|
||||||
|
|
||||||
int aaaxxx=0;
|
|
||||||
|
|
||||||
void FunctionShoot(void *argument)
|
void FunctionShoot(void *argument)
|
||||||
{
|
{
|
||||||
@ -35,13 +35,6 @@ while(1)
|
|||||||
|
|
||||||
shoot.shoot_control();
|
shoot.shoot_control();
|
||||||
|
|
||||||
// shoot.t_posSet=aaaxxx;
|
|
||||||
// shoot.trigger_control();
|
|
||||||
// shoot.GO_SendData(goangle,5);
|
|
||||||
// shoot.shoot_control();
|
|
||||||
// shoot.t_posSet=goangle;
|
|
||||||
// shoot.trigger_control();
|
|
||||||
|
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
osDelayUntil(tick);
|
osDelayUntil(tick);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user