拨弹单环d项抖动

This commit is contained in:
yxming66 2025-10-01 21:01:31 +08:00
parent 4800d3fe3b
commit 293600caaa
23 changed files with 4824 additions and 4179 deletions

File diff suppressed because one or more lines are too long

View File

@ -153,7 +153,56 @@
<Name>-U-O142 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>130</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\User\module\shoot_control.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>131</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\User\module\shoot_control.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>132</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\User\module\shoot_control.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
<count>0</count>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -28,8 +28,9 @@ Project File Date: 09/30/2025
*** Using Compiler 'V6.16', folder: 'D:\cangming\ARM\ARMCLANG\Bin'
Build target 'shoot'
Note: source file '..\User\bsp\can.c' - object file renamed from 'shoot\can.o' to 'shoot\can_1.o'.
compiling shoot_control.c...
linking...
Program Size: Code=29872 RO-data=660 RW-data=156 ZI-data=21916
Program Size: Code=32088 RO-data=660 RW-data=164 ZI-data=21996
FromELF: creating hex file...
"shoot\shoot.axf" - 0 Error(s), 0 Warning(s).

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -48,4 +48,4 @@ shoot/shoot_control.o: ..\User\module\shoot_control.c \
..\Middlewares\Third_Party\FreeRTOS\Source\include\task.h \
..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h \
..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h \
..\User\bsp\dwt.h
D:\cangming\ARM\ARMCLANG\Bin\..\include\string.h ..\User\bsp\time.h

Binary file not shown.

Binary file not shown.

View File

@ -1268,7 +1268,7 @@ I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr_ex.h)(0x68AD823F)
I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_uart.h)(0x68AD823F)
I (..\User\bsp\bsp.h)(0x68D3FFDB)
F (..\User\device\AT9S_Pro.h)(0x68CE6AC0)()
F (..\User\component\user_math.c)(0x68D3FFDB)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/user_math.o -MD)
F (..\User\component\user_math.c)(0x68DD1413)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/user_math.o -MD)
I (..\User\component\user_math.h)(0x68D3FFDB)
I (D:\cangming\ARM\ARMCLANG\include\float.h)(0x6035A4A0)
I (D:\cangming\ARM\ARMCLANG\include\math.h)(0x6035A4A8)
@ -1299,8 +1299,8 @@ I (D:\cangming\ARM\ARMCLANG\include\stdbool.h)(0x6035A4A8)
I (D:\cangming\ARM\ARMCLANG\include\stdint.h)(0x6035A4A8)
I (D:\cangming\ARM\ARMCLANG\include\stddef.h)(0x6035A4A8)
F (..\User\component\filter.h)(0x68D3FFDB)()
F (..\User\component\pid.c)(0x68D3FFDB)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/pid.o -MD)
I (..\User\component\pid.h)(0x68D3FFDB)
F (..\User\component\pid.c)(0x68DD0ECB)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/pid.o -MD)
I (..\User\component\pid.h)(0x68DD0ECB)
I (D:\cangming\ARM\ARMCLANG\include\stdint.h)(0x6035A4A8)
I (..\User\component\filter.h)(0x68D3FFDB)
I (..\User\component\user_math.h)(0x68D3FFDB)
@ -1308,9 +1308,9 @@ I (D:\cangming\ARM\ARMCLANG\include\float.h)(0x6035A4A0)
I (D:\cangming\ARM\ARMCLANG\include\math.h)(0x6035A4A8)
I (D:\cangming\ARM\ARMCLANG\include\stdbool.h)(0x6035A4A8)
I (D:\cangming\ARM\ARMCLANG\include\stddef.h)(0x6035A4A8)
F (..\User\component\pid.h)(0x68D3FFDB)()
F (..\User\module\shoot_control.c)(0x68DBE4B2)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/shoot_control.o -MD)
I (..\User\module\shoot_control.h)(0x68DBE202)
F (..\User\component\pid.h)(0x68DD0ECB)()
F (..\User\module\shoot_control.c)(0x68DD247A)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/shoot_control.o -MD)
I (..\User\module\shoot_control.h)(0x68DCDC49)
I (..\Core\Inc\main.h)(0x68D1384A)
I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal.h)(0x68AD823F)
I (..\Core\Inc\stm32f4xx_hal_conf.h)(0x68D1384A)
@ -1342,7 +1342,7 @@ I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr.h)(0x68AD823F)
I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr_ex.h)(0x68AD823F)
I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_uart.h)(0x68AD823F)
I (D:\cangming\ARM\ARMCLANG\include\stdbool.h)(0x6035A4A8)
I (..\User\component\pid.h)(0x68D3FFDB)
I (..\User\component\pid.h)(0x68DD0ECB)
I (..\User\component\filter.h)(0x68D3FFDB)
I (..\User\component\user_math.h)(0x68D3FFDB)
I (D:\cangming\ARM\ARMCLANG\include\float.h)(0x6035A4A0)
@ -1365,12 +1365,13 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h)(0x68AD8208
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\task.h)(0x68AD8208)
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h)(0x68AD8208)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68AD8208)
I (..\User\bsp\dwt.h)(0x68D3FFDB)
F (..\User\module\shoot_control.h)(0x68DBE202)()
F (..\User\module\config.c)(0x68DBDF20)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/config.o -MD)
I (D:\cangming\ARM\ARMCLANG\include\string.h)(0x6035A4A8)
I (..\User\bsp\time.h)(0x68D3FFDB)
F (..\User\module\shoot_control.h)(0x68DCDC49)()
F (..\User\module\config.c)(0x68DD16FB)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/config.o -MD)
I (..\User\module\config.h)(0x68DABE70)
I (D:\cangming\ARM\ARMCLANG\include\stdint.h)(0x6035A4A8)
I (..\User\component\pid.h)(0x68D3FFDB)
I (..\User\component\pid.h)(0x68DD0ECB)
I (..\User\component\filter.h)(0x68D3FFDB)
I (..\User\component\user_math.h)(0x68D3FFDB)
I (D:\cangming\ARM\ARMCLANG\include\float.h)(0x6035A4A0)
@ -1423,7 +1424,7 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h)(0x68AD8208
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\task.h)(0x68AD8208)
I (..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h)(0x68AD8208)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68AD8208)
I (..\User\module\shoot_control.h)(0x68DBE202)
I (..\User\module\shoot_control.h)(0x68DCDC49)
F (..\User\module\config.h)(0x68DABE70)()
F (..\User\task\init.c)(0x68D4AE2D)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/init.o -MD)
I (..\User\task\user_task.h)(0x68D3E4B9)
@ -1467,7 +1468,7 @@ I (D:\cangming\ARM\ARMCLANG\include\math.h)(0x6035A4A8)
I (D:\cangming\ARM\ARMCLANG\include\stdbool.h)(0x6035A4A8)
I (..\User\device\device.h)(0x68D400B4)
I (..\User\component\at9s_pro_cmd.h)(0x68D4B9F6)
F (..\User\task\shoot_ctrl.c)(0x68DAC248)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/shoot_ctrl.o -MD)
F (..\User\task\shoot_ctrl.c)(0x68DC9C9B)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/shoot_ctrl.o -MD)
I (..\User\task\user_task.h)(0x68D3E4B9)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68AD8208)
I (D:\cangming\ARM\ARMCLANG\include\stdint.h)(0x6035A4A8)
@ -1488,7 +1489,7 @@ I (..\User\component\user_math.h)(0x68D3FFDB)
I (D:\cangming\ARM\ARMCLANG\include\float.h)(0x6035A4A0)
I (D:\cangming\ARM\ARMCLANG\include\math.h)(0x6035A4A8)
I (..\User\device\device.h)(0x68D400B4)
I (..\User\module\shoot_control.h)(0x68DBE202)
I (..\User\module\shoot_control.h)(0x68DCDC49)
I (..\Core\Inc\main.h)(0x68D1384A)
I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal.h)(0x68AD823F)
I (..\Core\Inc\stm32f4xx_hal_conf.h)(0x68D1384A)
@ -1517,7 +1518,7 @@ I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ramfunc.h)(0x68AD823F
I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr.h)(0x68AD823F)
I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr_ex.h)(0x68AD823F)
I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_uart.h)(0x68AD823F)
I (..\User\component\pid.h)(0x68D3FFDB)
I (..\User\component\pid.h)(0x68DD0ECB)
I (..\User\component\filter.h)(0x68D3FFDB)
I (..\User\device\motor_rm.h)(0x68D3FFBB)
I (..\User\device\motor.h)(0x68D3FFBB)
@ -1527,7 +1528,7 @@ I (..\User\bsp\bsp.h)(0x68D3FFDB)
I (..\User\bsp\mm.h)(0x68D3FFDB)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h)(0x68AD8208)
I (..\User\module\config.h)(0x68DABE70)
F (..\User\task\user_task.c)(0x68D1407D)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/user_task.o -MD)
F (..\User\task\user_task.c)(0x68DCD9EF)(-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./RTE/_shoot -ID:/cangming/ARM/CMSIS/5.7.0/CMSIS/Core/Include -ID:/cangming/keil/STM32F4xx_DFP/2.15.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include -D__UVISION_VERSION="534" -D_RTE_ -DSTM32F407xx -D_RTE_ -DUSE_HAL_DRIVER -DSTM32F407xx -o shoot/user_task.o -MD)
I (..\User\task\user_task.h)(0x68D3E4B9)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68AD8208)
I (D:\cangming\ARM\ARMCLANG\include\stdint.h)(0x6035A4A8)

Binary file not shown.

View File

@ -32,6 +32,7 @@ void OnProjectLoad (void) {
//
// User settings
//
Edit.SysVar (VAR_HSS_SPEED, "100 Hz");
Project.SetOSPlugin ("FreeRTOSPlugin_Cortex-M");
File.Open ("D:/CUBEMX/shoot/MDK-ARM/shoot/shoot.axf");
Util.Error("==== 脚本已加载,路径请看标题栏", 0);

View File

@ -2,12 +2,13 @@
GraphedExpression="(((shoot_c).feedback).fric[1]).rotor_speed", Color=#e56a6f, Show=0
GraphedExpression="(((shoot_c).feedback).fric[0]).rotor_speed", Color=#35792b, Show=0
GraphedExpression="(shoot_c).errtosee", Color=#769dda
GraphedExpression="(shoot_c).errtosee", Color=#769dda, Show=0
OpenDocument="config.c", FilePath="D:/CUBEMX/shoot/User/module/config.c", Line=6
OpenDocument="queue.c", FilePath="D:/CUBEMX/shoot/Middlewares/Third_Party/FreeRTOS/Source/queue.c", Line=854
OpenDocument="main.c", FilePath="D:/CUBEMX/shoot/Core/Src/main.c", Line=66
OpenDocument="shoot_ctrl.c", FilePath="D:/CUBEMX/shoot/User/task/shoot_ctrl.c", Line=7
OpenDocument="rc.c", FilePath="D:/CUBEMX/shoot/User/task/rc.c", Line=0
OpenDocument="shoot_control.c", FilePath="D:/CUBEMX/shoot/User/module/shoot_control.c", Line=44
OpenDocument="shoot_control.c", FilePath="D:/CUBEMX/shoot/User/module/shoot_control.c", Line=0
OpenDocument="startup_stm32f407xx.s", FilePath="D:/CUBEMX/shoot/MDK-ARM/startup_stm32f407xx.s", Line=161
OpenDocument="tasks.c", FilePath="D:/CUBEMX/shoot/Middlewares/Third_Party/FreeRTOS/Source/tasks.c", Line=3419
OpenToolbar="Debug", Floating=0, x=0, y=0
@ -16,7 +17,7 @@ OpenWindow="Source Files", DockArea=LEFT, x=0, y=0, w=300, h=919, TabPos=0, TopO
OpenWindow="Watched Data 1", DockArea=RIGHT, x=0, y=0, w=726, h=919, TabPos=0, TopOfStack=1, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
OpenWindow="Functions", DockArea=LEFT, x=0, y=0, w=300, h=919, TabPos=1, TopOfStack=0, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
OpenWindow="Data Sampling", DockArea=BOTTOM, x=0, y=0, w=1007, h=536, TabPos=0, TopOfStack=1, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0, VisibleTab=0, UniformSampleSpacing=0
OpenWindow="Timeline", DockArea=BOTTOM, x=1, y=0, w=1552, h=555, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=1, DataPaneShown=1, PowerPaneShown=0, CodePaneShown=0, PinCursor="Cursor Movable", TimePerDiv="200 ms / Div", TimeStampFormat="Time", DataGraphDrawAsPoints=0, DataGraphLegendShown=1, DataGraphUniformSampleSpacing=0, DataGraphLegendPosition="61;0", DataGraphShowNamesAtCursor=0, PowerGraphDrawAsPoints=0, PowerGraphLegendShown=0, PowerGraphAvgFilterTime=Off, PowerGraphAvgFilterLen=Off, PowerGraphUniformSampleSpacing=0, PowerGraphLegendPosition="1328;-69", CodeGraphLegendShown=0, CodeGraphLegendPosition="1344;0"
OpenWindow="Timeline", DockArea=BOTTOM, x=1, y=0, w=1552, h=555, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=1, DataPaneShown=1, PowerPaneShown=0, CodePaneShown=0, PinCursor="Cursor Movable", TimePerDiv="200 ms / Div", TimeStampFormat="Time", DataGraphDrawAsPoints=0, DataGraphLegendShown=1, DataGraphUniformSampleSpacing=0, DataGraphLegendPosition="61;0", DataGraphShowNamesAtCursor=0, PowerGraphDrawAsPoints=0, PowerGraphLegendShown=0, PowerGraphAvgFilterTime=Off, PowerGraphAvgFilterLen=Off, PowerGraphUniformSampleSpacing=0, PowerGraphLegendPosition="1328;0", CodeGraphLegendShown=0, CodeGraphLegendPosition="1344;0"
OpenWindow="Console", DockArea=BOTTOM, x=0, y=0, w=1007, h=536, TabPos=1, TopOfStack=0, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
SmartViewPlugin="", Page="", Toolbar="Hidden", Window="SmartView 1"
TableHeader="Registers 1", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Value";"Description"], ColWidths=[100;144;482]
@ -25,9 +26,9 @@ TableHeader="Power Sampling", SortCol="None", SortOrder="ASCENDING", VisibleCols
TableHeader="Task List", SortCol="None", SortOrder="ASCENDING", VisibleCols=["Name";"Run Count";"Priority";"Status";"Timeout";"Stack Info";"ID";"Mutex Count";"Notified Value";"Notify State"], ColWidths=[110;110;110;110;110;110;110;110;110;110]
TableHeader="RegisterSelectionDialog", SortCol="None", SortOrder="ASCENDING", VisibleCols=[], ColWidths=[]
TableHeader="Source Files", SortCol="File", SortOrder="ASCENDING", VisibleCols=["File";"Status";"Size";"#Insts";"Path"], ColWidths=[215;100;100;100;734]
TableHeader="Watched Data 1", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Value";"Location";"Refresh"], ColWidths=[250;282;91;100]
TableHeader="Watched Data 1", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Value";"Location";"Refresh"], ColWidths=[250;282;91;103]
TableHeader="Data Sampling Table", SortCol="None", SortOrder="ASCENDING", VisibleCols=["Index";"Time";" (((shoot_c).feedback).fric[1]).rotor_speed";" (((shoot_c).feedback).fric[0]).rotor_speed";" (shoot_c).errtosee"], ColWidths=[100;100;100;100;100]
TableHeader="Data Sampling Setup", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Type";"Value";"Min";"Max";"Average";"# Changes";"Min. Change";"Max. Change"], ColWidths=[406;100;100;100;100;154;110;126;126]
TableHeader="Data Sampling Setup", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Type";"Value";"Min";"Max";"Average";"# Changes";"Min. Change";"Max. Change"], ColWidths=[406;100;100;100;100;100;110;126;126]
TableHeader="TargetExceptionDialog", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Value";"Address";"Description"], ColWidths=[200;100;100;340]
WatchedExpression="shoot_ctrl_cmd_rc", RefreshRate=5, Window=Watched Data 1
WatchedExpression="shoot_c", RefreshRate=5, Window=Watched Data 1

View File

@ -96,11 +96,12 @@ float PID_Calc(KPID_t *pid, float sp, float fb, float fb_dot, float dt) {
/* 计算PD输出 */
float output = (k_err * pid->param->p) - (d * pid->param->d);
pid->last.p_out = k_err * pid->param->p;
pid->last.d_out = d * pid->param->d;
/* 计算I项 */
const float i = pid->i + (k_err * dt);
const float i_out = i * pid->param->i;
pid->last.i_out = i_out;
if (pid->param->i > SIGMA) {
/* 检查是否饱和 */
if (isfinite(i)) {

View File

@ -52,6 +52,9 @@ typedef struct {
struct {
float err; /* 上次误差 */
float k_fb; /* 上次反馈值 */
float p_out;
float i_out;
float d_out;
float out; /* 上次输出 */
} last;

View File

@ -20,6 +20,9 @@ Config_RobotParam_t robot_config = {
.shoot_param = {
.trig_step_angle=M_2PI/8,
.shot_delay_time=0.2f,
.shot_burst_num=3,
.fric_motor_param[0] = {
.can = BSP_CAN_2,
.id = 0x201,
@ -69,7 +72,7 @@ Config_RobotParam_t robot_config = {
.i_limit=0.2f,
.out_limit=0.9f,
.d_cutoff_freq=30.0f,
.range=-1.0f,
.range=M_2PI,
},
.filter.fric = {
.in = 30.0f,

View File

@ -1,10 +1,11 @@
#include "shoot_control.h"
#include <string.h>
#include "can.h"
#include "component/filter.h"
#include "component/user_math.h"
#include <math.h>
#include "bsp/dwt.h"
#include "bsp/time.h"
static bool last_firecmd;
@ -18,143 +19,277 @@ static inline void ScaleSumTo1(float *a, float *b) {
}
int8_t Shoot_Init(shoot_t *c, Shoot_Params_t *param, float target_freq)
int8_t Shoot_SetMode(shoot_t *s, Shoot_Mode_t mode)
{
if (c == NULL || param == NULL || target_freq <= 0.0f) {
if (s == NULL) {
return -1; // 参数错误
}
c->param=param;
s->mode=mode;
return 0;
}
int8_t Shoot_ResetIntegral(shoot_t *s)
{
if (s == NULL) {
return -1; // 参数错误
}
for(int i=0;i<SHOOT_FRIC_NUM;i++)
{
PID_ResetIntegral(&s->pid.fric_follow[i]);
PID_ResetIntegral(&s->pid.fric_err[i]);
}
PID_ResetIntegral(&s->pid.trig);
return 0;
}
int8_t Shoot_ResetCalu(shoot_t *s)
{
if (s == NULL) {
return -1; // 参数错误
}
for(int i=0;i<SHOOT_FRIC_NUM;i++)
{
PID_Reset(&s->pid.fric_follow[i]);
PID_Reset(&s->pid.fric_err[i]);
LowPassFilter2p_Reset(&s->filter.fric.in[i], 0.0f);
LowPassFilter2p_Reset(&s->filter.fric.out[i], 0.0f);
}
// PID_Reset(&s->pid.trig);
LowPassFilter2p_Reset(&s->filter.trig.in, 0.0f);
LowPassFilter2p_Reset(&s->filter.trig.out, 0.0f);
return 0;
}
int8_t Shoot_ResetOutput(shoot_t *s)
{
if (s == NULL) {
return -1; // 参数错误
}
for(int i=0;i<SHOOT_FRIC_NUM;i++)
{
s->output.out_follow[i]=0.0f;
s->output.out_err[i]=0.0f;
s->output.out_fric[i]=0.0f;
s->output.lpfout_fric[i]=0.0f;
}
s->output.out_trig=0.0f;
s->output.lpfout_trig=0.0f;
return 0;
}
int8_t Shoot_CaluTargetRPM(shoot_t *s, float target_speed)
{
if (s == NULL) {
return -1; // 参数错误
}
s->target_variable.target_rpm=target_speed;
return 0;
}
/**
* \brief
*
* \param s
* \param num
*/
int8_t Shoot_CaluTargetAngle(shoot_t *s, Shoot_CMD_t *cmd)
{
if (s == NULL || s->shoot_Anglecalu.num_to_shoot == 0) {
return -1;
}
if(s->now - s->shoot_Anglecalu.time_last_shoot >= s->param->shot_delay_time && cmd->firecmd)
{
s->shoot_Anglecalu.time_last_shoot=s->now;
s->target_variable.target_angle += s->param->trig_step_angle;
if(s->target_variable.target_angle>M_PI)s->target_variable.target_angle-=M_2PI;
else if((s->target_variable.target_angle<-M_PI))s->target_variable.target_angle+=M_2PI;
s->shoot_Anglecalu.num_to_shoot--;
}
return 0;
}
int8_t Shoot_Init(shoot_t *s, Shoot_Params_t *param, float target_freq)
{
if (s == NULL || param == NULL || target_freq <= 0.0f) {
return -1; // 参数错误
}
s->param=param;
DWT_Init(168);
BSP_CAN_Init();
for(int i=0;i<SHOOT_FRIC_NUM;i++){
MOTOR_RM_Register(&param->fric_motor_param[i]);
PID_Init(&c->pid.fric_follow[i], KPID_MODE_CALC_D, target_freq,&param->fric_follow);
LowPassFilter2p_Init(&c->filter.fric.in[i], target_freq, c->param->filter.fric.in);
LowPassFilter2p_Init(&c->filter.fric.out[i], target_freq, c->param->filter.fric.out);
PID_Init(&s->pid.fric_follow[i], KPID_MODE_CALC_D, target_freq,&param->fric_follow);
LowPassFilter2p_Init(&s->filter.fric.in[i], target_freq, s->param->filter.fric.in);
LowPassFilter2p_Init(&s->filter.fric.out[i], target_freq, s->param->filter.fric.out);
}
MOTOR_RM_Register(&param->trig_motor_param);
PID_Init(&c->pid.trig, KPID_MODE_CALC_D, target_freq,&param->trig);
PID_Init(&s->pid.trig, KPID_MODE_CALC_D, target_freq,&param->trig);
LowPassFilter2p_Init(&c->filter.trig.in, target_freq, c->param->filter.trig.in);
LowPassFilter2p_Init(&c->filter.trig.out, target_freq, c->param->filter.trig.out);
LowPassFilter2p_Init(&s->filter.trig.in, target_freq, s->param->filter.trig.in);
LowPassFilter2p_Init(&s->filter.trig.out, target_freq, s->param->filter.trig.out);
memset(&s->shoot_Anglecalu,0,sizeof(s->shoot_Anglecalu));
memset(&s->output,0,sizeof(s->output));
return 0;
}
int8_t Chassis_UpdateFeedback(shoot_t *c)
int8_t Chassis_UpdateFeedback(shoot_t *s)
{
if (c == NULL) {
if (s == NULL) {
return -1; // 参数错误
}
float rpm_sum=0.0f;
for(int i = 0; i < SHOOT_FRIC_NUM; i++) {
MOTOR_RM_Update(&c->param->fric_motor_param[i]);
MOTOR_RM_t *motor_fed = MOTOR_RM_GetMotor(&c->param->fric_motor_param[i]);
/* 更新摩擦电机反馈 */
MOTOR_RM_Update(&s->param->fric_motor_param[i]);
MOTOR_RM_t *motor_fed = MOTOR_RM_GetMotor(&s->param->fric_motor_param[i]);
if(motor_fed!=NULL)
{
c->feedback.fric[i]=motor_fed->motor.feedback;
s->feedback.fric[i]=motor_fed->motor.feedback;
}
c->feedback.fil_fric_rpm[i] = LowPassFilter2p_Apply(&c->filter.fric.in[i], c->feedback.fric[i].rotor_speed);
c->feedback.fric_rpm[i] = c->feedback.fil_fric_rpm[i] / MAX_FRIC_RPM;
if(c->feedback.fric_rpm[i]>1.0f)c->feedback.fric_rpm[i]=1.0f;
if(c->feedback.fric_rpm[i]<-1.0f)c->feedback.fric_rpm[i]=-1.0f;
rpm_sum+=c->feedback.fric_rpm[i];
/* 滤波反馈rpm */
s->feedback.fil_fric_rpm[i] = LowPassFilter2p_Apply(&s->filter.fric.in[i], s->feedback.fric[i].rotor_speed);
/* 归一化rpm */
s->feedback.fric_rpm[i] = s->feedback.fil_fric_rpm[i] / MAX_FRIC_RPM;
if(s->feedback.fric_rpm[i]>1.0f)s->feedback.fric_rpm[i]=1.0f;
if(s->feedback.fric_rpm[i]<-1.0f)s->feedback.fric_rpm[i]=-1.0f;
/* 计算平均rpm */
rpm_sum+=s->feedback.fric_rpm[i];
}
c->feedback.fric_avgrpm=rpm_sum/SHOOT_FRIC_NUM;
MOTOR_RM_Update(&c->param->trig_motor_param);
c->feedback.trig = MOTOR_RM_GetMotor(&c->param->trig_motor_param);
s->feedback.fric_avgrpm=rpm_sum/SHOOT_FRIC_NUM;
/* 更新拨弹电机反馈 */
MOTOR_RM_Update(&s->param->trig_motor_param);
MOTOR_RM_t *motor_fed = MOTOR_RM_GetMotor(&s->param->trig_motor_param);
if(motor_fed!=NULL)
{
s->feedback.trig=motor_fed->motor.feedback;
}
/* 将多圈角度归化到单圈 (-M_PI, M_PI) */
s->feedback.trig_angle_cicle = s->feedback.trig.rotor_abs_angle;
s->feedback.trig_angle_cicle = fmod(s->feedback.trig_angle_cicle, M_2PI); // 将角度限制在 [-2π, 2π]
if (s->feedback.trig_angle_cicle > M_PI) {
s->feedback.trig_angle_cicle -= M_2PI; // 调整到 [-π, π]
}else if (s->feedback.trig_angle_cicle < -M_PI) {
s->feedback.trig_angle_cicle += M_2PI; // 调整到 [-π, π]
}
// s->feedback.trig_angle_cicle = fmodf(s->feedback.trig.rotor_abs_angle, M_2PI);
// if(s->feedback.trig_angle_cicle<0.0f)
// {
// s->feedback.trig_angle_cicle+=M_2PI;
// }
// s->feedback.trig_angle_cicle = s->feedback.trig.rotor_abs_angle;
// CircleAdd(&s->feedback.trig_angle_cicle, 0.0f, M_2PI);
//
c->feedback.fil_trig_rpm = LowPassFilter2p_Apply(&c->filter.trig.in, c->feedback.trig->feedback.rotor_speed);
c->feedback.trig_rpm = c->feedback.trig->feedback.rotor_speed / MAX_TRIG_RPM;
if(c->feedback.trig_rpm>1.0f)c->feedback.trig_rpm=1.0f; //如果单环效果好就删
if(c->feedback.trig_rpm<-1.0f)c->feedback.trig_rpm=-1.0f;
s->feedback.fil_trig_rpm = LowPassFilter2p_Apply(&s->filter.trig.in, s->feedback.trig.rotor_speed);
s->feedback.trig_rpm = s->feedback.trig.rotor_speed / MAX_TRIG_RPM;
if(s->feedback.trig_rpm>1.0f)s->feedback.trig_rpm=1.0f; //如果单环效果好就删
if(s->feedback.trig_rpm<-1.0f)s->feedback.trig_rpm=-1.0f;
//
c->errtosee = c->feedback.fric[0].rotor_speed - c->feedback.fric[1].rotor_speed;
s->errtosee = s->feedback.fric[0].rotor_speed - s->feedback.fric[1].rotor_speed;
return 0;
}
int8_t Shoot_Control(shoot_t *c, const Shoot_CMD_t *cmd)
float a;
int8_t Shoot_Control(shoot_t *s, Shoot_CMD_t *cmd)
{
if (c == NULL || cmd == NULL) {
if (s == NULL || cmd == NULL) {
return -1; // 参数错误
}
c->dt = DWT_GetDeltaT(&c->lask_wakeup);
// c->running_state = cmd->state;
c->online = cmd->online;
if(!c->online /*|| c->mode==SHOOT_MODE_SAFE*/){
s->now = BSP_TIME_Get_us() / 1000000.0f;
s->dt = (BSP_TIME_Get_us() - s->lask_wakeup) / 1000000.0f;
s->lask_wakeup = BSP_TIME_Get_us();
// s->running_state = cmd->state;
s->online = cmd->online;
if(!s->online /*|| s->mode==SHOOT_MODE_SAFE*/){
for(int i=0;i<SHOOT_FRIC_NUM;i++)
{
MOTOR_RM_Relax(&c->param->fric_motor_param[i]);
MOTOR_RM_Relax(&s->param->fric_motor_param[i]);
}
MOTOR_RM_Relax(&c->param->trig_motor_param);
MOTOR_RM_Relax(&s->param->trig_motor_param);
}
else{
switch(c->running_state)
a=CircleError(s->target_variable.target_angle, s->feedback.trig_angle_cicle, M_2PI);
switch(s->running_state)
{
case SHOOT_STATE_IDLE:/*熄火等待*/
for(int i=0;i<SHOOT_FRIC_NUM;i++)
{
PID_ResetIntegral(&c->pid.fric_follow[i]);
c->output.out_follow[i]=PID_Calc(&c->pid.fric_follow[i],0.0f,c->feedback.fric_rpm[i],0,c->dt);
c->output.out_fric[i]=c->output.out_follow[i];
c->output.lpfout_fric[i] = LowPassFilter2p_Apply(&c->filter.fric.out[i], c->output.out_fric[i]);
MOTOR_RM_SetOutput(&c->param->fric_motor_param[i], c->output.lpfout_fric[i]);
PID_ResetIntegral(&s->pid.fric_follow[i]);
s->output.out_follow[i]=PID_Calc(&s->pid.fric_follow[i],0.0f,s->feedback.fric_rpm[i],0,s->dt);
s->output.out_fric[i]=s->output.out_follow[i];
s->output.lpfout_fric[i] = LowPassFilter2p_Apply(&s->filter.fric.out[i], s->output.out_fric[i]);
MOTOR_RM_SetOutput(&s->param->fric_motor_param[i], s->output.lpfout_fric[i]);
}
c->output.out_trig=PID_Calc(&c->pid.trig,c->target_variable.target_angle,c->feedback.trig->gearbox_total_angle,0,c->dt);
MOTOR_RM_SetOutput(&c->param->trig_motor_param, c->output.out_trig);
s->output.out_trig=PID_Calc(&s->pid.trig,s->target_variable.target_angle,s->feedback.trig_angle_cicle,0,s->dt);
MOTOR_RM_SetOutput(&s->param->trig_motor_param, s->output.out_trig);
if(cmd->ready)
{
c->running_state=SHOOT_STATE_READY;
{
Shoot_ResetCalu(s);
// Shoot_ResetIntegral(s);
// Shoot_ResetOutput(s);
s->running_state=SHOOT_STATE_READY;
}
break;
case SHOOT_STATE_READY:/*准备射击*/
for(int i=0;i<SHOOT_FRIC_NUM;i++)
{ /* 计算跟随输出->计算修正输出->加和、滤波、输出 */
c->output.out_follow[i]=PID_Calc(&c->pid.fric_follow[i],c->target_variable.target_rpm/MAX_FRIC_RPM,c->feedback.fric_rpm[i],0,c->dt);
c->output.out_err[i]=PID_Calc(&c->pid.fric_err[i],c->feedback.fric_avgrpm,c->feedback.fric_rpm[i],0,c->dt);
ScaleSumTo1(&c->output.out_follow[i], &c->output.out_err[i]);
c->output.out_fric[i]=c->output.out_follow[i]+c->output.out_err[i];
c->output.lpfout_fric[i] = LowPassFilter2p_Apply(&c->filter.fric.out[i], c->output.out_fric[i]);
MOTOR_RM_SetOutput(&c->param->fric_motor_param[i], c->output.lpfout_fric[i]);
{ /* 计算跟随输出、计算修正输出 */
s->output.out_follow[i]=PID_Calc(&s->pid.fric_follow[i],s->target_variable.target_rpm/MAX_FRIC_RPM,s->feedback.fric_rpm[i],0,s->dt);
s->output.out_err[i]=PID_Calc(&s->pid.fric_err[i],s->feedback.fric_avgrpm,s->feedback.fric_rpm[i],0,s->dt);
/* 按比例缩放并加和输出 */
ScaleSumTo1(&s->output.out_follow[i], &s->output.out_err[i]);
s->output.out_fric[i]=s->output.out_follow[i]+s->output.out_err[i];
/* 滤波 */
s->output.lpfout_fric[i] = LowPassFilter2p_Apply(&s->filter.fric.out[i], s->output.out_fric[i]);
/* 输出 */
MOTOR_RM_SetOutput(&s->param->fric_motor_param[i], s->output.lpfout_fric[i]);
}
c->output.out_trig=PID_Calc(&c->pid.trig,c->target_variable.target_angle,c->feedback.trig->gearbox_total_angle,0,c->dt);
MOTOR_RM_SetOutput(&c->param->trig_motor_param, c->output.out_trig);
/* 拨弹电机输出 */
s->output.out_trig=PID_Calc(&s->pid.trig,s->target_variable.target_angle,s->feedback.trig_angle_cicle,0,s->dt);
MOTOR_RM_SetOutput(&s->param->trig_motor_param, s->output.out_trig);
/* 检查状态机 */
if(!cmd->ready)
{
c->running_state=SHOOT_STATE_IDLE;
// Shoot_ResetCalu(s);
// Shoot_ResetOutput(s);
s->running_state=SHOOT_STATE_IDLE;
}
else if(last_firecmd==false&&cmd->firecmd==true)//可以加一个到达目标速度的判断
else if(last_firecmd==false&&cmd->firecmd==true)
{
c->running_state=SHOOT_STATE_FIRE;
c->target_variable.target_angle+=c->param->trig_step_angle;
Shoot_ResetCalu(s);
Shoot_ResetOutput(s);
s->running_state=SHOOT_STATE_FIRE;
s->shoot_Anglecalu.num_to_shoot+=1;
}
break;
case SHOOT_STATE_FIRE:
// c->target_variable.target_angle+=c->param->trig_step_angle;
Shoot_CaluTargetAngle(s, cmd);
for(int i=0;i<SHOOT_FRIC_NUM;i++)
{
c->output.out_follow[i]=PID_Calc(&c->pid.fric_follow[i],c->target_variable.target_rpm/MAX_FRIC_RPM,c->feedback.fric_rpm[i],0,c->dt);
c->output.out_err[i]=PID_Calc(&c->pid.fric_err[i],c->feedback.fric_avgrpm,c->feedback.fric_rpm[i],0,c->dt);
ScaleSumTo1(&c->output.out_follow[i], &c->output.out_err[i]);
c->output.out_fric[i]=c->output.out_follow[i]+c->output.out_err[i];
c->output.lpfout_fric[i] = LowPassFilter2p_Apply(&c->filter.fric.out[i], c->output.out_fric[i]);
MOTOR_RM_SetOutput(&c->param->fric_motor_param[i], c->output.lpfout_fric[i]);
s->output.out_follow[i]=PID_Calc(&s->pid.fric_follow[i],s->target_variable.target_rpm/MAX_FRIC_RPM,s->feedback.fric_rpm[i],0,s->dt);
s->output.out_err[i]=PID_Calc(&s->pid.fric_err[i],s->feedback.fric_avgrpm,s->feedback.fric_rpm[i],0,s->dt);
ScaleSumTo1(&s->output.out_follow[i], &s->output.out_err[i]);
s->output.out_fric[i]=s->output.out_follow[i]+s->output.out_err[i];
s->output.lpfout_fric[i] = LowPassFilter2p_Apply(&s->filter.fric.out[i], s->output.out_fric[i]);
MOTOR_RM_SetOutput(&s->param->fric_motor_param[i], s->output.lpfout_fric[i]);
}
c->output.out_trig=PID_Calc(&c->pid.trig,c->target_variable.target_angle,c->feedback.trig->gearbox_total_angle,0,c->dt);
MOTOR_RM_SetOutput(&c->param->trig_motor_param, c->output.out_trig);
s->output.out_trig=PID_Calc(&s->pid.trig,s->target_variable.target_angle,s->feedback.trig_angle_cicle,0,s->dt);
MOTOR_RM_SetOutput(&s->param->trig_motor_param, s->output.out_trig);
if(!cmd->firecmd)
{
c->running_state=SHOOT_STATE_READY;
Shoot_ResetCalu(s);
Shoot_ResetOutput(s);
s->running_state=SHOOT_STATE_READY;
}
break;
default:
c->running_state=SHOOT_STATE_IDLE;
s->running_state=SHOOT_STATE_IDLE;
break;
}
}
MOTOR_RM_Ctrl(&c->param->fric_motor_param[0]);
MOTOR_RM_Ctrl(&s->param->fric_motor_param[0]);
last_firecmd = cmd->firecmd;
return 0;
}

View File

@ -48,17 +48,25 @@ typedef struct {
} Shoot_CMD_t;
typedef struct {
MOTOR_Feedback_t fric[SHOOT_FRIC_NUM]; /* 摩擦轮电机反馈 */
MOTOR_RM_t *trig; /* 拨弹电机反馈 */
MOTOR_Feedback_t trig; /* 拨弹电机反馈 */
float fil_fric_rpm[SHOOT_FRIC_NUM]; /* 滤波后的摩擦轮转速 */
float fil_trig_rpm; /* 滤波后的拨弹电机转速*/
float trig_angle_cicle; /* 拨弹电机减速输出轴单圈角度0~M_2PI */
float fric_rpm[SHOOT_FRIC_NUM]; /* 归一化摩擦轮转速 */
float fric_avgrpm; /* 归一化摩擦轮平均转速*/
float trig_rpm; /* 归一化拨弹电机转速*/
}Shoot_Feedback_t;
typedef struct{
float time_last_shoot;
uint8_t num_to_shoot;
uint8_t num_shooted;
}Shoot_AngleCalu_t;
typedef struct {
float out_follow[SHOOT_FRIC_NUM];
float out_err[SHOOT_FRIC_NUM];
@ -73,7 +81,9 @@ typedef struct {
/* 底盘参数的结构体包含所有初始化用的参数通常是const存好几组 */
typedef struct {
float trig_step_angle; /* 每次拨弹电机转动的角度 */
float trig_step_angle; /* 每发弹丸拨弹电机转动的角度 */
float shot_delay_time; /* 射击间隔时间,单位秒 */
uint8_t shot_burst_num; /* 多发模式下一次射击的发数 */
MOTOR_RM_Param_t fric_motor_param[SHOOT_FRIC_NUM];
MOTOR_RM_Param_t trig_motor_param;
@ -104,8 +114,9 @@ typedef struct {
typedef struct {
bool online;
uint32_t lask_wakeup;
float dt;
float now;
uint64_t lask_wakeup;
float dt;
Shoot_Params_t *param; /* */
/* 模块通用 */
@ -114,6 +125,7 @@ typedef struct {
/* 反馈信息 */
Shoot_Feedback_t feedback;
/* 控制信息*/
Shoot_AngleCalu_t shoot_Anglecalu;
Shoot_Output_t output;
/* 目标控制量 */
struct {
@ -149,32 +161,32 @@ typedef struct {
/**
* \brief
*
* \param c
* \param s
* \param param
* \param target_freq
*
* \return
*/
int8_t Shoot_Init(shoot_t *c, Shoot_Params_t *param, float target_freq);
int8_t Shoot_Init(shoot_t *s, Shoot_Params_t *param, float target_freq);
/**
* \brief
*
* \param c
* \param s
*
* \return
*/
int8_t Chassis_UpdateFeedback(shoot_t *c);
int8_t Chassis_UpdateFeedback(shoot_t *s);
/**
* \brief
*
* \param c
* \param s
* \param cmd
*
* \return
*/
int8_t Shoot_Control(shoot_t *c, const Shoot_CMD_t *cmd);
int8_t Shoot_Control(shoot_t *s, Shoot_CMD_t *cmd);

View File

@ -17,7 +17,7 @@
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
COMP_AT9S_CMD_t shoot_ctrl_cmd_rc;
shoot_t shoot_c;
shoot_t shoot;
Shoot_CMD_t shoot_cmd;
/* USER STRUCT BEGIN */
@ -36,7 +36,7 @@ void Task_shoot_ctrl(void *argument) {
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
/* USER CODE INIT BEGIN */
Shoot_Init(&shoot_c,&Config_GetRobotParam()->shoot_param,SHOOT_CTRL_FREQ);
Shoot_Init(&shoot,&Config_GetRobotParam()->shoot_param,SHOOT_CTRL_FREQ);
/* USER CODE INIT END */
while (1) {
@ -46,8 +46,8 @@ void Task_shoot_ctrl(void *argument) {
shoot_cmd.ready=shoot_ctrl_cmd_rc.shoot.ready;
shoot_cmd.firecmd=shoot_ctrl_cmd_rc.shoot.firecmd;
shoot_cmd.online=shoot_ctrl_cmd_rc.online;
Chassis_UpdateFeedback(&shoot_c);
Shoot_Control(&shoot_c,&shoot_cmd);
Chassis_UpdateFeedback(&shoot);
Shoot_Control(&shoot,&shoot_cmd);
/* USER CODE END */
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
}

View File

@ -12,7 +12,7 @@ const osThreadAttr_t attr_init = {
const osThreadAttr_t attr_shoot_ctrl = {
.name = "shoot_ctrl",
.priority = osPriorityNormal,
.stack_size = 256 * 4,
.stack_size = 512 * 4,
};
const osThreadAttr_t attr_rc = {
.name = "rc",