sick转接,无报错
This commit is contained in:
parent
5556d48921
commit
afdb0edbc3
108
MDK-ARM/.vscode/c_cpp_properties.json
vendored
108
MDK-ARM/.vscode/c_cpp_properties.json
vendored
@ -415,6 +415,114 @@
|
|||||||
"__vfp_status(x,y)=0"
|
"__vfp_status(x,y)=0"
|
||||||
],
|
],
|
||||||
"intelliSenseMode": "${default}"
|
"intelliSenseMode": "${default}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "R2",
|
||||||
|
"includePath": [
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Core\\Inc",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Drivers\\STM32F4xx_HAL_Driver\\Inc",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Drivers\\STM32F4xx_HAL_Driver\\Inc\\Legacy",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Middlewares\\Third_Party\\FreeRTOS\\Source\\include",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Middlewares\\Third_Party\\FreeRTOS\\Source\\CMSIS_RTOS_V2",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Middlewares\\Third_Party\\FreeRTOS\\Source\\portable\\RVDS\\ARM_CM4F",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Drivers\\CMSIS\\Device\\ST\\STM32F4xx\\Include",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Drivers\\CMSIS\\Include",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\User",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\User\\bsp",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\User\\device",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\User\\task",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\User\\Algorithm",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\User\\Module",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\MDK-ARM",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\USB_DEVICE\\App",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\USB_DEVICE\\Target",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Middlewares\\ST\\STM32_USB_Device_Library\\Core\\Inc",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\CDC\\Inc",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Drivers\\CMSIS\\Lib\\ARM",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Core\\Src",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Drivers\\STM32F4xx_HAL_Driver\\Src",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Middlewares\\Third_Party\\FreeRTOS\\Source",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Middlewares\\Third_Party\\FreeRTOS\\Source\\portable\\MemMang",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Middlewares\\ST\\STM32_USB_Device_Library\\Core\\Src",
|
||||||
|
"d:\\Desktop\\r2\\R2_NEW\\R2\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\CDC\\Src"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"USE_HAL_DRIVER",
|
||||||
|
"STM32F407xx",
|
||||||
|
"__CC_ARM",
|
||||||
|
"__arm__",
|
||||||
|
"__align(x)=",
|
||||||
|
"__ALIGNOF__(x)=",
|
||||||
|
"__alignof__(x)=",
|
||||||
|
"__asm(x)=",
|
||||||
|
"__forceinline=",
|
||||||
|
"__restrict=",
|
||||||
|
"__global_reg(n)=",
|
||||||
|
"__inline=",
|
||||||
|
"__int64=long long",
|
||||||
|
"__INTADDR__(expr)=0",
|
||||||
|
"__irq=",
|
||||||
|
"__packed=",
|
||||||
|
"__pure=",
|
||||||
|
"__smc(n)=",
|
||||||
|
"__svc(n)=",
|
||||||
|
"__svc_indirect(n)=",
|
||||||
|
"__svc_indirect_r7(n)=",
|
||||||
|
"__value_in_regs=",
|
||||||
|
"__weak=",
|
||||||
|
"__writeonly=",
|
||||||
|
"__declspec(x)=",
|
||||||
|
"__attribute__(x)=",
|
||||||
|
"__nonnull__(x)=",
|
||||||
|
"__register=",
|
||||||
|
"__breakpoint(x)=",
|
||||||
|
"__cdp(x,y,z)=",
|
||||||
|
"__clrex()=",
|
||||||
|
"__clz(x)=0U",
|
||||||
|
"__current_pc()=0U",
|
||||||
|
"__current_sp()=0U",
|
||||||
|
"__disable_fiq()=",
|
||||||
|
"__disable_irq()=",
|
||||||
|
"__dmb(x)=",
|
||||||
|
"__dsb(x)=",
|
||||||
|
"__enable_fiq()=",
|
||||||
|
"__enable_irq()=",
|
||||||
|
"__fabs(x)=0.0",
|
||||||
|
"__fabsf(x)=0.0f",
|
||||||
|
"__force_loads()=",
|
||||||
|
"__force_stores()=",
|
||||||
|
"__isb(x)=",
|
||||||
|
"__ldrex(x)=0U",
|
||||||
|
"__ldrexd(x)=0U",
|
||||||
|
"__ldrt(x)=0U",
|
||||||
|
"__memory_changed()=",
|
||||||
|
"__nop()=",
|
||||||
|
"__pld(...)=",
|
||||||
|
"__pli(...)=",
|
||||||
|
"__qadd(x,y)=0",
|
||||||
|
"__qdbl(x)=0",
|
||||||
|
"__qsub(x,y)=0",
|
||||||
|
"__rbit(x)=0U",
|
||||||
|
"__rev(x)=0U",
|
||||||
|
"__return_address()=0U",
|
||||||
|
"__ror(x,y)=0U",
|
||||||
|
"__schedule_barrier()=",
|
||||||
|
"__semihost(x,y)=0",
|
||||||
|
"__sev()=",
|
||||||
|
"__sqrt(x)=0.0",
|
||||||
|
"__sqrtf(x)=0.0f",
|
||||||
|
"__ssat(x,y)=0",
|
||||||
|
"__strex(x,y)=0U",
|
||||||
|
"__strexd(x,y)=0",
|
||||||
|
"__strt(x,y)=",
|
||||||
|
"__swp(x,y)=0U",
|
||||||
|
"__usat(x,y)=0U",
|
||||||
|
"__wfe()=",
|
||||||
|
"__wfi()=",
|
||||||
|
"__yield()=",
|
||||||
|
"__vfp_status(x,y)=0"
|
||||||
|
],
|
||||||
|
"intelliSenseMode": "${default}"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": 4
|
"version": 4
|
||||||
|
8
MDK-ARM/.vscode/keil-assistant.log
vendored
8
MDK-ARM/.vscode/keil-assistant.log
vendored
@ -451,3 +451,11 @@
|
|||||||
|
|
||||||
[info] Log at : 2025/3/28|21:46:16|GMT+0800
|
[info] Log at : 2025/3/28|21:46:16|GMT+0800
|
||||||
|
|
||||||
|
[info] Log at : 2025/6/6|21:51:18|GMT+0800
|
||||||
|
|
||||||
|
[info] Log at : 2025/6/7|17:45:08|GMT+0800
|
||||||
|
|
||||||
|
[info] Log at : 2025/6/7|21:03:23|GMT+0800
|
||||||
|
|
||||||
|
[info] Log at : 2025/6/12|16:54:50|GMT+0800
|
||||||
|
|
||||||
|
3
MDK-ARM/.vscode/settings.json
vendored
3
MDK-ARM/.vscode/settings.json
vendored
@ -96,6 +96,7 @@
|
|||||||
"limits": "c",
|
"limits": "c",
|
||||||
"gimbal_task.h": "c",
|
"gimbal_task.h": "c",
|
||||||
"gimgal.h": "c",
|
"gimgal.h": "c",
|
||||||
"navi.h": "c"
|
"navi.h": "c",
|
||||||
|
"up.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -158,197 +158,102 @@
|
|||||||
<Ww>
|
<Ww>
|
||||||
<count>0</count>
|
<count>0</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>rc_ctrl,0x0A</ItemText>
|
<ItemText>Nor_Vx</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>1</count>
|
<count>1</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>LD_raw,0x0A</ItemText>
|
<ItemText>Nor_Vy</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>2</count>
|
<count>2</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>can,0x0A</ItemText>
|
<ItemText>count,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>3</count>
|
<count>3</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>UP,0x0A</ItemText>
|
<ItemText>count</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>4</count>
|
<count>4</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>cmd_rc,0x0A</ItemText>
|
<ItemText>pid</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>5</count>
|
<count>5</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>chassis</ItemText>
|
<ItemText>BMI088_t</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>6</count>
|
<count>6</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>nuc_raw,0x0A</ItemText>
|
<ItemText>up,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>7</count>
|
<count>7</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>nucbuf</ItemText>
|
<ItemText>low,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>8</count>
|
<count>8</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>cmd_fromnuc</ItemText>
|
<ItemText>UP,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>9</count>
|
<count>9</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>up_cmd,0x0A</ItemText>
|
<ItemText>send,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>10</count>
|
<count>10</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>can_out</ItemText>
|
<ItemText>cmd,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>11</count>
|
<count>11</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>Nor_Vx</ItemText>
|
<ItemText>rc_ctrl,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>12</count>
|
<count>12</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>Nor_Vy</ItemText>
|
<ItemText>a,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>13</count>
|
<count>13</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>b</ItemText>
|
<ItemText>delay_aa,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>14</count>
|
<count>14</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>count,0x0A</ItemText>
|
<ItemText>aaaaaaaaaaa,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>15</count>
|
<count>15</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>count</ItemText>
|
<ItemText>task_runtime,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>16</count>
|
<count>16</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>raw_rx1,0x0A</ItemText>
|
<ItemText>last_tick,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>17</count>
|
<count>17</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>gyro_kp,0x0A</ItemText>
|
<ItemText>chassis,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>18</count>
|
<count>18</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>nucbuf,0x0A</ItemText>
|
<ItemText>can,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>19</count>
|
<count>19</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>vofa_send,0x0A</ItemText>
|
<ItemText>can_rx,0x0A</ItemText>
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>20</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>SendBuffer,0x10</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>21</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>NUC_StartSending,0x0A</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>22</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>PIAN</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>23</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>pid</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>24</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>bmi088</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>25</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>ist8310</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>26</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>imu_eulr,0x0A</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>27</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>imu_temp,0x0A</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>28</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>htim10,0x0A</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>29</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>pulse</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>30</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>imu_temp</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>31</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>cmd</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>32</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>NUC_send</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>33</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>BMI088_t</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>34</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>bmi088</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>35</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>up,0x0A</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>36</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>low,0x0A</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>37</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>NUC_send</ItemText>
|
|
||||||
</Ww>
|
|
||||||
<Ww>
|
|
||||||
<count>38</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>cmd_fromnuc</ItemText>
|
|
||||||
</Ww>
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
<Tracepoint>
|
<Tracepoint>
|
||||||
|
Binary file not shown.
@ -190,40 +190,48 @@ c->NUC_send .send [1]=1;
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
sick0,左1
|
sick0,下
|
||||||
sick1,左2
|
sick1,左2
|
||||||
sick2,下1
|
sick2,左1
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//int8_t sick_calibration(Chassis_t *c, CMD_t *ctrl, CAN_Output_t *out)
|
int8_t sick_calibration(Chassis_t *c, CMD_t *ctrl, CAN_Output_t *out)
|
||||||
//{
|
{
|
||||||
//// int32_t x_set;
|
if (c == NULL) return CHASSIS_ERR_NULL;
|
||||||
//// int32_t y_set;
|
if (ctrl == NULL) return CHASSIS_ERR_NULL;
|
||||||
// if (c == NULL) return CHASSIS_ERR_NULL;
|
|
||||||
// if (ctrl == NULL) return CHASSIS_ERR_NULL;
|
|
||||||
//
|
|
||||||
// //yaw修正
|
|
||||||
// if(fabs((fp32)c->sick_cali .sick_dis [0]-c->sick_cali .sick_dis [1])>(fp32)c->sick_cali .sickparam.w_error){
|
|
||||||
// c->move_vec .Vw = PID_calc(&(c->pid .chassis_SickVxPID ),c->sick_cali .sick_dis [0],c->sick_cali .sick_dis [1]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// else { //大于误差
|
|
||||||
// if(fabs((fp32)c->sick_cali .sick_dis[0]-c->sick_cali .sick_dis[1])>c->sick_cali .sickparam .xy_error)
|
fp32 sick0 = c->sick_cali.sick_dis[0];
|
||||||
// {//xy修正
|
fp32 sick1 = c->sick_cali.sick_dis[1];
|
||||||
// c->move_vec .Vx =PID_calc (&(c->pid .chassis_SickVxPID ),c->sick_cali .sick_dis [0], c->sick_cali .sickparam.x_set);
|
fp32 sick2 = c->sick_cali.sick_dis[2];
|
||||||
// c->move_vec .Vy =PID_calc (&(c->pid .chassis_SickVyPID),c->sick_cali .sick_dis [2], c->sick_cali .sickparam.y_set);
|
const sickparam_t *param = &c->sick_cali.sickparam;
|
||||||
// }
|
|
||||||
// else {//修正OK后,给nuc返回值
|
fp32 diff = fabsf(sick0 - sick1);
|
||||||
//
|
|
||||||
//
|
// 1. yaw修正
|
||||||
// }
|
if (diff > param->w_error) {
|
||||||
//
|
c->move_vec.Vw = PID_calc(&(c->pid.chassis_SickVxPID), diff, 0);
|
||||||
//
|
c->move_vec.Vx = 0;
|
||||||
// }
|
c->move_vec.Vy = 0;
|
||||||
//
|
}
|
||||||
//}
|
// 2. xy修正
|
||||||
|
else if (diff > param->xy_error) {
|
||||||
|
c->move_vec.Vw = 0;
|
||||||
|
c->move_vec.Vx = PID_calc(&(c->pid.chassis_SickVxPID), sick0, param->x_set);
|
||||||
|
c->move_vec.Vy = PID_calc(&(c->pid.chassis_SickVyPID), sick2, param->y_set);
|
||||||
|
}
|
||||||
|
// 3. 修正完成
|
||||||
|
else {
|
||||||
|
c->move_vec.Vw = 0;
|
||||||
|
c->move_vec.Vx = 0;
|
||||||
|
c->move_vec.Vy = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return CHASSIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,13 +95,13 @@ static const ConfigParam_t param ={
|
|||||||
|
|
||||||
/*上层其他参数*/
|
/*上层其他参数*/
|
||||||
/*运球*/
|
/*运球*/
|
||||||
.DribbleConfig_Config = {
|
.DribbleCfg = {
|
||||||
.dribble_flag=0,
|
.dribble_flag=0,
|
||||||
.m3508_init_angle = -5,
|
.m3508_init_ang = -5,
|
||||||
.m3508_translate_angle = 1000,
|
.m3508_translate_angle = 1000,
|
||||||
.m3508_dribble_Reverse_speed=-3500,
|
.rev_spd=-1500,
|
||||||
.m3508_dribble_speed= 4000, // 转动速度
|
.spd= 4000, // 转动速度
|
||||||
.m3508_dribble_init_speed=0,
|
.init_spd=0,
|
||||||
|
|
||||||
.light_3508_flag=0,//3508平移处的光电,0初始,1到位置
|
.light_3508_flag=0,//3508平移处的光电,0初始,1到位置
|
||||||
.light_ball_flag=0,//检测球的flag
|
.light_ball_flag=0,//检测球的flag
|
||||||
@ -109,21 +109,17 @@ static const ConfigParam_t param ={
|
|||||||
|
|
||||||
},
|
},
|
||||||
/*投球*/
|
/*投球*/
|
||||||
.PitchConfig_Config = {
|
.PitchCfg = {
|
||||||
.m2006_init_angle =-100,
|
.m2006_init =-100, //释放的角度
|
||||||
.m2006_trigger_angle =0,
|
.m2006_trig =0, //可以拉住发射的角度
|
||||||
.go1_init_position = -50,
|
.go_init = -50, //仅用在go上电,初始位置
|
||||||
.go1_Receive_ball = -5, //偏下
|
.go_pull_pos =-210,
|
||||||
.go1_release_threshold =-210,
|
|
||||||
.m2006_Screw_init=0,
|
|
||||||
.Pitch_angle =58,
|
.Pitch_angle =58,
|
||||||
|
|
||||||
.pull_speed =5,
|
.pull_speed =5,
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
.chassis = {/**/
|
.chassis = {/**/
|
||||||
|
|
||||||
@ -172,8 +168,8 @@ static const ConfigParam_t param ={
|
|||||||
.out_limit =0.0f,
|
.out_limit =0.0f,
|
||||||
},
|
},
|
||||||
.sickparam={
|
.sickparam={
|
||||||
.w_error=1000,
|
.w_error=5000,
|
||||||
.xy_error=1000,
|
.xy_error=5000,
|
||||||
.x_set=1000,
|
.x_set=1000,
|
||||||
.y_set=1000,
|
.y_set=1000,
|
||||||
|
|
||||||
|
200
User/Module/up.c
200
User/Module/up.c
@ -53,17 +53,17 @@ int8_t up_init(UP_t *u,const UP_Param_t *param,float target_freq)
|
|||||||
|
|
||||||
|
|
||||||
// 初始化上层状态机
|
// 初始化上层状态机
|
||||||
if (!u->DribbleContext .is_initialized) { //检查是否为第一次运行状态机,运球
|
if (!u->DribbleCont .is_init) { //检查是否为第一次运行状态机,运球
|
||||||
u->DribbleContext .DribbleConfig = u->param ->DribbleConfig_Config ;//赋值
|
u->DribbleCont .DribbleConfig = u->param ->DribbleCfg ;//赋值
|
||||||
u->DribbleContext .DribbleState = DRIBBLE_PREPARE;
|
u->DribbleCont .DribbleState = DRIBBLE_PREPARE;
|
||||||
u->DribbleContext .is_initialized = 1;
|
u->DribbleCont .is_init = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!u->PitchContext .is_initialized) {
|
if (!u->Pitch_Cfg .is_init) {
|
||||||
u->PitchContext .PitchConfig = u->param ->PitchConfig_Config ;//赋值
|
u->Pitch_Cfg .PitchConfig = u->param ->PitchCfg ;//赋值
|
||||||
u->PitchContext .PitchState = PITCH_PREPARE; //状态更新,开始夹球
|
u->Pitch_Cfg .PitchState = PITCH_PREPARE; //状态更新,开始夹球
|
||||||
u->PitchContext .is_initialized = 1;
|
u->Pitch_Cfg .is_init = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
BSP_UART_RegisterCallback(BSP_UART_RS485, BSP_UART_RX_CPLT_CB, USART6_RxCompleteCallback);//注册串口回调函数,bsp层
|
BSP_UART_RegisterCallback(BSP_UART_RS485, BSP_UART_RX_CPLT_CB, USART6_RxCompleteCallback);//注册串口回调函数,bsp层
|
||||||
@ -96,8 +96,8 @@ int8_t UP_UpdateFeedback(UP_t *u, const CAN_t *can, CMD_t *c) {
|
|||||||
|
|
||||||
u->cmd =c;
|
u->cmd =c;
|
||||||
/*光电状态更新*/
|
/*光电状态更新*/
|
||||||
u->DribbleContext .DribbleConfig .light_ball_flag =HAL_GPIO_ReadPin(LIGHT_C_GPIO_Port ,LIGHT_C_Pin);
|
u->DribbleCont .DribbleConfig .light_ball_flag =HAL_GPIO_ReadPin(LIGHT_C_GPIO_Port ,LIGHT_C_Pin);
|
||||||
u->DribbleContext .DribbleConfig .light_3508_flag =HAL_GPIO_ReadPin(LIGHT_B_GPIO_Port ,LIGHT_B_Pin);
|
u->DribbleCont .DribbleConfig .light_3508_flag =HAL_GPIO_ReadPin(LIGHT_B_GPIO_Port ,LIGHT_B_Pin);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -168,17 +168,8 @@ int8_t GO_SendData(UP_t *u, float pos, float limit)
|
|||||||
static int is_calibration=0;
|
static int is_calibration=0;
|
||||||
static fp32 error=0; //误差量
|
static fp32 error=0; //误差量
|
||||||
|
|
||||||
// GO_MotorData_t *GO_calibration;//校准前,原始数据
|
|
||||||
u->motorfeedback .go_data = get_GO_measure_point() ;
|
u->motorfeedback .go_data = get_GO_measure_point() ;
|
||||||
// if(is_calibration==0)
|
|
||||||
// {
|
|
||||||
// is_calibration=HAL_GPIO_ReadPin (GPIOE ,GPIO_PIN_9 );
|
|
||||||
// u->go_cmd.Pos = -50; //上电之后跑
|
|
||||||
// error= GO_calibration->Pos ;
|
|
||||||
// }
|
|
||||||
// u->motorfeedback .go_data = GO_calibration;
|
|
||||||
// u->motorfeedback .go_data ->Pos= error ;
|
|
||||||
// u->go_cmd.Pos = pos;
|
|
||||||
|
|
||||||
// 读取参数
|
// 读取参数
|
||||||
float tff = u->go_cmd.T; // 前馈力矩
|
float tff = u->go_cmd.T; // 前馈力矩
|
||||||
@ -233,7 +224,7 @@ int8_t ALL_Motor_Control(UP_t *u,CAN_Output_t *out)
|
|||||||
|
|
||||||
GO_SendData(u,
|
GO_SendData(u,
|
||||||
u->motor_target .go_shoot,
|
u->motor_target .go_shoot,
|
||||||
u->PitchContext .PitchConfig .pull_speed );//对应的拉动速度
|
u->Pitch_Cfg .PitchConfig .pull_speed );//对应的拉动速度
|
||||||
|
|
||||||
|
|
||||||
for(int i=0;i<4;i++){
|
for(int i=0;i<4;i++){
|
||||||
@ -251,18 +242,23 @@ int8_t ALL_Motor_Control(UP_t *u,CAN_Output_t *out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int a=0;
|
|
||||||
int b=0;
|
|
||||||
|
|
||||||
|
|
||||||
int8_t UP_control(UP_t *u,CAN_Output_t *out,CMD_t *c)
|
int8_t UP_control(UP_t *u,CAN_Output_t *out,CMD_t *c)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(u ==NULL) return 0;
|
if(u ==NULL) return 0;
|
||||||
|
if(out ==NULL) return 0;
|
||||||
|
if(c ==NULL) return 0;
|
||||||
|
|
||||||
|
/*指针简化*/
|
||||||
|
PitchCfg_t *pitch_cfg = &u->Pitch_Cfg.PitchConfig;
|
||||||
|
DribbleCfg_t *DribbleCont = &u->DribbleCont.DribbleConfig;
|
||||||
|
|
||||||
|
up_motor_target_t *target=&u->motor_target ;
|
||||||
static int is_pitch=1;
|
static int is_pitch=1;
|
||||||
|
|
||||||
/*config值限位*/
|
/*config值限位*/
|
||||||
abs_limit_min_max_fp(&u->PitchContext.PitchConfig.go1_Receive_ball ,-208.0f,2.0f);
|
abs_limit_min_max_fp(&u->Pitch_Cfg.PitchConfig.go_release_pos ,-208.0f,2.0f);
|
||||||
|
|
||||||
|
|
||||||
switch (c->CMD_CtrlType )
|
switch (c->CMD_CtrlType )
|
||||||
@ -275,53 +271,49 @@ int8_t UP_control(UP_t *u,CAN_Output_t *out,CMD_t *c)
|
|||||||
case Normal :
|
case Normal :
|
||||||
/*投篮*/
|
/*投篮*/
|
||||||
if(is_pitch){
|
if(is_pitch){
|
||||||
u->motor_target .go_shoot =u->PitchContext .PitchConfig .go1_init_position ;
|
target->go_shoot =pitch_cfg->go_init ;
|
||||||
u->motor_target .Shoot_Pitch_angle=u->PitchContext.PitchConfig.Pitch_angle;
|
target->Shoot_Pitch_angle=pitch_cfg->Pitch_angle;
|
||||||
is_pitch=0;
|
is_pitch=0;
|
||||||
} //让初始go位置只读一次,后面按调整模式更改的来,后面稳定了之后,可以跟随调整模式下一块删
|
} //让初始go位置只读一次,后面按调整模式更改的来,后面稳定了之后,可以跟随调整模式下一块删
|
||||||
u->motor_target .Shoot_M2006_angle =u->PitchContext .PitchConfig .m2006_init_angle ;
|
target->Shoot_M2006_angle =u->Pitch_Cfg .PitchConfig .m2006_init ;
|
||||||
u->PitchContext .PitchState = PITCH_PREPARE; //状态更新,开始夹球
|
u->Pitch_Cfg .PitchState = PITCH_PREPARE; //状态更新,开始夹球
|
||||||
|
|
||||||
/*运球*/
|
/*运球*/
|
||||||
|
|
||||||
RELAY1_TOGGLE(0);//关闭气缸
|
RELAY1_TOGGLE(0);//关闭气缸
|
||||||
for(int i=0;i<3;i++){
|
for(int i=0;i<3;i++){
|
||||||
u->motor_target.Dribble_M3508_speed[i]=0;
|
target->Dribble_M3508_speed[i]=0;
|
||||||
}
|
}
|
||||||
u->motor_target .Dribble_translate_M3508_angle =u->DribbleContext .DribbleConfig .m3508_translate_angle;
|
target->Dribble_translate_M3508_angle =u->DribbleCont .DribbleConfig .m3508_translate_angle;
|
||||||
u->DribbleContext .DribbleState = DRIBBLE_PREPARE; //重置最初状态
|
u->DribbleCont .DribbleState = DRIBBLE_PREPARE; //重置最初状态
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Pitch :
|
case Pitch :
|
||||||
// if (u->PitchContext .PitchState ==PITCH_PREPARE)
|
if (u->Pitch_Cfg .PitchState ==PITCH_PREPARE)
|
||||||
// {
|
|
||||||
// u->PitchContext .PitchState=PITCH_START;//置标志位用于启动投篮
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Pitch_Process(u,out);
|
|
||||||
if (u->PitchContext .PitchState ==PITCH_PREPARE)
|
|
||||||
{
|
{
|
||||||
u->CoContext .CoState =CoTRANSLATE_OUT;
|
u->Pitch_Cfg .PitchState=PITCH_START;//置标志位用于启动投篮
|
||||||
}
|
}
|
||||||
Co_Process(u,out);
|
|
||||||
|
Pitch_Process(u,out);
|
||||||
|
|
||||||
|
|
||||||
break ;
|
break ;
|
||||||
case UP_Adjust: //测试用
|
case UP_Adjust: //测试用
|
||||||
u->PitchContext .PitchConfig .pull_speed=5;
|
pitch_cfg ->pull_speed=5;
|
||||||
u->PitchContext.PitchConfig.go1_Receive_ball += c->Vx ;
|
pitch_cfg ->go_release_pos += c->Vx ;
|
||||||
u->PitchContext.PitchConfig.Pitch_angle += c->Vy/100;
|
pitch_cfg->Pitch_angle += c->Vy/100;
|
||||||
|
|
||||||
u->motor_target .go_shoot=u->PitchContext.PitchConfig.go1_Receive_ball;
|
target->go_shoot=u->Pitch_Cfg.PitchConfig.go_release_pos;
|
||||||
u->motor_target .Shoot_Pitch_angle=u->PitchContext.PitchConfig.Pitch_angle;
|
target->Shoot_Pitch_angle=u->Pitch_Cfg.PitchConfig.Pitch_angle;
|
||||||
break ;
|
break ;
|
||||||
case Dribble:
|
case Dribble:
|
||||||
{
|
{
|
||||||
|
|
||||||
if(u->DribbleContext.DribbleState== DRIBBLE_PREPARE){
|
if(u->DribbleCont.DribbleState== DRIBBLE_PREPARE){
|
||||||
u->DribbleContext .DribbleState=DRIBBLE_PROCESS_DOWN;
|
u->DribbleCont .DribbleState=DRIBBLE_PROCESS_DOWN;
|
||||||
}
|
}
|
||||||
//光电状态更新
|
//光电状态更新
|
||||||
Dribble_Process(u,out);
|
Dribble_Process(u,out);
|
||||||
@ -336,28 +328,28 @@ int8_t UP_control(UP_t *u,CAN_Output_t *out,CMD_t *c)
|
|||||||
switch(c-> CMD_mode)
|
switch(c-> CMD_mode)
|
||||||
{
|
{
|
||||||
case AUTO_MID360_Pitch:
|
case AUTO_MID360_Pitch:
|
||||||
u->PitchContext .PitchConfig .go1_Receive_ball=LowPassFilter2p_Apply(&u->filled[0],c->pos);
|
pitch_cfg ->go_init=LowPassFilter2p_Apply(&u->filled[0],c->pos);
|
||||||
|
|
||||||
if (u->PitchContext .PitchState ==PITCH_PREPARE)
|
if (u->Pitch_Cfg .PitchState ==PITCH_PREPARE)
|
||||||
{
|
{
|
||||||
u->PitchContext .PitchState=PITCH_START;//置标志位用于启动投篮
|
u->Pitch_Cfg .PitchState=PITCH_START;//置标志位用于启动投篮
|
||||||
}
|
}
|
||||||
/*根据距离实时计算所需pos*/
|
/*根据距离实时计算所需pos*/
|
||||||
|
|
||||||
u->PitchContext .PitchConfig .go1_init_position=c->pos;
|
pitch_cfg ->go_release_pos=c->pos;
|
||||||
if(u->CoContext .CoState == CoPITCH){
|
// if(u->CoContext .CoState == CoPITCH){
|
||||||
u->CoContext.CoState=CoPITCH_MID360;
|
// u->CoContext.CoState=CoPITCH_MID360;
|
||||||
}
|
// }
|
||||||
Co_Process(u,out);
|
// Co_Process(u,out);
|
||||||
|
|
||||||
// Pitch_Process(u,out);
|
Pitch_Process(u,out);
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case AUTO_MID360:
|
case AUTO_MID360:
|
||||||
u->motor_target .Shoot_M2006_angle =u->PitchContext .PitchConfig .m2006_init_angle ;
|
target->Shoot_M2006_angle =pitch_cfg ->m2006_init ;
|
||||||
|
|
||||||
u->PitchContext .PitchState = PITCH_PREPARE;
|
u->Pitch_Cfg .PitchState = PITCH_PREPARE;
|
||||||
u->DribbleContext .DribbleState = DRIBBLE_PREPARE;
|
u->DribbleCont .DribbleState = DRIBBLE_PREPARE;
|
||||||
|
|
||||||
|
|
||||||
break ;
|
break ;
|
||||||
@ -384,17 +376,21 @@ return 0;
|
|||||||
int8_t Pitch_Process(UP_t *u, CAN_Output_t *out)
|
int8_t Pitch_Process(UP_t *u, CAN_Output_t *out)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch(u->PitchContext .PitchState){
|
PitchCfg_t *cfg = &u->Pitch_Cfg.PitchConfig;
|
||||||
|
PitchState_t *state =&u->Pitch_Cfg .PitchState;
|
||||||
|
up_motor_target_t *target=&u->motor_target ;
|
||||||
|
|
||||||
|
switch(*state){
|
||||||
|
|
||||||
case PITCH_START:
|
case PITCH_START:
|
||||||
u->motor_target .Dribble_translate_M3508_angle =u->DribbleContext .DribbleConfig.m3508_translate_angle;//平行移动
|
// u->motor_target .Dribble_translate_M3508_angle =u->DribbleCont .DribbleConfig.m3508_translate_angle;//平行移动
|
||||||
u->PitchContext .PitchConfig .pull_speed=10;
|
cfg->pull_speed=10;
|
||||||
u->motor_target .go_shoot = u->PitchContext .PitchConfig .go1_release_threshold;
|
target->go_shoot = cfg->go_pull_pos;
|
||||||
|
|
||||||
if(u->motorfeedback .go_data ->Pos < -209){ //检测go位置到达最上面,这里的检测条件可以更改
|
if(u->motorfeedback .go_data ->Pos < -209){ //检测go位置到达最上面,这里的检测条件可以更改
|
||||||
u->motor_target .Shoot_M2006_angle = u->PitchContext .PitchConfig .m2006_trigger_angle ;//设置2006角度,0
|
target->Shoot_M2006_angle = cfg->m2006_trig ;//设置2006角度,0
|
||||||
u->PitchContext .PitchConfig .pull_speed=6;
|
u->Pitch_Cfg .PitchConfig .pull_speed=6;
|
||||||
u->PitchContext .PitchState=PITCH_PULL_TRIGGER;
|
*state=PITCH_PULL_TRIGGER;
|
||||||
}//更改标志位
|
}//更改标志位
|
||||||
|
|
||||||
break ;
|
break ;
|
||||||
@ -403,16 +399,16 @@ int8_t Pitch_Process(UP_t *u, CAN_Output_t *out)
|
|||||||
|
|
||||||
if( u->motorfeedback .DJmotor_feedback [4].total_angle>-1) //当2006的总角度小于1,可以认为已经勾上,误差为1
|
if( u->motorfeedback .DJmotor_feedback [4].total_angle>-1) //当2006的总角度小于1,可以认为已经勾上,误差为1
|
||||||
{
|
{
|
||||||
u->motor_target .go_shoot=u->PitchContext.PitchConfig.go1_Receive_ball;
|
target->go_shoot=cfg->go_release_pos;
|
||||||
if(is_reached (u->motorfeedback .go_data ->Pos ,u->motor_target .go_shoot ,1.0f))
|
if(is_reached (u->motorfeedback .go_data ->Pos ,target->go_shoot ,1.0f))
|
||||||
{
|
{
|
||||||
u->PitchContext .PitchState=PITCH_LAUNCHING;
|
*state=PITCH_LAUNCHING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case PITCH_LAUNCHING: //等待发射
|
case PITCH_LAUNCHING: //等待发射
|
||||||
// u->PitchContext .PitchState=PITCH_COMPLETE;
|
// *state=PITCH_COMPLETE;
|
||||||
break ;
|
break ;
|
||||||
case PITCH_COMPLETE: //发射完成
|
case PITCH_COMPLETE: //发射完成
|
||||||
|
|
||||||
@ -439,41 +435,43 @@ int8_t Dribble_Process(UP_t *u, CAN_Output_t *out)
|
|||||||
static int common_speed_flag=0;//是否共速
|
static int common_speed_flag=0;//是否共速
|
||||||
static int common_speed_reverse_flag=0;//是否共速
|
static int common_speed_reverse_flag=0;//是否共速
|
||||||
|
|
||||||
|
DribbleCfg_t *DribbleCfg = &u->DribbleCont.DribbleConfig;
|
||||||
|
up_motor_target_t *target=&u->motor_target ;
|
||||||
|
DribbleState_t *DribbleState=&u->DribbleCont.DribbleState;
|
||||||
|
|
||||||
switch (u->DribbleContext.DribbleState) {
|
switch (u->DribbleCont.DribbleState) {
|
||||||
|
|
||||||
case DRIBBLE_TRANSLATE:
|
case DRIBBLE_TRANSLATE:
|
||||||
u->motor_target .Dribble_translate_M3508_angle =u->DribbleContext .DribbleConfig.m3508_translate_angle;//平行移动
|
target->Dribble_translate_M3508_angle =DribbleCfg->m3508_translate_angle;//平行移动
|
||||||
|
|
||||||
if(u->motorfeedback.DJmotor_feedback[3].rpm==0 && u->motorfeedback.DJmotor_feedback[3].total_angle < -500)//速度为0认为卡主
|
if(u->motorfeedback.DJmotor_feedback[3].rpm==0 && u->motorfeedback.DJmotor_feedback[3].total_angle < -500)//速度为0认为卡主
|
||||||
{
|
{
|
||||||
u->DribbleContext .DribbleState=DRIBBLE_PROCESS_DOWN;//到达位置后,转移状态
|
u->DribbleCont .DribbleState=DRIBBLE_PROCESS_DOWN;//到达位置后,转移状态
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DRIBBLE_PROCESS_DOWN:
|
case DRIBBLE_PROCESS_DOWN:
|
||||||
|
|
||||||
u->motor_target.Dribble_M3508_speed[0]=u->DribbleContext .DribbleConfig.m3508_dribble_speed;
|
target->Dribble_M3508_speed[0]=DribbleCfg->spd;
|
||||||
u->motor_target.Dribble_M3508_speed[1]=u->DribbleContext .DribbleConfig.m3508_dribble_speed;
|
target->Dribble_M3508_speed[1]=DribbleCfg->spd;
|
||||||
u->motor_target.Dribble_M3508_speed[2]=u->DribbleContext .DribbleConfig.m3508_dribble_speed;
|
target->Dribble_M3508_speed[2]=DribbleCfg->spd;
|
||||||
|
|
||||||
if(is_reached_multiple(u->motorfeedback .DJmotor_feedback [0].rpm,
|
if(is_reached_multiple(u->motorfeedback .DJmotor_feedback [0].rpm,
|
||||||
u->motorfeedback .DJmotor_feedback [1].rpm,
|
u->motorfeedback .DJmotor_feedback [1].rpm,
|
||||||
u->motorfeedback .DJmotor_feedback [2].rpm,
|
u->motorfeedback .DJmotor_feedback [2].rpm,
|
||||||
u->motor_target.Dribble_M3508_speed [0],
|
DribbleCfg->spd,
|
||||||
u->motor_target.Dribble_M3508_speed [1],
|
DribbleCfg->spd,
|
||||||
u->motor_target.Dribble_M3508_speed[2],
|
DribbleCfg->spd, 50.0f,50)
|
||||||
50.0f,50)
|
|
||||||
) {
|
) {
|
||||||
RELAY1_TOGGLE(1); //速度达到后打开气缸
|
RELAY1_TOGGLE(1); //速度达到后打开气缸
|
||||||
common_speed_flag =1;
|
common_speed_flag =1;
|
||||||
}
|
}
|
||||||
if(common_speed_flag){
|
if(common_speed_flag){
|
||||||
if(u->DribbleContext .DribbleConfig .light_ball_flag == 0){//球下落检测,反转
|
if(u->DribbleCont .DribbleConfig .light_ball_flag == 0){//球下落检测,反转
|
||||||
u->motor_target.Dribble_M3508_speed[0]=u->DribbleContext .DribbleConfig.m3508_dribble_Reverse_speed;
|
target->Dribble_M3508_speed[0]=DribbleCfg->rev_spd;
|
||||||
u->motor_target.Dribble_M3508_speed[1]=u->DribbleContext .DribbleConfig.m3508_dribble_Reverse_speed;
|
target->Dribble_M3508_speed[1]=DribbleCfg->rev_spd;
|
||||||
u->motor_target.Dribble_M3508_speed[2]=u->DribbleContext .DribbleConfig.m3508_dribble_Reverse_speed;
|
target->Dribble_M3508_speed[2]=DribbleCfg->rev_spd;
|
||||||
|
|
||||||
u->DribbleContext .DribbleState=DRIBBLE_PROCESS_UP;
|
*DribbleState=DRIBBLE_PROCESS_UP;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -492,8 +490,8 @@ int8_t Dribble_Process(UP_t *u, CAN_Output_t *out)
|
|||||||
|
|
||||||
}
|
}
|
||||||
if(common_speed_reverse_flag){
|
if(common_speed_reverse_flag){
|
||||||
if(u->DribbleContext .DribbleConfig .light_ball_flag == 1){
|
if(DribbleCfg->light_ball_flag == 1){
|
||||||
u->DribbleContext .DribbleState=DRIBBLE_DONE;
|
*DribbleState=DRIBBLE_DONE;
|
||||||
RELAY1_TOGGLE(0); //关闭气缸
|
RELAY1_TOGGLE(0); //关闭气缸
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -501,12 +499,12 @@ int8_t Dribble_Process(UP_t *u, CAN_Output_t *out)
|
|||||||
case DRIBBLE_DONE:
|
case DRIBBLE_DONE:
|
||||||
common_speed_reverse_flag=0;
|
common_speed_reverse_flag=0;
|
||||||
for(int i=0;i<3;i++){
|
for(int i=0;i<3;i++){
|
||||||
u->motor_target.Dribble_M3508_speed[i]=u->DribbleContext .DribbleConfig.m3508_dribble_init_speed ;//三摩擦速度归0
|
target->Dribble_M3508_speed[i]=DribbleCfg->init_spd ;//三摩擦速度归0
|
||||||
}
|
}
|
||||||
|
|
||||||
/*标志位清零*/
|
/*标志位清零*/
|
||||||
u->DribbleContext.DribbleConfig.light_ball_flag=0;
|
DribbleCfg->light_ball_flag=0;
|
||||||
u->DribbleContext.DribbleConfig.light_3508_flag=0;
|
DribbleCfg->light_3508_flag=0;
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -531,12 +529,12 @@ int8_t Co_Process(UP_t *u, CAN_Output_t *out)
|
|||||||
|
|
||||||
break ;
|
break ;
|
||||||
case CoTRANSLATE_OUT:
|
case CoTRANSLATE_OUT:
|
||||||
u->motor_target .Dribble_translate_M3508_angle =u->DribbleContext .DribbleConfig.m3508_translate_angle;//平行移动
|
u->motor_target .Dribble_translate_M3508_angle =u->DribbleCont .DribbleConfig.m3508_translate_angle;//平行移动
|
||||||
|
|
||||||
if(u->motorfeedback.DJmotor_feedback[3].rpm==0 && u->motorfeedback.DJmotor_feedback[3].total_angle > 900)//速度为0认为卡主
|
if(u->motorfeedback.DJmotor_feedback[3].rpm==0 && u->motorfeedback.DJmotor_feedback[3].total_angle > 500)//速度为0认为卡主
|
||||||
{
|
{
|
||||||
u->DribbleContext .DribbleState=DRIBBLE_PROCESS_DOWN;//到达位置后,运球转移状态
|
u->DribbleCont .DribbleState=DRIBBLE_PROCESS_DOWN;//到达位置后,运球转移状态
|
||||||
u->PitchContext .PitchState = PITCH_START;
|
u->Pitch_Cfg .PitchState = PITCH_START;
|
||||||
|
|
||||||
u->CoContext .CoState =CoDRIBBLE;
|
u->CoContext .CoState =CoDRIBBLE;
|
||||||
}
|
}
|
||||||
@ -546,11 +544,11 @@ int8_t Co_Process(UP_t *u, CAN_Output_t *out)
|
|||||||
Dribble_Process(u,out); //状态停在DRIBBLE_DONE
|
Dribble_Process(u,out); //状态停在DRIBBLE_DONE
|
||||||
Pitch_Process(u,out); //状态停在PITCH_LAUNCHING
|
Pitch_Process(u,out); //状态停在PITCH_LAUNCHING
|
||||||
//状态停在对应位置时,平移去给发射送球
|
//状态停在对应位置时,平移去给发射送球
|
||||||
if(u->DribbleContext .DribbleState ==DRIBBLE_DONE && u->PitchContext.PitchState ==PITCH_LAUNCHING)
|
if(u->DribbleCont .DribbleState ==DRIBBLE_DONE && u->Pitch_Cfg.PitchState ==PITCH_LAUNCHING)
|
||||||
{
|
{
|
||||||
u->motor_target .Dribble_translate_M3508_angle =u->DribbleContext .DribbleConfig .m3508_init_angle;
|
u->motor_target .Dribble_translate_M3508_angle =u->DribbleCont .DribbleConfig .m3508_init_ang;
|
||||||
}
|
}
|
||||||
if(is_reached(u->motorfeedback.DJmotor_feedback[3].total_angle ,u->DribbleContext .DribbleConfig.m3508_init_angle,1.0f))
|
if(is_reached(u->motorfeedback.DJmotor_feedback[3].total_angle ,u->DribbleCont .DribbleConfig.m3508_init_ang,1.0f))
|
||||||
{
|
{
|
||||||
u->motor_target.Dribble_M3508_speed[0]=1000;
|
u->motor_target.Dribble_M3508_speed[0]=1000;
|
||||||
u->motor_target.Dribble_M3508_speed[1]=1000;
|
u->motor_target.Dribble_M3508_speed[1]=1000;
|
||||||
@ -572,12 +570,12 @@ int8_t Co_Process(UP_t *u, CAN_Output_t *out)
|
|||||||
) {
|
) {
|
||||||
RELAY1_TOGGLE(1); //速度达到后打开气缸,送给发射
|
RELAY1_TOGGLE(1); //速度达到后打开气缸,送给发射
|
||||||
}
|
}
|
||||||
if(u->DribbleContext .DribbleConfig.light_ball_flag == 0)
|
if(u->DribbleCont .DribbleConfig.light_ball_flag == 0)
|
||||||
{
|
{
|
||||||
u->motor_target.Dribble_M3508_speed[0]=0;
|
u->motor_target.Dribble_M3508_speed[0]=0;
|
||||||
u->motor_target.Dribble_M3508_speed[1]=0;
|
u->motor_target.Dribble_M3508_speed[1]=0;
|
||||||
u->motor_target.Dribble_M3508_speed[2]=0;
|
u->motor_target.Dribble_M3508_speed[2]=0;
|
||||||
u->motor_target .Dribble_translate_M3508_angle =u->DribbleContext .DribbleConfig.m3508_translate_angle;//平行移动
|
u->motor_target .Dribble_translate_M3508_angle =u->DribbleCont .DribbleConfig.m3508_translate_angle;//平行移动
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,7 +593,7 @@ int8_t Co_Process(UP_t *u, CAN_Output_t *out)
|
|||||||
|
|
||||||
case CoPITCH_MID360:
|
case CoPITCH_MID360:
|
||||||
|
|
||||||
u->motor_target .go_shoot=u->PitchContext.PitchConfig.go1_init_position;
|
u->motor_target .go_shoot=u->Pitch_Cfg.PitchConfig.go_init;
|
||||||
|
|
||||||
break ;
|
break ;
|
||||||
break ;
|
break ;
|
||||||
|
167
User/Module/up.h
167
User/Module/up.h
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/*配合过程状态,co是合作的意思*/
|
/*配合过程状态*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CoPREPARE, // 准备阶段
|
CoPREPARE, // 准备阶段
|
||||||
CoTRANSLATE_OUT,//上方平移,去运球
|
CoTRANSLATE_OUT,//上方平移,去运球
|
||||||
@ -43,8 +43,8 @@ typedef enum {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
CoState_t CoState;
|
CoState_t CoState;
|
||||||
|
|
||||||
uint8_t is_initialized ;
|
uint8_t is_init ;
|
||||||
} CoContext_t;
|
} CoCon_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -62,32 +62,32 @@ typedef enum {
|
|||||||
|
|
||||||
/* 投球参数配置 */
|
/* 投球参数配置 */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
fp32 m2006_init_angle; // M2006初始角度-140
|
fp32 m2006_init; // M2006初始角度
|
||||||
fp32 m2006_trigger_angle; // M2006触发角度0,用来合并扳机
|
fp32 m2006_trig; // M2006触发角度0,用来合并扳机
|
||||||
fp32 go1_init_position; // GO电机触发位置,初始位置,后续更改用于发射的位置
|
fp32 go_init; // GO电机触发位置,初始位置,后续更改用于发射的位置
|
||||||
fp32 go1_release_threshold; // go上升去合并扳机,扳机位置
|
fp32 go_pull_pos; // go上升去合并扳机,扳机位置
|
||||||
fp32 go1_Receive_ball; //用在配合过程,用来接平移后的球
|
|
||||||
fp32 m2006_Screw_init;
|
|
||||||
fp32 Pitch_angle;
|
fp32 Pitch_angle;
|
||||||
|
|
||||||
fp32 pull_speed;
|
fp32 pull_speed;//go速度
|
||||||
|
fp32 go_release_pos;//go松开,发射位置
|
||||||
} PitchConfig_t;
|
|
||||||
|
|
||||||
|
} PitchCfg_t;
|
||||||
|
//fp32 go_pull_pos;
|
||||||
|
// fp32 m2006_init; // M2006初始角度
|
||||||
|
// fp32 m2006_trig; // M2006触发角度
|
||||||
|
// fp32 go_init; // GO初始位置
|
||||||
|
// fp32 go_release; // GO释放阈值
|
||||||
|
// fp32 go_recv; // GO接球位置
|
||||||
|
// fp32 screw_init; // 螺杆初始值
|
||||||
|
// fp32 pitch_ang; // 投球角度
|
||||||
|
// fp32 pull_spd; // 拉动速度
|
||||||
/* 投球控制上下文 */
|
/* 投球控制上下文 */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PitchState_t PitchState;
|
PitchState_t PitchState;
|
||||||
PitchConfig_t PitchConfig;
|
PitchCfg_t PitchConfig;
|
||||||
|
|
||||||
uint8_t is_initialized ;
|
|
||||||
} PitchContext_t;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t is_init ;
|
||||||
|
} Pitch_Cfg_t;
|
||||||
|
|
||||||
/*运球*/
|
/*运球*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -103,27 +103,27 @@ typedef enum {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t dribble_flag;//当移动三摩擦后为1,否则为0,防止发射撞到
|
int8_t dribble_flag;//当移动三摩擦后为1,否则为0,防止发射撞到
|
||||||
|
|
||||||
fp32 m3508_init_angle; // 平移前位置
|
fp32 m3508_init_ang; // 3508平移前位置
|
||||||
fp32 m3508_translate_angle; // 平移后位置
|
fp32 m3508_translate_angle; // 平移后位置
|
||||||
fp32 m3508_dribble_init_speed;
|
fp32 init_spd;
|
||||||
fp32 m3508_dribble_speed; // 转动速度
|
fp32 spd; // 转动速度
|
||||||
fp32 m3508_dribble_Reverse_speed;
|
fp32 rev_spd;
|
||||||
|
|
||||||
|
|
||||||
/*光电标志位,初始值均为0,触发为1*/
|
/*光电标志位,初始值均为0,触发为1*/
|
||||||
int light_3508_flag;//3508平移处的光电,0初始,1到位置
|
int light_3508_flag;//3508平移处的光电,0初始,1到位置
|
||||||
int light_ball_flag;//检测球的flag
|
int light_ball_flag;//检测球的flag
|
||||||
|
|
||||||
} DribbleConfig_t;
|
} DribbleCfg_t;
|
||||||
|
|
||||||
/* 状态机上下文 */
|
/* 状态机上下文 */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DribbleState_t DribbleState;
|
DribbleState_t DribbleState;
|
||||||
DribbleConfig_t DribbleConfig;
|
DribbleCfg_t DribbleConfig;
|
||||||
|
|
||||||
uint8_t is_initialized;
|
uint8_t is_init;
|
||||||
|
|
||||||
} DribbleContext_t;
|
} DribbleCont_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -154,58 +154,13 @@ typedef struct
|
|||||||
pid_param_t Dribble_translate_M3508_angle_param;//平移用的角度环
|
pid_param_t Dribble_translate_M3508_angle_param;//平移用的角度环
|
||||||
|
|
||||||
|
|
||||||
DribbleConfig_t DribbleConfig_Config;
|
DribbleCfg_t DribbleCfg;
|
||||||
PitchConfig_t PitchConfig_Config;
|
PitchCfg_t PitchCfg;
|
||||||
|
|
||||||
GO_MotorCmd_t go_cmd;
|
GO_MotorCmd_t go_cmd;
|
||||||
}UP_Param_t;
|
}UP_Param_t;
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
fp32 ecd;
|
|
||||||
fp32 rpm;
|
|
||||||
uint8_t id;
|
|
||||||
fp32 orig_angle;
|
|
||||||
fp32 last_angle;
|
|
||||||
int32_t round_cnt;
|
|
||||||
int init_cnt;
|
|
||||||
fp32 total_angle;
|
|
||||||
}DJmotor_feedback_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
|
|
||||||
uint8_t up_task_run;
|
|
||||||
const UP_Param_t *param;
|
|
||||||
CoContext_t CoContext;
|
|
||||||
/*运球过程*/
|
|
||||||
DribbleContext_t DribbleContext;
|
|
||||||
/*投篮过程*/
|
|
||||||
PitchContext_t PitchContext;
|
|
||||||
|
|
||||||
CMD_t *cmd;
|
|
||||||
|
|
||||||
struct{
|
|
||||||
|
|
||||||
struct{
|
|
||||||
fp32 VESC_5065_M1_rpm;
|
|
||||||
fp32 VESC_5065_M2_rpm;
|
|
||||||
}VESC;
|
|
||||||
|
|
||||||
GO_MotorData_t *go_data;//存放go电机数据
|
|
||||||
|
|
||||||
DJmotor_feedback_t DJmotor_feedback[6];
|
|
||||||
|
|
||||||
struct {
|
|
||||||
uint32_t ecd;
|
|
||||||
float angle;
|
|
||||||
}Encoder;
|
|
||||||
}motorfeedback;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct{
|
|
||||||
|
|
||||||
fp32 VESC_5065_M1_rpm;
|
fp32 VESC_5065_M1_rpm;
|
||||||
fp32 VESC_5065_M2_rpm;
|
fp32 VESC_5065_M2_rpm;
|
||||||
|
|
||||||
@ -218,9 +173,9 @@ typedef struct{
|
|||||||
|
|
||||||
fp32 Shoot_Pitch_angle;
|
fp32 Shoot_Pitch_angle;
|
||||||
|
|
||||||
}motor_target;
|
}up_motor_target_t;
|
||||||
|
|
||||||
struct{
|
typedef struct{
|
||||||
|
|
||||||
|
|
||||||
pid_type_def VESC_5065_M1;
|
pid_type_def VESC_5065_M1;
|
||||||
@ -240,12 +195,56 @@ typedef struct{
|
|||||||
pid_type_def Dribble_translate_M3508_angle;//平移用的角度环
|
pid_type_def Dribble_translate_M3508_angle;//平移用的角度环
|
||||||
|
|
||||||
|
|
||||||
}pid;
|
}up_pid_t;
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
fp32 ecd;
|
||||||
|
fp32 rpm;
|
||||||
|
uint8_t id;
|
||||||
|
fp32 orig_angle;
|
||||||
|
fp32 last_angle;
|
||||||
|
int32_t round_cnt;
|
||||||
|
int init_cnt;
|
||||||
|
fp32 total_angle;
|
||||||
|
}DJmotor_feedback_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
uint8_t up_task_run;
|
||||||
|
const UP_Param_t *param;
|
||||||
|
CoCon_t CoContext;
|
||||||
|
/*运球过程*/
|
||||||
|
DribbleCont_t DribbleCont;
|
||||||
|
/*投篮过程*/
|
||||||
|
Pitch_Cfg_t Pitch_Cfg;
|
||||||
|
|
||||||
|
CMD_t *cmd;
|
||||||
|
|
||||||
|
struct{
|
||||||
|
|
||||||
|
struct{
|
||||||
|
fp32 VESC_5065_M1_rpm;
|
||||||
|
fp32 VESC_5065_M2_rpm;
|
||||||
|
}VESC;
|
||||||
|
GO_MotorData_t *go_data;//存放go电机数据
|
||||||
|
|
||||||
|
DJmotor_feedback_t DJmotor_feedback[6];
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint32_t ecd;
|
||||||
|
float angle;
|
||||||
|
}Encoder;
|
||||||
|
}motorfeedback;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
up_pid_t pid;
|
||||||
|
up_motor_target_t motor_target;
|
||||||
|
|
||||||
GO_MotorCmd_t go_cmd;
|
GO_MotorCmd_t go_cmd;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*经PID计算后的实际发送给电机的实时输出值*/
|
/*经PID计算后的实际发送给电机的实时输出值*/
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@ -260,8 +259,6 @@ typedef struct{
|
|||||||
|
|
||||||
fp32 vofa_send[8];
|
fp32 vofa_send[8];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} UP_t;
|
} UP_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,31 +56,20 @@ static void CAN_DJIMotor_Decode(CAN_MotorFeedback_t *feedback,
|
|||||||
feedback->torque_current =
|
feedback->torque_current =
|
||||||
raw_current * CAN_GM6020_MAX_ABS_CUR / (float)CAN_MOTOR_CUR_RES;
|
raw_current * CAN_GM6020_MAX_ABS_CUR / (float)CAN_MOTOR_CUR_RES;
|
||||||
}
|
}
|
||||||
static void CAN_Sick_Receive(CAN_SickFeedback_t *feedback,uint16_t id,
|
static void CAN_Sick_Receive(CAN_SickFeedback_t *feedback,
|
||||||
const uint8_t *raw) {
|
const uint8_t *raw) {
|
||||||
if (feedback == NULL || raw == NULL) return;
|
if (feedback == NULL || raw == NULL) return;
|
||||||
switch (id)
|
static uint16_t sick_rec[4];
|
||||||
{
|
|
||||||
case CAN_SICK_ID_1:
|
|
||||||
feedback->raw_dis[0] = (uint16_t)(raw[0] << 8| raw[1]);
|
|
||||||
|
|
||||||
break ;
|
sick_rec[0] = (uint16_t)(raw[0] << 8 | raw[1]);
|
||||||
|
sick_rec[1] = (uint16_t)(raw[2] << 8 | raw[3]);
|
||||||
|
sick_rec[2] = (uint16_t)(raw[4] << 8 | raw[5]);
|
||||||
|
sick_rec[3] = (uint16_t)(raw[6] << 8 | raw[7]);
|
||||||
|
|
||||||
case CAN_SICK_ID_2:
|
feedback ->raw_dis [0]= sick_rec[0];
|
||||||
feedback->raw_dis[1] = (uint16_t)(raw[0] << 8| raw[1]);
|
feedback ->raw_dis [1]= sick_rec[1];
|
||||||
|
feedback ->raw_dis [2]= sick_rec[2];
|
||||||
break ;
|
feedback ->raw_dis [3]= sick_rec[3];
|
||||||
|
|
||||||
case CAN_SICK_ID_3:
|
|
||||||
feedback->raw_dis[2] = (uint16_t)(raw[0] << 8| raw[1]);
|
|
||||||
|
|
||||||
break ;
|
|
||||||
|
|
||||||
case CAN_SICK_ID_4:
|
|
||||||
feedback->raw_dis[3] = (uint16_t)(raw[0] << 8| raw[1]);
|
|
||||||
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void CAN_Encoder_Decode(CAN_EncoderFeedback_t *feedback,
|
void CAN_Encoder_Decode(CAN_EncoderFeedback_t *feedback,
|
||||||
const uint8_t *raw) {
|
const uint8_t *raw) {
|
||||||
@ -384,19 +373,10 @@ int8_t CAN_StoreMsg(CAN_t *can, CAN_RawRx_t *can_rx) {
|
|||||||
CAN_DJIMotor_Decode(&(can->motor.chassis_motor3508.as_array[index]), can_rx->rx_data);
|
CAN_DJIMotor_Decode(&(can->motor.chassis_motor3508.as_array[index]), can_rx->rx_data);
|
||||||
detect_hook(CHASSIS3508M1_TOE + index);
|
detect_hook(CHASSIS3508M1_TOE + index);
|
||||||
break;
|
break;
|
||||||
case CAN_SICK_ID_1:
|
case CAN_SICK_ID:
|
||||||
CAN_Sick_Receive(&(can->sickfed),CAN_SICK_ID_1, can_rx->rx_data);
|
CAN_Sick_Receive(&(can->sickfed), can_rx->rx_data);
|
||||||
break;
|
break;
|
||||||
case CAN_SICK_ID_2:
|
|
||||||
CAN_Sick_Receive(&(can->sickfed),CAN_SICK_ID_2, can_rx->rx_data);
|
|
||||||
break;
|
|
||||||
case CAN_SICK_ID_3:
|
|
||||||
CAN_Sick_Receive(&(can->sickfed),CAN_SICK_ID_3, can_rx->rx_data);
|
|
||||||
break;
|
|
||||||
case CAN_SICK_ID_4:
|
|
||||||
CAN_Sick_Receive(&(can->sickfed),CAN_SICK_ID_4, can_rx->rx_data);
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,8 @@ typedef enum {
|
|||||||
CAN_UP_M3508_M5_ID = 0x205, /* 1 */
|
CAN_UP_M3508_M5_ID = 0x205, /* 1 */
|
||||||
CAN_UP_M3508_M6_ID = 0x206, /* 2 */
|
CAN_UP_M3508_M6_ID = 0x206, /* 2 */
|
||||||
|
|
||||||
CAN_SICK_ID_1=0x301,
|
CAN_SICK_ID=0x305,
|
||||||
CAN_SICK_ID_2=0x302,
|
|
||||||
CAN_SICK_ID_3=0x303,
|
|
||||||
CAN_SICK_ID_4=0x304,
|
|
||||||
|
|
||||||
CAN_Encoder_ID=0x01,
|
CAN_Encoder_ID=0x01,
|
||||||
|
|
||||||
@ -200,6 +198,6 @@ void CAN_Encoder_Control(CAN_t *can);
|
|||||||
|
|
||||||
void CAN_Encoder_Decode(CAN_EncoderFeedback_t *feedback,
|
void CAN_Encoder_Decode(CAN_EncoderFeedback_t *feedback,
|
||||||
const uint8_t *raw) ;
|
const uint8_t *raw) ;
|
||||||
static void CAN_Sick_Receive(CAN_SickFeedback_t *feedback,uint16_t id,
|
static void CAN_Sick_Receive(CAN_SickFeedback_t *feedback,
|
||||||
const uint8_t *raw) ;
|
const uint8_t *raw) ;
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,7 +6,8 @@ static volatile uint32_t drop_message = 0;
|
|||||||
|
|
||||||
static osThreadId_t thread_alert;
|
static osThreadId_t thread_alert;
|
||||||
|
|
||||||
uint8_t nucbuf[31];
|
static uint8_t nucbuf[31];
|
||||||
|
static char SendBuffer[19];
|
||||||
|
|
||||||
|
|
||||||
static void NUC_IdleCallback(void) {
|
static void NUC_IdleCallback(void) {
|
||||||
@ -28,11 +29,8 @@ int8_t NUC_StartReceiving() {
|
|||||||
return DEVICE_OK;
|
return DEVICE_OK;
|
||||||
return DEVICE_ERR;
|
return DEVICE_ERR;
|
||||||
}
|
}
|
||||||
char SendBuffer[19];
|
|
||||||
|
|
||||||
int8_t NUC_StartSending(fp32 *data) {
|
int8_t NUC_StartSending(fp32 *data) {
|
||||||
|
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
float x[4];
|
float x[4];
|
||||||
@ -64,7 +62,7 @@ int8_t NUC_Restart(void) {
|
|||||||
return DEVICE_OK;
|
return DEVICE_OK;
|
||||||
}
|
}
|
||||||
bool_t NUC_WaitDmaCplt(void) {
|
bool_t NUC_WaitDmaCplt(void) {
|
||||||
return (osThreadFlagsWait(SIGNAL_NUC_RAW_REDY, osFlagsWaitAll,500) ==
|
return (osThreadFlagsWait(SIGNAL_NUC_RAW_REDY, osFlagsWaitAll,100) ==
|
||||||
SIGNAL_NUC_RAW_REDY);
|
SIGNAL_NUC_RAW_REDY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@ const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CAN;
|
|||||||
|
|
||||||
|
|
||||||
//一问一答sick数据指令
|
//一问一答sick数据指令
|
||||||
// CAN_Sick_Control(&can);
|
|
||||||
CAN_Encoder_Control(&can);
|
CAN_Encoder_Control(&can);
|
||||||
|
|
||||||
/*can设备数据存入队列*/
|
/*can设备数据存入队列*/
|
||||||
|
@ -56,6 +56,8 @@ void Task_Chassis(void *argument)
|
|||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
task_runtime.stack_water_mark.chassis = osThreadGetStackSpace(osThreadGetId());
|
task_runtime.stack_water_mark.chassis = osThreadGetStackSpace(osThreadGetId());
|
||||||
|
task_runtime.freq.chassis=TASK_FREQ_CHASSIS;
|
||||||
|
task_runtime.last_up_time.chassis=tick;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*imu数据获取*/
|
/*imu数据获取*/
|
||||||
|
@ -30,8 +30,9 @@ void Task_cmd(void *argument){
|
|||||||
while(1){
|
while(1){
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/*记录任务所需要的栈空间*/
|
/*记录任务所需要的栈空间*/
|
||||||
task_runtime.stack_water_mark.cmd =
|
task_runtime.stack_water_mark.cmd =osThreadGetStackSpace(osThreadGetId());
|
||||||
osThreadGetStackSpace(osThreadGetId());
|
task_runtime.last_up_time.cmd=tick;
|
||||||
|
task_runtime.freq.cmd=TASK_FREQ_CTRL_CMD;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
osKernelLock(); /*锁住RTOS内核调度*/
|
osKernelLock(); /*锁住RTOS内核调度*/
|
||||||
|
@ -13,12 +13,12 @@ static CMD_NUC_t cmd_fromnuc;
|
|||||||
NUC_send_t NUC_send;
|
NUC_send_t NUC_send;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
//fp32 send[4]={11.0f,45.0,1.f,4.0f};
|
fp32 send[4]={11.0f,45.0,1.f,4.0f};
|
||||||
|
|
||||||
void Task_nuc(void *argument){
|
void Task_nuc(void *argument){
|
||||||
(void)argument; /**/
|
(void)argument; /**/
|
||||||
|
|
||||||
// osDelay(TASK_INIT_DELAY_NUC);
|
// osDelay(TASK_INIT_DELAY_NUC);
|
||||||
|
|
||||||
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_NUC;
|
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_NUC;
|
||||||
|
|
||||||
NUC_Init(&nuc_raw);
|
NUC_Init(&nuc_raw);
|
||||||
@ -29,9 +29,13 @@ void Task_nuc(void *argument){
|
|||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
task_runtime.stack_water_mark.nuc= osThreadGetStackSpace(osThreadGetId());
|
task_runtime.stack_water_mark.nuc= osThreadGetStackSpace(osThreadGetId());
|
||||||
|
task_runtime .freq.nuc = TASK_FREQ_NUC;
|
||||||
|
task_runtime.last_up_time.nuc= tick;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
NUC_StartReceiving();
|
NUC_StartReceiving();
|
||||||
// NUC_StartSending(NUC_send.send);
|
NUC_StartSending(NUC_send.send);
|
||||||
|
// NUC_StartSending (send);
|
||||||
if (NUC_WaitDmaCplt()){
|
if (NUC_WaitDmaCplt()){
|
||||||
NUC_RawParse(&cmd_fromnuc);
|
NUC_RawParse(&cmd_fromnuc);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user