伸缩模式初步完成,

This commit is contained in:
yunhai8432 2026-03-08 01:20:57 +08:00
parent 7a0c26567c
commit 4d0928c3e5
15 changed files with 94935 additions and 14615 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -117,6 +117,11 @@
<pMon>Segger\JL2CM3.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
<Name> \* ?</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>JL2CM3</Key>

View File

@ -36,13 +36,13 @@ Note: source file '..\User\task\dr16.c' - object file renamed from 'Steering Whe
Note: source file '..\User\task\ET16s.c' - object file renamed from 'Steering Wheel_Infatry\ET16s.o' to 'Steering Wheel_Infatry\et16s_1.o'.
Note: source file '..\User\task\vofa.c' - object file renamed from 'Steering Wheel_Infatry\vofa.o' to 'Steering Wheel_Infatry\vofa_1.o'.
Note: source file '..\User\module\cmd\cmd.c' - object file renamed from 'Steering Wheel_Infatry\cmd.o' to 'Steering Wheel_Infatry\cmd_1.o'.
../User/module/chassis.c(227): warning: incompatible pointer types passing 'KPID_t (*)[2]' to parameter of type 'KPID_t *' [-Wincompatible-pointer-types]
../User/module/chassis.c(179): warning: incompatible pointer types passing 'KPID_t (*)[2]' to parameter of type 'KPID_t *' [-Wincompatible-pointer-types]
PID_Reset(&c->pid.Telescope_omega);
^~~~~~~~~~~~~~~~~~~~~~~
../User\component/pid.h(99): note: passing argument to parameter 'pid' here
int8_t PID_Reset(KPID_t *pid);
^
../User/module/chassis.c(228): warning: incompatible pointer types passing 'KPID_t (*)[2]' to parameter of type 'KPID_t *' [-Wincompatible-pointer-types]
../User/module/chassis.c(180): warning: incompatible pointer types passing 'KPID_t (*)[2]' to parameter of type 'KPID_t *' [-Wincompatible-pointer-types]
PID_Reset(&c->pid.Telescope_angle);
^~~~~~~~~~~~~~~~~~~~~~~
../User\component/pid.h(99): note: passing argument to parameter 'pid' here
@ -51,7 +51,7 @@ int8_t PID_Reset(KPID_t *pid);
2 warnings generated.
compiling chassis.c...
linking...
Program Size: Code=67304 RO-data=1668 RW-data=1224 ZI-data=123044
Program Size: Code=67416 RO-data=1668 RW-data=1224 ZI-data=123092
FromELF: creating hex file...
"Steering Wheel_Infatry\Steering Wheel_Infatry.axf" - 0 Error(s), 2 Warning(s).

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
<title>Static Call Graph - [Steering Wheel_Infatry\Steering Wheel_Infatry.axf]</title></head>
<body><HR>
<H1>Static Call Graph for image Steering Wheel_Infatry\Steering Wheel_Infatry.axf</H1><HR>
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 6160001: Last Updated: Sun Mar 8 00:29:02 2026
<BR><P>#&#060CALLGRAPH&#062# ARM Linker, 6160001: Last Updated: Sun Mar 8 01:19:52 2026
<BR><P>
<H3>Maximum Stack Usage = 464 bytes + Unknown(Functions without stacksize, Cycles, Untraceable Function Pointers)</H3><H3>
Call chain for Maximum Stack Depth:</H3>
@ -1411,7 +1411,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[13b]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;CMD_Update
</UL>
<P><STRONG><a name="[141]"></a>Chassis_Control</STRONG> (Thumb, 576 bytes, Stack size 48 bytes, chassis.o(.text.Chassis_Control))
<P><STRONG><a name="[141]"></a>Chassis_Control</STRONG> (Thumb, 580 bytes, Stack size 48 bytes, chassis.o(.text.Chassis_Control))
<BR><BR>[Stack]<UL><LI>Max Depth = 304<LI>Call Chain = Chassis_Control &rArr; Chassis_speed_calculate &rArr; __hardfp_atan2 &rArr; atan &rArr; __hardfp_atan &rArr; __kernel_poly &rArr; __aeabi_dmul
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;PID_Calc
@ -1435,7 +1435,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[81]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;Task_chassis_ctrl
</UL>
<P><STRONG><a name="[147]"></a>Chassis_speed_calculate</STRONG> (Thumb, 1488 bytes, Stack size 88 bytes, chassis.o(.text.Chassis_speed_calculate))
<P><STRONG><a name="[147]"></a>Chassis_speed_calculate</STRONG> (Thumb, 1512 bytes, Stack size 88 bytes, chassis.o(.text.Chassis_speed_calculate))
<BR><BR>[Stack]<UL><LI>Max Depth = 256<LI>Call Chain = Chassis_speed_calculate &rArr; __hardfp_atan2 &rArr; atan &rArr; __hardfp_atan &rArr; __kernel_poly &rArr; __aeabi_dmul
</UL>
<BR>[Calls]<UL><LI><a href="#[d9]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_f2d
@ -1450,7 +1450,7 @@ Global Symbols
<BR>[Called By]<UL><LI><a href="#[141]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;Chassis_Control
</UL>
<P><STRONG><a name="[150]"></a>Chassis_update</STRONG> (Thumb, 508 bytes, Stack size 88 bytes, chassis.o(.text.Chassis_update))
<P><STRONG><a name="[150]"></a>Chassis_update</STRONG> (Thumb, 516 bytes, Stack size 88 bytes, chassis.o(.text.Chassis_update))
<BR><BR>[Stack]<UL><LI>Max Depth = 336<LI>Call Chain = Chassis_update &rArr; MOTOR_RM_Update &rArr; BSP_CAN_GetMessage &rArr; osMutexAcquire &rArr; xQueueTakeMutexRecursive &rArr; xQueueSemaphoreTake &rArr; xTaskResumeAll &rArr; xTaskIncrementTick
</UL>
<BR>[Calls]<UL><LI><a href="#[d9]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;__aeabi_f2d
@ -5654,7 +5654,7 @@ Local Symbols
<BR>[Called By]<UL><LI><a href="#[141]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;Chassis_Control
</UL>
<P><STRONG><a name="[143]"></a>Set_Chassis_Attitude</STRONG> (Thumb, 124 bytes, Stack size 24 bytes, chassis.o(.text.Set_Chassis_Attitude))
<P><STRONG><a name="[143]"></a>Set_Chassis_Attitude</STRONG> (Thumb, 208 bytes, Stack size 24 bytes, chassis.o(.text.Set_Chassis_Attitude))
<BR><BR>[Stack]<UL><LI>Max Depth = 120<LI>Call Chain = Set_Chassis_Attitude &rArr; PID_Calc &rArr; LowPassFilter2p_Apply
</UL>
<BR>[Calls]<UL><LI><a href="#[145]">&gt;&gt;</a>&nbsp;&nbsp;&nbsp;PID_Calc

File diff suppressed because it is too large Load Diff

View File

@ -2414,8 +2414,8 @@ I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_uart.h)(0x68B05645)
I (D:\Keil_v5\ARM\ARMCLANG\include\stdbool.h)(0x6035A4A8)
I (..\User\bsp\bsp.h)(0x6982F1BF)
I (..\User\device\device.h)(0x6982F1BF)
F (..\User\module\chassis.c)(0x69AC524D)(-xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar -gdwarf-3 -O1 -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F -I ../User -I ../User/bsp -I ../User/component -I ../User/device -I ../User/module -I ../User/task -I ../User/module/cmd -I./RTE/_Steering_Wheel_Infatry -ID:/Keil_v5/Arm/Packs/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/Keil_v5/Arm/Packs/Keil/STM32F4xx_DFP/2.17.1/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o "steering wheel_infatry/chassis.o" -MD)
I (..\User\module\chassis.h)(0x69AC421E)
F (..\User\module\chassis.c)(0x69AC5E35)(-xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar -gdwarf-3 -O1 -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F -I ../User -I ../User/bsp -I ../User/component -I ../User/device -I ../User/module -I ../User/task -I ../User/module/cmd -I./RTE/_Steering_Wheel_Infatry -ID:/Keil_v5/Arm/Packs/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/Keil_v5/Arm/Packs/Keil/STM32F4xx_DFP/2.17.1/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o "steering wheel_infatry/chassis.o" -MD)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\module\struct_typedef.h)(0x68DBD148)
I (..\User\component\filter.h)(0x6982F1BF)
I (..\User\component\user_math.h)(0x6982F1BF)
@ -2481,7 +2481,7 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68B05
I (..\User\component\trapezoidal_profile.h)(0x69AC1BA9)
I (..\User\bsp\time.h)(0x6982F1BF)
I (D:\Keil_v5\ARM\ARMCLANG\include\stdlib.h)(0x6035A4A8)
F (..\User\module\config.c)(0x69AC5146)(-xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar -gdwarf-3 -O1 -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F -I ../User -I ../User/bsp -I ../User/component -I ../User/device -I ../User/module -I ../User/task -I ../User/module/cmd -I./RTE/_Steering_Wheel_Infatry -ID:/Keil_v5/Arm/Packs/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/Keil_v5/Arm/Packs/Keil/STM32F4xx_DFP/2.17.1/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o "steering wheel_infatry/config.o" -MD)
F (..\User\module\config.c)(0x69AC5D31)(-xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar -gdwarf-3 -O1 -ffunction-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -I ../Core/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc -I ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I ../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I ../Drivers/CMSIS/Include -I ../Middlewares/Third_Party/FreeRTOS/Source/include -I ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I ../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F -I ../User -I ../User/bsp -I ../User/component -I ../User/device -I ../User/module -I ../User/task -I ../User/module/cmd -I./RTE/_Steering_Wheel_Infatry -ID:/Keil_v5/Arm/Packs/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/Keil_v5/Arm/Packs/Keil/STM32F4xx_DFP/2.17.1/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o "steering wheel_infatry/config.o" -MD)
I (..\User\component\user_math.h)(0x6982F1BF)
I (D:\Keil_v5\ARM\ARMCLANG\include\float.h)(0x6035A4A0)
I (D:\Keil_v5\ARM\ARMCLANG\include\math.h)(0x6035A4A8)
@ -2546,7 +2546,7 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h)(0x68B055DB)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68B055DB)
I (..\User\device\motor_rm.h)(0x6982F1BF)
I (..\User\module\shoot.h)(0x6968CB81)
I (..\User\module\chassis.h)(0x69AC421E)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\module\struct_typedef.h)(0x68DBD148)
I (..\User\device\bmi088.h)(0x6982F1BF)
I (..\User\component\trapezoidal_profile.h)(0x69AC1BA9)
@ -2687,7 +2687,7 @@ I (..\User\module\cmd\cmd_types.h)(0x69710063)
I (..\User\module\cmd\cmd_adapter.h)(0x697249FA)
I (..\User\device\ET16s.h)(0x69735766)
I (..\User\module\cmd\cmd_behavior.h)(0x695FA70F)
I (..\User\module\chassis.h)(0x69AC421E)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\module\struct_typedef.h)(0x68DBD148)
I (..\User\component\ahrs.h)(0x6982F1BF)
I (..\User\device\bmi088.h)(0x6982F1BF)
@ -2776,7 +2776,7 @@ I (..\User\bsp\mm.h)(0x6982F1BF)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h)(0x68B055DB)
I (..\User\device\motor_rm.h)(0x6982F1BF)
I (..\User\module\shoot.h)(0x6968CB81)
I (..\User\module\chassis.h)(0x69AC421E)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\module\struct_typedef.h)(0x68DBD148)
I (..\User\device\bmi088.h)(0x6982F1BF)
I (..\User\component\trapezoidal_profile.h)(0x69AC1BA9)
@ -2953,7 +2953,7 @@ I (..\User\bsp\bsp.h)(0x6982F1BF)
I (..\User\bsp\mm.h)(0x6982F1BF)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h)(0x68B055DB)
I (..\User\device\motor_rm.h)(0x6982F1BF)
I (..\User\module\chassis.h)(0x69AC421E)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\module\struct_typedef.h)(0x68DBD148)
I (..\User\device\bmi088.h)(0x6982F1BF)
I (..\User\component\trapezoidal_profile.h)(0x69AC1BA9)
@ -3041,7 +3041,7 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\portable\RVDS\ARM_CM4F\portmacro.h
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h)(0x68B055DB)
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\task.h)(0x68B055DB)
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h)(0x68B055DB)
I (..\User\module\chassis.h)(0x69AC421E)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\module\struct_typedef.h)(0x68DBD148)
I (..\User\component\filter.h)(0x6982F1BF)
I (..\User\component\user_math.h)(0x6982F1BF)
@ -3168,7 +3168,7 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h)(0x68B055
I (..\User\device\motor_rm.h)(0x6982F1BF)
I (..\User\module\config.h)(0x696E2066)
I (..\User\module\shoot.h)(0x6968CB81)
I (..\User\module\chassis.h)(0x69AC421E)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\module\struct_typedef.h)(0x68DBD148)
I (..\User\device\bmi088.h)(0x6982F1BF)
I (..\User\component\trapezoidal_profile.h)(0x69AC1BA9)
@ -3246,7 +3246,7 @@ I (..\User\bsp\mm.h)(0x6982F1BF)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h)(0x68B055DB)
I (..\User\device\motor_rm.h)(0x6982F1BF)
I (..\User\module\shoot.h)(0x6968CB81)
I (..\User\module\chassis.h)(0x69AC421E)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\device\bmi088.h)(0x6982F1BF)
I (..\User\component\trapezoidal_profile.h)(0x69AC1BA9)
I (..\User\module\cmd\cmd.h)(0x6986AEE1)
@ -3265,7 +3265,7 @@ I (..\User\device\device.h)(0x6982F1BF)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68B055DB)
I (D:\Keil_v5\ARM\ARMCLANG\include\stddef.h)(0x6035A4A8)
I (..\User\module\cmd\cmd_behavior.h)(0x695FA70F)
I (..\User\module\chassis.h)(0x69AC421E)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\module\struct_typedef.h)(0x68DBD148)
I (..\User\component\filter.h)(0x6982F1BF)
I (..\User\component\user_math.h)(0x6982F1BF)
@ -3350,7 +3350,7 @@ I (..\User\device\ET16s.h)(0x69735766)
I (..\User\device\device.h)(0x6982F1BF)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68B055DB)
I (D:\Keil_v5\ARM\ARMCLANG\include\stddef.h)(0x6035A4A8)
I (..\User\module\chassis.h)(0x69AC421E)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\module\struct_typedef.h)(0x68DBD148)
I (..\User\component\filter.h)(0x6982F1BF)
I (..\User\component\user_math.h)(0x6982F1BF)
@ -3424,7 +3424,7 @@ I (..\User\device\device.h)(0x6982F1BF)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68B055DB)
I (D:\Keil_v5\ARM\ARMCLANG\include\stddef.h)(0x6035A4A8)
I (..\User\module\cmd\cmd_behavior.h)(0x695FA70F)
I (..\User\module\chassis.h)(0x69AC421E)
I (..\User\module\chassis.h)(0x69AC5AFF)
I (..\User\module\struct_typedef.h)(0x68DBD148)
I (..\User\component\filter.h)(0x6982F1BF)
I (..\User\component\user_math.h)(0x6982F1BF)

View File

@ -95,7 +95,7 @@ static float motor_add_angle(float current_angle, int motor_id){
*/
float GetLogicalPosition(float raw, float offset, float range) {
float logic_pos = raw - offset;
// 如果差值为负,说明跨越了 0 点,加上 range 补回循环
if (logic_pos < 0.0f) {
logic_pos += range;
@ -108,67 +108,18 @@ float GetLogicalPosition(float raw, float offset, float range) {
return logic_pos;
}
TrapezoidalProfile telescope_profile;
// float last_target_angle ;
static int8_t Set_Chassis_Attitude(Chassis_t *c,CHASSIS_ATTITUDE_MODE_t mode){
float Telescope_omega_set_point[2];
// c->Set_TelescopeAngle=c->param->Set_TelescopeAngle;
// c->feedfrward=c->param->feedfrward;
//【关键参数】这里的最大速度和加速度需要你根据实际伸缩机构的物理极限来调试!
// 你的位置单位似乎是弧度(rad),速度是 rad/s。请根据实际情况微调这两个值。
// const float V_MAX = 5.0f; // 最大角速度 (rad/s)
// const float ACCEL = 10.0f; // 最大角加速度 (rad/s^2)
//
// // 1. 如果检测到目标角度发生改变,重新初始化规划器
// if (c->Set_TelescopeAngle != c->Last_Set_TelescopeAngle) {
// // 以电机0当前的实际位置作为规划起点
// Profile_Init(&telescope_profile,
// c->feedback.motor_transformation.Telescope_SuperiorAngle[0],
// c->Set_TelescopeAngle,
// V_MAX, ACCEL);
// c->Last_Set_TelescopeAngle = c->Set_TelescopeAngle;
// }
// // 2. 更新规划器状态,计算出当前 dt 周期下应该达到的 瞬时位置 和 瞬时速度
// Profile_Update(&telescope_profile, c->accl_time.dt);
// // 计算两电机真实位置差值,用于监控或其它补偿(保留你的原代码变量)
// c->Telescope_err = (c->feedback.motor_transformation.Telescope_SuperiorAngle[0] -
// c->feedback.motor_transformation.Telescope_SuperiorAngle[1]);
//
// c->Follow_TelescopeAngle=c->feedback.motor_transformation.Telescope_SuperiorAngle[0];
//
//// A. 位置环计算:追踪瞬时位置 profile.current_pos
// for(int i = 0; i < 2; i++){
// float angle_pid_out = PID_Calc(&(c->pid.Telescope_angle[i]),
// telescope_profile.current_pos,
// c->feedback.motor_transformation.Telescope_SuperiorAngle[i],
// 0.0f, c->dt);
//
// // B. 【消除滞后的核心:速度前馈】
// // 目标速度 = 位置环的补偿量 + 规划器输出的瞬时速度
// // (如果你的位置单位是rad速度单位是rad/s前馈系数直接乘1.0f即可)
// float target_omega = angle_pid_out + telescope_profile.current_vel * 1.0f;
// // C. 速度环计算
// c->out.Telescope[i] = PID_Calc(&(c->pid.Telescope_omega[i]),
// target_omega,
// c->feedback.motor_transformation.Telescope_Omega[i],
// 0.0f, c->dt);
// }
/* 前馈添加 */
// c->out.Telescope[1]+=c->feedfrward*c->Telescope_err;
// c->out.Telescope[0]=1;
// switch(mode)
// {
// case STOP_MODE:
// for(int i = 0; i < 2; i++)
// c->out.Telescope[i] = 0.0f;
// break;
// case EXPAND_MODE:
c->Set_TelescopeAngle=c->param->Set_TelescopeAngle;
c->feedfrward=c->param->feedfrward;
switch(mode)
{
case STOP_MODE:
for(int i = 0; i < 2; i++)
c->out.Telescope[i] = 0.0f;
break;
case EXPAND_MODE:
Telescope_omega_set_point[0] = PID_Calc(&(c->pid.Telescope_angle[0]), c->Set_TelescopeAngle,
c->feedback.motor_transformation.Telescope_SuperiorAngle[0], 0.0f, c->dt);
c->out.Telescope[0] = PID_Calc(&(c->pid.Telescope_omega[0]), Telescope_omega_set_point[0],
@ -177,30 +128,31 @@ float GetLogicalPosition(float raw, float offset, float range) {
c->feedback.motor_transformation.Telescope_SuperiorAngle[1], 0.0f, c->dt);
c->out.Telescope[1] = PID_Calc(&(c->pid.Telescope_omega[1]), Telescope_omega_set_point[1],
c->feedback.motor_transformation.Telescope_Omega[1], 0.f, c->dt);
// break;
// case REDUCE_MODE:
//
// // Telescope_omega_set_point = PID_Calc(&(c->pid.Telescope_angle), 0,
// // c->feedback.motor.Telescope_SuperiorAngle, 0.0f, c->dt);
// // c->out.Telescope = PID_Calc(&(c->pid.Telescope_omega), Telescope_omega_set_point,
// // c->feedback.motor.Telescope_Omega, 0.f, c->dt);
// break;
// default:
// for(int i = 0; i < 2; i++)
// c->out.Telescope[i] = 0.0f;
// break;
// }
return CHASSIS_OK;
}
static int8_t TelescopeChassis_Control(Chassis_t *c,CHASSIS_ATTITUDE_MODE_t mode){
c->Follow_TelescopeAngle=c->feedback.motor_transformation.Telescope_SuperiorAngle[0];
/* 前馈添加 */
c->out.Telescope[0]+=c->feedfrward*c->Telescope_err;
break;
case REDUCE_MODE:
Telescope_omega_set_point[0] = PID_Calc(&(c->pid.Telescope_angle[0]), 0,
c->feedback.motor_transformation.Telescope_SuperiorAngle[0], 0.0f, c->dt);
c->out.Telescope[0] = PID_Calc(&(c->pid.Telescope_omega[0]), Telescope_omega_set_point[0],
c->feedback.motor_transformation.Telescope_Omega[0], 0.f, c->dt);
Telescope_omega_set_point[1] = PID_Calc(&(c->pid.Telescope_angle[1]), c->Set_TelescopeAngle,
c->feedback.motor_transformation.Telescope_SuperiorAngle[1], 0.0f, c->dt);
c->out.Telescope[1] = PID_Calc(&(c->pid.Telescope_omega[1]), Telescope_omega_set_point[1],
c->feedback.motor_transformation.Telescope_Omega[1], 0.f, c->dt);
c->Follow_TelescopeAngle=c->feedback.motor_transformation.Telescope_SuperiorAngle[0];
/* 前馈添加 */
c->out.Telescope[0]+=c->feedfrward*c->Telescope_err;
break;
default:
for(int i = 0; i < 2; i++)
c->out.Telescope[i] = 0.0f;
break;
}
return CHASSIS_OK;
}

View File

@ -145,6 +145,7 @@ typedef struct
float chassis6020_detangle[4];
Chassis_Mode_t mode;
ChassisMove_Vec move_vec; // 最终输入速度
TrapezoidalProfile telescope_profile;
/* 设立角度和跟随角度 */
float Set_TelescopeAngle;
float Last_Set_TelescopeAngle;

View File

@ -44,7 +44,7 @@ Config_RobotParam_t robot_config = {
.Telescope_Omega[1]={
.k=0.4f,
.p=0.5f,
.p=0.4f,
.i=0.2f,
.d=0.0f,
.i_limit=1.0f,