小修改了逻辑,添加了注释

This commit is contained in:
yxming66 2025-10-03 18:18:25 +08:00
parent a5b600866b
commit c628b431a9
17 changed files with 4126 additions and 4327 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@ -28,6 +28,10 @@ Project File Date: 10/02/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=30760 RO-data=660 RW-data=236 ZI-data=23076
FromELF: creating hex file...
"shoot\shoot.axf" - 0 Error(s), 0 Warning(s).
<h2>Software Packages used:</h2>

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

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)(0x68DE7D66)(-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)(0x68DF79D0)(-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)
@ -1309,8 +1309,8 @@ 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)(0x68DD0ECB)()
F (..\User\module\shoot_control.c)(0x68DE97A5)(-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)(0x68DE8F09)
F (..\User\module\shoot_control.c)(0x68DF961C)(-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)(0x68DF960C)
I (..\Core\Inc\main.h)(0x68D1384A)
I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal.h)(0x68AD823F)
I (..\Core\Inc\stm32f4xx_hal_conf.h)(0x68D1384A)
@ -1367,8 +1367,8 @@ I (..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h)(0x68AD8208)
I (..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h)(0x68AD8208)
I (D:\cangming\ARM\ARMCLANG\include\string.h)(0x6035A4A8)
I (..\User\bsp\time.h)(0x68D3FFDB)
F (..\User\module\shoot_control.h)(0x68DE8F09)()
F (..\User\module\config.c)(0x68DE90D3)(-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)
F (..\User\module\shoot_control.h)(0x68DF960C)()
F (..\User\module\config.c)(0x68DF817A)(-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)(0x68DD0ECB)
@ -1424,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)(0x68DE8F09)
I (..\User\module\shoot_control.h)(0x68DF960C)
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)
@ -1489,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)(0x68DE8F09)
I (..\User\module\shoot_control.h)(0x68DF960C)
I (..\Core\Inc\main.h)(0x68D1384A)
I (..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal.h)(0x68AD823F)
I (..\Core\Inc\stm32f4xx_hal_conf.h)(0x68D1384A)

Binary file not shown.

View File

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

View File

@ -4,45 +4,44 @@
Breakpoint=D:/CUBEMX/shoot/User/device/motor_rm.c:145:32, State=BP_STATE_DISABLED
Breakpoint=D:/CUBEMX/shoot/User/device/motor_rm.c:148:22, State=BP_STATE_DISABLED
Breakpoint=D:/CUBEMX/shoot/User/module/shoot_control.c:114, State=BP_STATE_DISABLED
GraphedExpression="((shoot).target_variable).target_angle", Color=#e56a6f
GraphedExpression="((shoot).output).outagl_trig", Color=#35792b, Show=0
GraphedExpression="((shoot).output).outomg_trig", Color=#769dda, Show=0
GraphedExpression="((shoot).output).outlpf_trig", Color=#b14f0d, Show=0
GraphedExpression="(((shoot).feedback).trig).torque_current", Color=#b3c38e, Show=0
GraphedExpression="((shoot).feedback).trig_angle_cicle", Color=#ab7b05
OpenDocument="tasks.c", FilePath="D:/CUBEMX/shoot/Middlewares/Third_Party/FreeRTOS/Source/tasks.c", Line=3617
GraphedExpression="(((shoot).feedback).fric[0]).rotor_speed", Color=#e56a6f, Show=0
GraphedExpression="((shoot).output).out_err[0]", Color=#35792b
GraphedExpression="((shoot).output).out_fric[0]", Color=#769dda, Show=0
GraphedExpression="((shoot).output).out_follow[0]", Color=#b14f0d
OpenDocument="tasks.c", FilePath="D:/CUBEMX/shoot/Middlewares/Third_Party/FreeRTOS/Source/tasks.c", Line=3637
OpenDocument="startup_stm32f407xx.s", FilePath="D:/CUBEMX/shoot/MDK-ARM/startup_stm32f407xx.s", Line=161
OpenDocument="main.c", FilePath="D:/CUBEMX/shoot/Core/Src/main.c", Line=66
OpenDocument="stm32f4xx_hal_can.c", FilePath="D:/CUBEMX/shoot/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c", Line=1558
OpenDocument="shoot_control.h", FilePath="D:/CUBEMX/shoot/User/module/shoot_control.h", Line=111
OpenDocument="shoot_control.h", FilePath="D:/CUBEMX/shoot/User/module/shoot_control.h", Line=58
OpenDocument="config.c", FilePath="D:/CUBEMX/shoot/User/module/config.c", Line=39
OpenDocument="queue.c", FilePath="D:/CUBEMX/shoot/Middlewares/Third_Party/FreeRTOS/Source/queue.c", Line=854
OpenDocument="queue.c", FilePath="D:/CUBEMX/shoot/Middlewares/Third_Party/FreeRTOS/Source/queue.c", Line=2062
OpenDocument="filter.c", FilePath="D:/CUBEMX/shoot/User/component/filter.c", Line=49
OpenDocument="shoot_ctrl.c", FilePath="D:/CUBEMX/shoot/User/task/shoot_ctrl.c", Line=1
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=191
OpenDocument="shoot_control.c", FilePath="D:/CUBEMX/shoot/User/module/shoot_control.c", Line=164
OpenDocument="motor.h", FilePath="D:/CUBEMX/shoot/User/device/motor.h", Line=0
OpenDocument="motor_rm.c", FilePath="D:/CUBEMX/shoot/User/device/motor_rm.c", Line=120
OpenDocument="motor_rm.c", FilePath="D:/CUBEMX/shoot/User/device/motor_rm.c", Line=148
OpenToolbar="Debug", Floating=0, x=0, y=0
OpenWindow="Registers 1", DockArea=RIGHT, x=0, y=0, w=726, h=919, TabPos=1, TopOfStack=0, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0, FilteredItems=[], RefreshRate=1
OpenWindow="Source Files", DockArea=LEFT, x=0, y=0, w=301, h=919, TabPos=0, TopOfStack=1, FilterBarShown=0, TotalValueBarShown=0, ToolBarShown=0
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=301, 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="668;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="1 s / Div", TimeStampFormat="Time", DataGraphDrawAsPoints=0, DataGraphLegendShown=1, DataGraphUniformSampleSpacing=0, DataGraphLegendPosition="240;101", DataGraphShowNamesAtCursor=0, PowerGraphDrawAsPoints=0, PowerGraphLegendShown=0, PowerGraphAvgFilterTime=Off, PowerGraphAvgFilterLen=Off, PowerGraphUniformSampleSpacing=0, PowerGraphLegendPosition="1327;-69", CodeGraphLegendShown=0, CodeGraphLegendPosition="1343;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;294]
TableHeader="Functions", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Address";"Size";"#Insts";"Source"], ColWidths=[1594;104;100;100;286]
TableHeader="Registers 1", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Value";"Description"], ColWidths=[100;144;482]
TableHeader="Functions", SortCol="Name", SortOrder="ASCENDING", VisibleCols=["Name";"Address";"Size";"#Insts";"Source"], ColWidths=[1594;104;100;100;100]
TableHeader="Power Sampling", SortCol="None", SortOrder="ASCENDING", VisibleCols=["Index";"Time";"Ch 0"], ColWidths=[100;100;100]
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;103]
TableHeader="Data Sampling Table", SortCol="None", SortOrder="ASCENDING", VisibleCols=["Index";"Time";" ((shoot).target_variable).target_angle";" ((shoot).output).outagl_trig";" ((shoot).output).outomg_trig";" ((shoot).output).outlpf_trig";" (((shoot).feedback).trig).torque_current";" ((shoot).feedback).trig_angle_cicle"], ColWidths=[100;100;100;100;100;100;100;307]
TableHeader="Data Sampling Setup", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Type";"Value";"Min";"Max";"Average";"# Changes";"Min. Change";"Max. Change"], ColWidths=[118;100;144;134;144;144;110;154;144]
TableHeader="Watched Data 1", SortCol="Expression", SortOrder="ASCENDING", VisibleCols=["Expression";"Value";"Location";"Refresh"], ColWidths=[250;282;91;100]
TableHeader="Data Sampling Table", SortCol="None", SortOrder="ASCENDING", VisibleCols=["Index";"Time";" (((shoot).feedback).fric[0]).rotor_speed";" ((shoot).output).out_err[0]";" ((shoot).output).out_fric[0]";" ((shoot).output).out_follow[0]"], ColWidths=[100;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=[118;100;154;164;154;164;110;164;154]
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_cmd", RefreshRate=5, Window=Watched Data 1
WatchedExpression="shoot", RefreshRate=5, Window=Watched Data 1
WatchedExpression="pos", RefreshRate=5, Window=Watched Data 1
WatchedExpression="pos", RefreshRate=5, Window=Watched Data 1
WatchedExpression="feedback_current", Window=Watched Data 1

View File

@ -74,8 +74,7 @@ inline float CircleError(float sp, float fb, float range) {
/**
* \brief x,yrange应设定为y-x
* -M_PI,M_PIrange=M_2PI;(0,M_2PI)range=M_2PI;a,a+brange=b;
* \brief 0,range
*
* \param origin
* \param delta

View File

@ -67,8 +67,8 @@ Config_RobotParam_t robot_config = {
.gear=false,
},
.trig_motor_param = {
.can = BSP_CAN_1,
.id = 0x203,
.can = BSP_CAN_2,
.id = 0x207,
.module = MOTOR_M2006,
.reverse = false,
.gear=true,

View File

@ -1,4 +1,8 @@
/*
* far
*/
/* Includes ----------------------------------------------------------------- */
#include "shoot_control.h"
#include <string.h>
#include "can.h"
@ -7,8 +11,12 @@
#include <math.h>
#include "bsp/time.h"
/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
static bool last_firecmd;
/* Private function -------------------------------------------------------- */
static inline void ScaleSumTo1(float *a, float *b) {
float sum = *a + *b;
if (sum > 1.0f) {
@ -18,7 +26,14 @@ static inline void ScaleSumTo1(float *a, float *b) {
}
}
/**
* \brief
*
* \param s
* \param mode
*
* \return
*/
int8_t Shoot_SetMode(Shoot_t *s, Shoot_Mode_t mode)
{
if (s == NULL) {
@ -28,6 +43,13 @@ int8_t Shoot_SetMode(Shoot_t *s, Shoot_Mode_t mode)
return 0;
}
/**
* \brief PID积分
*
* \param s
*
* \return
*/
int8_t Shoot_ResetIntegral(Shoot_t *s)
{
if (s == NULL) {
@ -43,6 +65,13 @@ int8_t Shoot_ResetIntegral(Shoot_t *s)
return 0;
}
/**
* \brief
*
* \param s
*
* \return
*/
int8_t Shoot_ResetCalu(Shoot_t *s)
{
if (s == NULL) {
@ -62,6 +91,13 @@ int8_t Shoot_ResetCalu(Shoot_t *s)
return 0;
}
/**
* \brief
*
* \param s
*
* \return
*/
int8_t Shoot_ResetOutput(Shoot_t *s)
{
if (s == NULL) {
@ -80,6 +116,14 @@ int8_t Shoot_ResetOutput(Shoot_t *s)
return 0;
}
/**
* \brief
*
* \param s
* \param target_speed m/s
*
* \return
*/
int8_t Shoot_CaluTargetRPM(Shoot_t *s, float target_speed)
{
if (s == NULL) {
@ -88,11 +132,14 @@ int8_t Shoot_CaluTargetRPM(Shoot_t *s, float target_speed)
s->target_variable.target_rpm=4000.0f/MAX_FRIC_RPM;
return 0;
}
/**
* \brief
*
* \param s
* \param num
* \param cmd
*
* \return
*/
int8_t Shoot_CaluTargetAngle(Shoot_t *s, Shoot_CMD_t *cmd)
{
@ -102,42 +149,22 @@ int8_t Shoot_CaluTargetAngle(Shoot_t *s, Shoot_CMD_t *cmd)
if(s->now - s->anglecalu.time_last_shoot >= s->param->shot_delay_time && cmd->firecmd)
{
s->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;
CircleAdd(&s->target_variable.target_angle, s->param->trig_step_angle, M_2PI);
// 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->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;
BSP_CAN_Init();
for(int i=0;i<SHOOT_FRIC_NUM;i++){
MOTOR_RM_Register(&param->fric_motor_param[i]);
PID_Init(&s->pid.fric_follow[i], KPID_MODE_CALC_D, target_freq,&param->fric_follow);
PID_Init(&s->pid.fric_err[i], KPID_MODE_CALC_D, target_freq,&param->fric_err);
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(&s->pid.trig, KPID_MODE_CALC_D, target_freq,&param->trig);
PID_Init(&s->pid.trig_omg, KPID_MODE_CALC_D, target_freq,&param->trig_omg);
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->anglecalu,0,sizeof(s->anglecalu));
memset(&s->output,0,sizeof(s->output));
return 0;
}
/**
* \brief
*
* \param s
*
* \return
*/
int8_t Chassis_UpdateFeedback(Shoot_t *s)
{
if (s == NULL) {
@ -145,20 +172,20 @@ int8_t Chassis_UpdateFeedback(Shoot_t *s)
}
float rpm_sum=0.0f;
for(int i = 0; i < SHOOT_FRIC_NUM; 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)
{
s->feedback.fric[i]=motor_fed->motor.feedback;
}
/* 滤波反馈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];
}
s->feedback.fric_avgrpm=rpm_sum/SHOOT_FRIC_NUM;
@ -168,16 +195,7 @@ int8_t Chassis_UpdateFeedback(Shoot_t *s)
if(motor_fed!=NULL)
{
s->feedback.trig=motor_fed->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.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; //如果单环效果好就删
@ -187,6 +205,14 @@ int8_t Chassis_UpdateFeedback(Shoot_t *s)
return 0;
}
/**
* \brief
*
* \param s
* \param cmd
*
* \return
*/
int8_t Shoot_RunningFSM(Shoot_t *s, Shoot_CMD_t *cmd)
{
if (s == NULL || cmd == NULL) {
@ -206,7 +232,7 @@ int8_t Shoot_RunningFSM(Shoot_t *s, Shoot_CMD_t *cmd)
case SHOOT_STATE_IDLE:/*熄火等待*/
for(int i=0;i<SHOOT_FRIC_NUM;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];
@ -214,10 +240,12 @@ int8_t Shoot_RunningFSM(Shoot_t *s, Shoot_CMD_t *cmd)
MOTOR_RM_SetOutput(&s->param->fric_motor_param[i], s->output.lpfout_fric[i]);
}
s->output.outagl_trig =PID_Calc(&s->pid.trig,pos,s->feedback.trig_angle_cicle,0,s->dt);
s->output.outagl_trig =PID_Calc(&s->pid.trig,pos,s->feedback.trig.rotor_abs_angle,0,s->dt);
s->output.outomg_trig =PID_Calc(&s->pid.trig_omg,s->output.outagl_trig,s->feedback.trig_rpm,0,s->dt);
s->output.outlpf_trig =LowPassFilter2p_Apply(&s->filter.trig.out, s->output.outomg_trig);
MOTOR_RM_SetOutput(&s->param->trig_motor_param, s->output.outlpf_trig);
/* 检查状态机 */
if(cmd->ready)
{
Shoot_ResetCalu(s);
@ -226,8 +254,8 @@ int8_t Shoot_RunningFSM(Shoot_t *s, Shoot_CMD_t *cmd)
s->running_state=SHOOT_STATE_READY;
}
break;
case SHOOT_STATE_READY:/*准备射击*/
case SHOOT_STATE_READY:/*准备射击*/
for(int i=0;i<SHOOT_FRIC_NUM;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);
@ -237,12 +265,12 @@ int8_t Shoot_RunningFSM(Shoot_t *s, Shoot_CMD_t *cmd)
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]);
}
/* 拨弹电机输出 */
s->output.outagl_trig =PID_Calc(&s->pid.trig,pos,s->feedback.trig_angle_cicle,0,s->dt);
s->output.outomg_trig =PID_Calc(&s->pid.trig_omg,s->output.outagl_trig,s->feedback.trig_rpm,0,s->dt);
/* 设置拨弹电机输出 */
s->output.outagl_trig =PID_Calc(&s->pid.trig,pos,s->feedback.trig.rotor_abs_angle,0,s->dt);
s->output.outomg_trig =PID_Calc(&s->pid.trig_omg,s->output.outagl_trig,s->feedback.trig_rpm,0,s->dt);
s->output.outlpf_trig =LowPassFilter2p_Apply(&s->filter.trig.out, s->output.outomg_trig);
MOTOR_RM_SetOutput(&s->param->trig_motor_param, s->output.outlpf_trig);
@ -260,39 +288,55 @@ int8_t Shoot_RunningFSM(Shoot_t *s, Shoot_CMD_t *cmd)
}
break;
case SHOOT_STATE_FIRE:
case SHOOT_STATE_FIRE:/*射击*/
Shoot_CaluTargetAngle(s, cmd);
for(int i=0;i<SHOOT_FRIC_NUM;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]);
}
s->output.outagl_trig =PID_Calc(&s->pid.trig,s->target_variable.target_angle,s->feedback.trig_angle_cicle,0,s->dt);
s->output.outomg_trig =PID_Calc(&s->pid.trig_omg,s->output.outagl_trig,s->feedback.trig_rpm,0,s->dt);
/* 设置拨弹电机输出 */
s->output.outagl_trig =PID_Calc(&s->pid.trig,s->target_variable.target_angle,s->feedback.trig.rotor_abs_angle,0,s->dt);
s->output.outomg_trig =PID_Calc(&s->pid.trig_omg,s->output.outagl_trig,s->feedback.trig_rpm,0,s->dt);
s->output.outlpf_trig =LowPassFilter2p_Apply(&s->filter.trig.out, s->output.outomg_trig);
MOTOR_RM_SetOutput(&s->param->trig_motor_param, s->output.outlpf_trig);
/* 检查状态机 */
if(!cmd->firecmd)
{
s->running_state=SHOOT_STATE_READY;
pos=s->feedback.trig_angle_cicle;
pos=s->feedback.trig.rotor_abs_angle;
}
break;
default:
s->running_state=SHOOT_STATE_IDLE;
break;
}
}
/* 输出 */
MOTOR_RM_Ctrl(&s->param->fric_motor_param[0]);
MOTOR_RM_Ctrl(&s->param->fric_motor_param[4]);
last_firecmd = cmd->firecmd;
return 0;
}
/**
* \brief
*
* \param s
* \param cmd
*
* \return
*/
int8_t Shoot_JamDetectionFSM(Shoot_t *s, Shoot_CMD_t *cmd)
{
if (s == NULL) {
@ -300,36 +344,43 @@ int8_t Shoot_JamDetectionFSM(Shoot_t *s, Shoot_CMD_t *cmd)
}
switch (s->jamdetection.jamfsm_state) {
case SHOOT_JAMFSM_STATE_NORMAL:
case SHOOT_JAMFSM_STATE_NORMAL:/* 正常运行 */
/* 检测电流是否超过阈值 */
if (s->feedback.trig.torque_current/1000.0f > s->param->jam_threshold) {
s->jamdetection.jamfsm_state = SHOOT_JAMFSM_STATE_SUSPECTED;
s->jamdetection.jam_last_time = s->now; // 记录怀疑开始时间
s->jamdetection.jam_last_time = s->now; /* 记录怀疑开始时间 */
}
Shoot_RunningFSM(s, cmd); // 正常运行状态下继续执行射击状态机
/* 正常运行射击状态机 */
Shoot_RunningFSM(s, cmd);
break;
case SHOOT_JAMFSM_STATE_SUSPECTED:
case SHOOT_JAMFSM_STATE_SUSPECTED:/* 怀疑堵塞 */
/* 检测电流是否低于阈值 */
if (s->feedback.trig.torque_current/1000.0f < s->param->jam_threshold) {
s->jamdetection.jamfsm_state = SHOOT_JAMFSM_STATE_NORMAL;
break;
} else {
if ((s->now - s->jamdetection.jam_last_time) >= s->param->jam_suspected_time) {
s->jamdetection.jam_detected =true;
s->jamdetection.jamfsm_state = SHOOT_JAMFSM_STATE_CONFIRMED;
break;
}
}
/* 检测高阈值状态是否超过设定怀疑时间 */
else if ((s->now - s->jamdetection.jam_last_time) >= s->param->jam_suspected_time) {
s->jamdetection.jam_detected =true;
s->jamdetection.jamfsm_state = SHOOT_JAMFSM_STATE_CONFIRMED;
break;
}
/* 正常运行射击状态机 */
Shoot_RunningFSM(s, cmd);
break;
case SHOOT_JAMFSM_STATE_CONFIRMED:
// 进入处理状态,修改拨弹盘目标角度
s->target_variable.target_angle = s->feedback.trig_angle_cicle-0.5f*s->param->trig_step_angle;
case SHOOT_JAMFSM_STATE_CONFIRMED:/* 确认堵塞 */
/* 进入处理状态,修改拨弹盘目标角度 */
s->target_variable.target_angle = s->feedback.trig.rotor_abs_angle-0.5f*s->param->trig_step_angle;
s->jamdetection.jamfsm_state = SHOOT_JAMFSM_STATE_DEAL;
s->jamdetection.jam_last_time = s->now; // 记录处理开始时间
case SHOOT_JAMFSM_STATE_DEAL:
s->jamdetection.jam_last_time = s->now; /* 记录处理开始时间 */
case SHOOT_JAMFSM_STATE_DEAL:/* 堵塞处理 */
/* 正常运行射击状态机 */
Shoot_RunningFSM(s, cmd);
if ((s->now - s->jamdetection.jam_last_time)>=0.3f&&s->output.outlpf_trig < 0.1f) { /* 给予0.3秒响应时间并检测输出,认为堵塞已解除 */
/* 给予0.3秒响应时间并检测电流小于20A认为堵塞已解除 */
if ((s->now - s->jamdetection.jam_last_time)>=0.3f&&s->feedback.trig.torque_current/1000.0f < 20.0f) {
s->jamdetection.jamfsm_state = SHOOT_JAMFSM_STATE_NORMAL;
}
break;
@ -341,7 +392,54 @@ int8_t Shoot_JamDetectionFSM(Shoot_t *s, Shoot_CMD_t *cmd)
return 0;
}
/* Exported functions ------------------------------------------------------- */
/**
* \brief
*
* \param s
* \param param
* \param target_freq Hz
*
* \return
*/
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;
BSP_CAN_Init();
/* 初始化摩擦轮PID和滤波器 */
for(int i=0;i<SHOOT_FRIC_NUM;i++){
MOTOR_RM_Register(&param->fric_motor_param[i]);
PID_Init(&s->pid.fric_follow[i], KPID_MODE_CALC_D, target_freq,&param->fric_follow);
PID_Init(&s->pid.fric_err[i], KPID_MODE_CALC_D, target_freq,&param->fric_err);
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);
}
/* 初始化拨弹PID和滤波器 */
MOTOR_RM_Register(&param->trig_motor_param);
PID_Init(&s->pid.trig, KPID_MODE_CALC_D, target_freq,&param->trig);
PID_Init(&s->pid.trig_omg, KPID_MODE_CALC_D, target_freq,&param->trig_omg);
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->anglecalu,0,sizeof(s->anglecalu));
memset(&s->output,0,sizeof(s->output));
return 0;
}
/**
* \brief
*
* \param s
* \param cmd
*
* \return
*/
int8_t Shoot_Control(Shoot_t *s, Shoot_CMD_t *cmd)
{
if (s == NULL || cmd == NULL) {

View File

@ -1,5 +1,5 @@
/*
* far蛇模组
* far
*/
#pragma once
@ -58,8 +58,6 @@ typedef struct {
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; /* 归一化拨弹电机转速*/
@ -99,7 +97,7 @@ typedef struct {
float jam_threshold; /* 卡弹检测阈值单位A */
float jam_suspected_time; /* 卡弹怀疑时间,单位秒 */
MOTOR_RM_Param_t fric_motor_param[SHOOT_FRIC_NUM];
MOTOR_RM_Param_t fric_motor_param[SHOOT_FRIC_NUM];
MOTOR_RM_Param_t trig_motor_param;
@ -126,45 +124,44 @@ typedef struct {
*
*/
typedef struct {
bool online;
bool online;//待完善,电机或遥控器在线检测
float now;
uint64_t lask_wakeup;
float dt;
Shoot_Params_t *param; /* 发射参数 */
/* 模块通用 */
Shoot_Running_State_t running_state; /* 运行状态机 */
Shoot_Mode_t mode;
/* 反馈信息 */
Shoot_Feedback_t feedback;
/* 控制信息*/
Shoot_JamDetection_t jamdetection;
Shoot_AngleCalu_t anglecalu;
Shoot_Output_t output;
/* 目标控制量 */
struct {
float target_rpm; /* 目标摩擦轮转速 */
float target_angle; /* 目标拨弹位置 */
float now; /* 当前时间,单位秒 */
uint64_t lask_wakeup; /* 上次唤醒时间,单位微秒 */
float dt; /* 两次唤醒间隔时间,单位秒 */
Shoot_Params_t *param; /* 发射参数 */
/* 模块通用 */
Shoot_Running_State_t running_state; /* 运行状态机 */
Shoot_Mode_t mode; /* 射击模式 */
/* 反馈信息 */
Shoot_Feedback_t feedback; /* 反馈信息 */
/* 控制信息*/
Shoot_JamDetection_t jamdetection;
Shoot_AngleCalu_t anglecalu;
Shoot_Output_t output;
/* 目标控制量 */
struct {
float target_rpm; /* 目标摩擦轮转速 */
float target_angle; /* 目标拨弹位置 */
}target_variable;
/* 反馈控制用的PID */
struct {
KPID_t fric_follow[SHOOT_FRIC_NUM]; /* */
KPID_t fric_err[SHOOT_FRIC_NUM]; /* */
KPID_t trig;
KPID_t trig_omg;
KPID_t fric_follow[SHOOT_FRIC_NUM]; /* */
KPID_t fric_err[SHOOT_FRIC_NUM]; /* */
KPID_t trig;
KPID_t trig_omg;
} pid;
/* 滤波器 */
struct {
struct{
LowPassFilter2p_t in[SHOOT_FRIC_NUM]; /* 反馈值滤波器 */
LowPassFilter2p_t out[SHOOT_FRIC_NUM]; /* 输出值滤波器 */
struct{
LowPassFilter2p_t in[SHOOT_FRIC_NUM]; /* 反馈值滤波器 */
LowPassFilter2p_t out[SHOOT_FRIC_NUM]; /* 输出值滤波器 */
}fric;
struct{
LowPassFilter2p_t in; /* 反馈值滤波器 */
LowPassFilter2p_t out; /* 输出值滤波器 */
LowPassFilter2p_t in; /* 反馈值滤波器 */
LowPassFilter2p_t out; /* 输出值滤波器 */
}trig;
} filter;