加了视觉
This commit is contained in:
parent
a235d14661
commit
f9b87f8f39
@ -102,7 +102,7 @@ void MX_USART6_UART_Init(void)
|
|||||||
|
|
||||||
/* USER CODE END USART6_Init 1 */
|
/* USER CODE END USART6_Init 1 */
|
||||||
huart6.Instance = USART6;
|
huart6.Instance = USART6;
|
||||||
huart6.Init.BaudRate = 4000000;
|
huart6.Init.BaudRate = 115200;
|
||||||
huart6.Init.WordLength = UART_WORDLENGTH_8B;
|
huart6.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
huart6.Init.StopBits = UART_STOPBITS_1;
|
huart6.Init.StopBits = UART_STOPBITS_1;
|
||||||
huart6.Init.Parity = UART_PARITY_NONE;
|
huart6.Init.Parity = UART_PARITY_NONE;
|
||||||
|
2
MDK-ARM/.vscode/keil-assistant.log
vendored
2
MDK-ARM/.vscode/keil-assistant.log
vendored
@ -122,3 +122,5 @@
|
|||||||
|
|
||||||
[info] Log at : 2025/5/30|19:34:50|GMT+0800
|
[info] Log at : 2025/5/30|19:34:50|GMT+0800
|
||||||
|
|
||||||
|
[info] Log at : 2025/5/31|14:39:23|GMT+0800
|
||||||
|
|
||||||
|
6
MDK-ARM/.vscode/uv4.log
vendored
6
MDK-ARM/.vscode/uv4.log
vendored
@ -1,8 +1,8 @@
|
|||||||
*** 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-shooter'
|
Build target 'R1-shooter'
|
||||||
compiling ball.cpp...
|
compiling usart.c...
|
||||||
linking...
|
linking...
|
||||||
Program Size: Code=30584 RO-data=2144 RW-data=276 ZI-data=24012
|
Program Size: Code=30588 RO-data=2144 RW-data=276 ZI-data=24012
|
||||||
FromELF: creating hex file...
|
FromELF: creating hex file...
|
||||||
"R1-shooter\R1-shooter.axf" - 0 Error(s), 0 Warning(s).
|
"R1-shooter\R1-shooter.axf" - 0 Error(s), 0 Warning(s).
|
||||||
Build Time Elapsed: 00:00:03
|
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/5/28 19:17:30
|
2025/5/31 16:57:56
|
@ -218,85 +218,55 @@
|
|||||||
<Ww>
|
<Ww>
|
||||||
<count>12</count>
|
<count>12</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>ball_state,0x0A</ItemText>
|
<ItemText>shoot,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>13</count>
|
<count>13</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>flag,0x0A</ItemText>
|
<ItemText>speedm,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>14</count>
|
<count>14</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>shoot,0x0A</ItemText>
|
<ItemText>shoot_flag,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>15</count>
|
<count>15</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>speedm,0x0A</ItemText>
|
<ItemText>angle1,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>16</count>
|
<count>16</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>a1,0x0A</ItemText>
|
<ItemText>motor_5065</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>17</count>
|
<count>17</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>a2,0x0A</ItemText>
|
<ItemText>test_distance</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>18</count>
|
<count>18</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>shoot_flag,0x0A</ItemText>
|
<ItemText>xxx</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>19</count>
|
<count>19</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>angle1,0x0A</ItemText>
|
<ItemText>test_speed,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>20</count>
|
<count>20</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>rx_header</ItemText>
|
<ItemText>speedm,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>21</count>
|
<count>21</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>rx_data</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>22</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>motor_5065</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>23</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>test_distance</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>24</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>xxx</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>25</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>test_speed,0x0A</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>26</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>speedm,0x0A</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>27</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>Torque,0x0A</ItemText>
|
<ItemText>Torque,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>28</count>
|
<count>22</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>triggerspeed,0x0A</ItemText>
|
<ItemText>triggerspeed,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
|
@ -32,7 +32,7 @@ void GO_M8010_init (){
|
|||||||
|
|
||||||
}
|
}
|
||||||
// HAL_UART_RegisterCallback(&huart1, HAL_UART_TX_COMPLETE_CB_ID, uartTxCB);
|
// HAL_UART_RegisterCallback(&huart1, HAL_UART_TX_COMPLETE_CB_ID, uartTxCB);
|
||||||
HAL_UART_RegisterCallback(&huart6, HAL_UART_TX_COMPLETE_CB_ID, uartTxCB);
|
// HAL_UART_RegisterCallback(&huart6, HAL_UART_TX_COMPLETE_CB_ID, uartTxCB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,18 +77,11 @@ int8_t NUC_RawParse(NUC_t *n) {
|
|||||||
} instance; // 方便在浮点数和字符数组之间进行数据转换
|
} instance; // 方便在浮点数和字符数组之间进行数据转换
|
||||||
|
|
||||||
// 校验数据包头
|
// 校验数据包头
|
||||||
if (nucbuf[0] != HEAD) {
|
if(nucbuf[0]!=HEAD) goto error; //发送ID不是底盘
|
||||||
return DEVICE_ERR;
|
else
|
||||||
}
|
{
|
||||||
// 提取数据包中的 CRC 值(假设 CRC 值在数据包的最后两个字节)
|
|
||||||
uint16_t received_crc = (nucbuf[16] << 8) | nucbuf[17]; // 假设 CRC 在第 16 和 17 字节
|
|
||||||
uint16_t calculated_crc = do_crc_table(nucbuf, 16); // 计算前 16 字节的 CRC
|
|
||||||
// 校验 CRC
|
|
||||||
if (received_crc == calculated_crc) {
|
|
||||||
|
|
||||||
n->status_fromnuc = nucbuf[1];
|
n->status_fromnuc = nucbuf[1];
|
||||||
n->ctrl_status = nucbuf[2];
|
n->ctrl_status = nucbuf[2];
|
||||||
|
|
||||||
switch (n->status_fromnuc) {
|
switch (n->status_fromnuc) {
|
||||||
case VISION:
|
case VISION:
|
||||||
/* 协议格式
|
/* 协议格式
|
||||||
@ -120,22 +113,83 @@ int8_t NUC_RawParse(NUC_t *n) {
|
|||||||
instance.data[8] = nucbuf[14];
|
instance.data[8] = nucbuf[14];
|
||||||
n->vision.z = instance.x[2];
|
n->vision.z = instance.x[2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return DEVICE_OK;
|
return DEVICE_OK;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return DEVICE_ERR;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
error:
|
error:
|
||||||
return DEVICE_ERR;
|
return DEVICE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// int8_t NUC_RawParse(NUC_t *n) {
|
||||||
|
// if (n == NULL) return DEVICE_ERR_NULL;
|
||||||
|
// union {
|
||||||
|
// float x[3];
|
||||||
|
// char data[12];
|
||||||
|
// } instance; // 方便在浮点数和字符数组之间进行数据转换
|
||||||
|
|
||||||
|
// // 校验数据包头
|
||||||
|
// if (nucbuf[0] != HEAD) {
|
||||||
|
// return DEVICE_ERR;
|
||||||
|
// }
|
||||||
|
// // 提取数据包中的 CRC 值(假设 CRC 值在数据包的最后两个字节)
|
||||||
|
// uint16_t received_crc = (nucbuf[16] << 8) | nucbuf[17]; // 假设 CRC 在第 16 和 17 字节
|
||||||
|
// uint16_t calculated_crc = do_crc_table(nucbuf, 16); // 计算前 16 字节的 CRC
|
||||||
|
// // 校验 CRC
|
||||||
|
// if (received_crc == calculated_crc) {
|
||||||
|
|
||||||
|
// n->status_fromnuc = nucbuf[1];
|
||||||
|
// n->ctrl_status = nucbuf[2];
|
||||||
|
|
||||||
|
// switch (n->status_fromnuc) {
|
||||||
|
// case VISION:
|
||||||
|
// /* 协议格式
|
||||||
|
// 0xFF HEAD
|
||||||
|
// 0x02 控制帧
|
||||||
|
// 0x01 相机帧
|
||||||
|
// x fp32
|
||||||
|
// y fp32
|
||||||
|
// z fp32
|
||||||
|
// 0xFE TAIL
|
||||||
|
// */
|
||||||
|
// if (nucbuf[15] != TAIL) goto error;
|
||||||
|
|
||||||
|
// instance.data[3] = nucbuf[3];
|
||||||
|
// instance.data[2] = nucbuf[4];
|
||||||
|
// instance.data[1] = nucbuf[5];
|
||||||
|
// instance.data[0] = nucbuf[6];
|
||||||
|
// n->vision.x = instance.x[0];
|
||||||
|
|
||||||
|
// instance.data[7] = nucbuf[7];
|
||||||
|
// instance.data[6] = nucbuf[8];
|
||||||
|
// instance.data[5] = nucbuf[9];
|
||||||
|
// instance.data[4] = nucbuf[10];
|
||||||
|
// n->vision.y = instance.x[1];
|
||||||
|
|
||||||
|
// instance.data[11] = nucbuf[11];
|
||||||
|
// instance.data[10] = nucbuf[12];
|
||||||
|
// instance.data[9] = nucbuf[13];
|
||||||
|
// instance.data[8] = nucbuf[14];
|
||||||
|
// n->vision.z = instance.x[2];
|
||||||
|
// break;
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
// return DEVICE_OK;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return DEVICE_ERR;
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// error:
|
||||||
|
// return DEVICE_ERR;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
int8_t NUC_HandleOffline(NUC_t *cmd)
|
int8_t NUC_HandleOffline(NUC_t *cmd)
|
||||||
{
|
{
|
||||||
if(cmd == NULL) return DEVICE_ERR_NULL;
|
if(cmd == NULL) return DEVICE_ERR_NULL;
|
||||||
|
@ -16,8 +16,8 @@ float vofa[8];
|
|||||||
#define Error 50
|
#define Error 50
|
||||||
|
|
||||||
int triggerspeed = -5000; // 扳机速度
|
int triggerspeed = -5000; // 扳机速度
|
||||||
int test_speed =34700;
|
int test_speed =35200;
|
||||||
float test_distance =3.6;
|
float test_distance =1;
|
||||||
float xxx;
|
float xxx;
|
||||||
|
|
||||||
#define STOP 0
|
#define STOP 0
|
||||||
@ -78,7 +78,7 @@ void Shoot::errorControl()
|
|||||||
void Shoot :: distanceGet(const NUC_t &nuc_v)
|
void Shoot :: distanceGet(const NUC_t &nuc_v)
|
||||||
{
|
{
|
||||||
|
|
||||||
test_distance=nuc_v.vision.z;
|
test_distance=nuc_v.vision.x; // 获取自瞄数据
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +115,8 @@ void Shoot::shootStateMachine() {
|
|||||||
case SHOOT_READY:
|
case SHOOT_READY:
|
||||||
{
|
{
|
||||||
// 发射状态,控制电机发射
|
// 发射状态,控制电机发射
|
||||||
speed_5065 = test_speed;
|
//speed_5065 = test_speed;
|
||||||
// speed_5065 =polynomial(distance);
|
speed_5065 =polynomial(distance);
|
||||||
if(motor_5065[0]->rotor_speed>=speed_5065-Error && motor_5065[0]->rotor_speed<=speed_5065+Error &&
|
if(motor_5065[0]->rotor_speed>=speed_5065-Error && motor_5065[0]->rotor_speed<=speed_5065+Error &&
|
||||||
motor_5065[1]->rotor_speed>=speed_5065-Error && motor_5065[1]->rotor_speed<=speed_5065+Error)
|
motor_5065[1]->rotor_speed>=speed_5065-Error && motor_5065[1]->rotor_speed<=speed_5065+Error)
|
||||||
{
|
{
|
||||||
@ -178,24 +178,10 @@ void Shoot::shootStateMachine() {
|
|||||||
|
|
||||||
//MATLAB拟合函数
|
//MATLAB拟合函数
|
||||||
float polynomial(float x) {
|
float polynomial(float x) {
|
||||||
return 1185.3918f * powf(x, 5.0f)
|
return 6348.2377f * powf(x, 5.0f)
|
||||||
+ -45876.846f * powf(x, 4.0f)
|
+ -128275.8296f * powf(x, 4.0f)
|
||||||
+ 517061.22f * powf(x, 3.0f)
|
+ 1030651.0231f * powf(x, 3.0f)
|
||||||
+ -2567947.4f * powf(x, 2.0f)
|
+ -4115199.9362f * powf(x, 2.0f)
|
||||||
+ 5954537.4f * x
|
+ 8167973.1254f * x
|
||||||
+ -5258769.0f;
|
+ -6420648.3555f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float polynomial2(float x) {
|
|
||||||
return 49162.7402f * powf(x, 5.0f)
|
|
||||||
+ -917344.6015f * powf(x, 4.0f)
|
|
||||||
+ 6840516.5228f * powf(x, 3.0f)
|
|
||||||
+ -25479457.6038f * powf(x, 2.0f)
|
|
||||||
+ 47406744.9129f * x
|
|
||||||
+ -35217628.5565f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// float polynomial(float x) {
|
|
||||||
// return 1185.3918*pow(x,5) + -45876.846*pow(x,4) + 517061.22*pow(x,3) + -2567947.4*pow(x,2) + 5954537.4*x + -5258769;
|
|
||||||
// }
|
|
||||||
|
@ -22,7 +22,6 @@ void Function_nuc(void *argument)
|
|||||||
|
|
||||||
NUC_Init(&cmd_fromnuc);
|
NUC_Init(&cmd_fromnuc);
|
||||||
|
|
||||||
|
|
||||||
uint32_t tick = osKernelGetTickCount();
|
uint32_t tick = osKernelGetTickCount();
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
|
@ -45,7 +45,7 @@ while(1)
|
|||||||
|
|
||||||
if (osMessageQueueGet(task_struct.msgq.nuc, &nucData, NULL, 0) == osOK)
|
if (osMessageQueueGet(task_struct.msgq.nuc, &nucData, NULL, 0) == osOK)
|
||||||
{
|
{
|
||||||
//shoot.distanceGet(nucData);
|
shoot.distanceGet(nucData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user