Compare commits
No commits in common. "f641fe4051597e9eedbe113f34bdae0a1f8e8384" and "476268298a665b4d60ed95466847d4631fb8af53" have entirely different histories.
f641fe4051
...
476268298a
12
.mxproject
12
.mxproject
File diff suppressed because one or more lines are too long
@ -59,7 +59,6 @@ void EXTI3_IRQHandler(void);
|
|||||||
void EXTI4_IRQHandler(void);
|
void EXTI4_IRQHandler(void);
|
||||||
void DMA1_Stream1_IRQHandler(void);
|
void DMA1_Stream1_IRQHandler(void);
|
||||||
void DMA1_Stream2_IRQHandler(void);
|
void DMA1_Stream2_IRQHandler(void);
|
||||||
void CAN1_TX_IRQHandler(void);
|
|
||||||
void CAN1_RX0_IRQHandler(void);
|
void CAN1_RX0_IRQHandler(void);
|
||||||
void CAN1_RX1_IRQHandler(void);
|
void CAN1_RX1_IRQHandler(void);
|
||||||
void EXTI9_5_IRQHandler(void);
|
void EXTI9_5_IRQHandler(void);
|
||||||
@ -70,7 +69,6 @@ void TIM7_IRQHandler(void);
|
|||||||
void DMA2_Stream1_IRQHandler(void);
|
void DMA2_Stream1_IRQHandler(void);
|
||||||
void DMA2_Stream2_IRQHandler(void);
|
void DMA2_Stream2_IRQHandler(void);
|
||||||
void DMA2_Stream3_IRQHandler(void);
|
void DMA2_Stream3_IRQHandler(void);
|
||||||
void CAN2_TX_IRQHandler(void);
|
|
||||||
void CAN2_RX0_IRQHandler(void);
|
void CAN2_RX0_IRQHandler(void);
|
||||||
void CAN2_RX1_IRQHandler(void);
|
void CAN2_RX1_IRQHandler(void);
|
||||||
void OTG_FS_IRQHandler(void);
|
void OTG_FS_IRQHandler(void);
|
||||||
|
|||||||
@ -122,8 +122,6 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)
|
|||||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* CAN1 interrupt Init */
|
/* CAN1 interrupt Init */
|
||||||
HAL_NVIC_SetPriority(CAN1_TX_IRQn, 5, 0);
|
|
||||||
HAL_NVIC_EnableIRQ(CAN1_TX_IRQn);
|
|
||||||
HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 5, 0);
|
||||||
HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn);
|
HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn);
|
||||||
HAL_NVIC_SetPriority(CAN1_RX1_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(CAN1_RX1_IRQn, 5, 0);
|
||||||
@ -157,8 +155,6 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)
|
|||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* CAN2 interrupt Init */
|
/* CAN2 interrupt Init */
|
||||||
HAL_NVIC_SetPriority(CAN2_TX_IRQn, 5, 0);
|
|
||||||
HAL_NVIC_EnableIRQ(CAN2_TX_IRQn);
|
|
||||||
HAL_NVIC_SetPriority(CAN2_RX0_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(CAN2_RX0_IRQn, 5, 0);
|
||||||
HAL_NVIC_EnableIRQ(CAN2_RX0_IRQn);
|
HAL_NVIC_EnableIRQ(CAN2_RX0_IRQn);
|
||||||
HAL_NVIC_SetPriority(CAN2_RX1_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(CAN2_RX1_IRQn, 5, 0);
|
||||||
@ -190,7 +186,6 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)
|
|||||||
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1);
|
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1);
|
||||||
|
|
||||||
/* CAN1 interrupt Deinit */
|
/* CAN1 interrupt Deinit */
|
||||||
HAL_NVIC_DisableIRQ(CAN1_TX_IRQn);
|
|
||||||
HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn);
|
HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn);
|
||||||
HAL_NVIC_DisableIRQ(CAN1_RX1_IRQn);
|
HAL_NVIC_DisableIRQ(CAN1_RX1_IRQn);
|
||||||
/* USER CODE BEGIN CAN1_MspDeInit 1 */
|
/* USER CODE BEGIN CAN1_MspDeInit 1 */
|
||||||
@ -216,7 +211,6 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)
|
|||||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6);
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6);
|
||||||
|
|
||||||
/* CAN2 interrupt Deinit */
|
/* CAN2 interrupt Deinit */
|
||||||
HAL_NVIC_DisableIRQ(CAN2_TX_IRQn);
|
|
||||||
HAL_NVIC_DisableIRQ(CAN2_RX0_IRQn);
|
HAL_NVIC_DisableIRQ(CAN2_RX0_IRQn);
|
||||||
HAL_NVIC_DisableIRQ(CAN2_RX1_IRQn);
|
HAL_NVIC_DisableIRQ(CAN2_RX1_IRQn);
|
||||||
/* USER CODE BEGIN CAN2_MspDeInit 1 */
|
/* USER CODE BEGIN CAN2_MspDeInit 1 */
|
||||||
|
|||||||
@ -269,20 +269,6 @@ void DMA1_Stream2_IRQHandler(void)
|
|||||||
/* USER CODE END DMA1_Stream2_IRQn 1 */
|
/* USER CODE END DMA1_Stream2_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles CAN1 TX interrupts.
|
|
||||||
*/
|
|
||||||
void CAN1_TX_IRQHandler(void)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN CAN1_TX_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END CAN1_TX_IRQn 0 */
|
|
||||||
HAL_CAN_IRQHandler(&hcan1);
|
|
||||||
/* USER CODE BEGIN CAN1_TX_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END CAN1_TX_IRQn 1 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles CAN1 RX0 interrupts.
|
* @brief This function handles CAN1 RX0 interrupts.
|
||||||
*/
|
*/
|
||||||
@ -424,20 +410,6 @@ void DMA2_Stream3_IRQHandler(void)
|
|||||||
/* USER CODE END DMA2_Stream3_IRQn 1 */
|
/* USER CODE END DMA2_Stream3_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles CAN2 TX interrupts.
|
|
||||||
*/
|
|
||||||
void CAN2_TX_IRQHandler(void)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN CAN2_TX_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END CAN2_TX_IRQn 0 */
|
|
||||||
HAL_CAN_IRQHandler(&hcan2);
|
|
||||||
/* USER CODE BEGIN CAN2_TX_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END CAN2_TX_IRQn 1 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles CAN2 RX0 interrupts.
|
* @brief This function handles CAN2 RX0 interrupts.
|
||||||
*/
|
*/
|
||||||
|
|||||||
4
DevC.ioc
4
DevC.ioc
@ -267,10 +267,8 @@ MxDb.Version=DB.6.0.20
|
|||||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||||
NVIC.CAN1_RX0_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true\:true
|
NVIC.CAN1_RX0_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.CAN1_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.CAN1_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.CAN1_TX_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
|
||||||
NVIC.CAN2_RX0_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true\:true
|
NVIC.CAN2_RX0_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.CAN2_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.CAN2_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.CAN2_TX_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
|
||||||
NVIC.DMA1_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:false\:true\:true
|
NVIC.DMA1_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:false\:true\:true
|
||||||
NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||||
NVIC.DMA1_Stream7_IRQn=true\:5\:0\:true\:false\:true\:true\:false\:true\:true
|
NVIC.DMA1_Stream7_IRQn=true\:5\:0\:true\:false\:true\:true\:false\:true\:true
|
||||||
@ -554,7 +552,7 @@ ProjectManager.ProjectName=DevC
|
|||||||
ProjectManager.ProjectStructure=
|
ProjectManager.ProjectStructure=
|
||||||
ProjectManager.RegisterCallBack=
|
ProjectManager.RegisterCallBack=
|
||||||
ProjectManager.StackSize=0x1000
|
ProjectManager.StackSize=0x1000
|
||||||
ProjectManager.TargetToolchain=CMake
|
ProjectManager.TargetToolchain=MDK-ARM V5.32
|
||||||
ProjectManager.ToolChainLocation=
|
ProjectManager.ToolChainLocation=
|
||||||
ProjectManager.UAScriptAfterPath=
|
ProjectManager.UAScriptAfterPath=
|
||||||
ProjectManager.UAScriptBeforePath=
|
ProjectManager.UAScriptBeforePath=
|
||||||
|
|||||||
@ -1245,8 +1245,8 @@ typedef struct
|
|||||||
*/
|
*/
|
||||||
/* Initialization and de-initialization functions ******************************/
|
/* Initialization and de-initialization functions ******************************/
|
||||||
HAL_StatusTypeDef HAL_RCC_DeInit(void);
|
HAL_StatusTypeDef HAL_RCC_DeInit(void);
|
||||||
HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
|
HAL_StatusTypeDef HAL_RCC_OscConfig(const RCC_OscInitTypeDef *RCC_OscInitStruct);
|
||||||
HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
|
HAL_StatusTypeDef HAL_RCC_ClockConfig(const RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -218,7 +218,7 @@ __weak HAL_StatusTypeDef HAL_RCC_DeInit(void)
|
|||||||
* first and then HSE On or HSE Bypass.
|
* first and then HSE On or HSE Bypass.
|
||||||
* @retval HAL status
|
* @retval HAL status
|
||||||
*/
|
*/
|
||||||
__weak HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct)
|
__weak HAL_StatusTypeDef HAL_RCC_OscConfig(const RCC_OscInitTypeDef *RCC_OscInitStruct)
|
||||||
{
|
{
|
||||||
uint32_t tickstart, pll_config;
|
uint32_t tickstart, pll_config;
|
||||||
|
|
||||||
@ -590,7 +590,7 @@ __weak HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruc
|
|||||||
* (for more details refer to section above "Initialization/de-initialization functions")
|
* (for more details refer to section above "Initialization/de-initialization functions")
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency)
|
HAL_StatusTypeDef HAL_RCC_ClockConfig(const RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency)
|
||||||
{
|
{
|
||||||
uint32_t tickstart;
|
uint32_t tickstart;
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
|
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
|
||||||
|
|
||||||
<SchemaVersion>1.0</SchemaVersion>
|
<SchemaVersion>1.0</SchemaVersion>
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<PageWidth>79</PageWidth>
|
<PageWidth>79</PageWidth>
|
||||||
<PageLength>66</PageLength>
|
<PageLength>66</PageLength>
|
||||||
<TabStop>8</TabStop>
|
<TabStop>8</TabStop>
|
||||||
<ListingPath />
|
<ListingPath></ListingPath>
|
||||||
</OPTLEX>
|
</OPTLEX>
|
||||||
<ListingPage>
|
<ListingPage>
|
||||||
<CreateCListing>1</CreateCListing>
|
<CreateCListing>1</CreateCListing>
|
||||||
@ -104,16 +104,16 @@
|
|||||||
<bSchkAxf>0</bSchkAxf>
|
<bSchkAxf>0</bSchkAxf>
|
||||||
<bTchkAxf>0</bTchkAxf>
|
<bTchkAxf>0</bTchkAxf>
|
||||||
<nTsel>3</nTsel>
|
<nTsel>3</nTsel>
|
||||||
<sDll />
|
<sDll></sDll>
|
||||||
<sDllPa />
|
<sDllPa></sDllPa>
|
||||||
<sDlgDll />
|
<sDlgDll></sDlgDll>
|
||||||
<sDlgPa />
|
<sDlgPa></sDlgPa>
|
||||||
<sIfile />
|
<sIfile></sIfile>
|
||||||
<tDll />
|
<tDll></tDll>
|
||||||
<tDllPa />
|
<tDllPa></tDllPa>
|
||||||
<tDlgDll />
|
<tDlgDll></tDlgDll>
|
||||||
<tDlgPa />
|
<tDlgPa></tDlgPa>
|
||||||
<tIfile />
|
<tIfile></tIfile>
|
||||||
<pMon>BIN\CMSIS_AGDI.dll</pMon>
|
<pMon>BIN\CMSIS_AGDI.dll</pMon>
|
||||||
</DebugOpt>
|
</DebugOpt>
|
||||||
<TargetDriverDllRegistry>
|
<TargetDriverDllRegistry>
|
||||||
@ -153,19 +153,19 @@
|
|||||||
<newCpu>0</newCpu>
|
<newCpu>0</newCpu>
|
||||||
<uProt>0</uProt>
|
<uProt>0</uProt>
|
||||||
</DebugFlag>
|
</DebugFlag>
|
||||||
<LintExecutable />
|
<LintExecutable></LintExecutable>
|
||||||
<LintConfigFile />
|
<LintConfigFile></LintConfigFile>
|
||||||
<bLintAuto>0</bLintAuto>
|
<bLintAuto>0</bLintAuto>
|
||||||
<bAutoGenD>0</bAutoGenD>
|
<bAutoGenD>0</bAutoGenD>
|
||||||
<LntExFlags>0</LntExFlags>
|
<LntExFlags>0</LntExFlags>
|
||||||
<pMisraName />
|
<pMisraName></pMisraName>
|
||||||
<pszMrule />
|
<pszMrule></pszMrule>
|
||||||
<pSingCmds />
|
<pSingCmds></pSingCmds>
|
||||||
<pMultCmds />
|
<pMultCmds></pMultCmds>
|
||||||
<pMisraNamep />
|
<pMisraNamep></pMisraNamep>
|
||||||
<pszMrulep />
|
<pszMrulep></pszMrulep>
|
||||||
<pSingCmdsp />
|
<pSingCmdsp></pSingCmdsp>
|
||||||
<pMultCmdsp />
|
<pMultCmdsp></pMultCmdsp>
|
||||||
<DebugDescription>
|
<DebugDescription>
|
||||||
<Enable>1</Enable>
|
<Enable>1</Enable>
|
||||||
<EnableFlashSeq>1</EnableFlashSeq>
|
<EnableFlashSeq>1</EnableFlashSeq>
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="project_projx.xsd">
|
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||||
|
|
||||||
<SchemaVersion>2.1</SchemaVersion>
|
<SchemaVersion>2.1</SchemaVersion>
|
||||||
|
|
||||||
<Header>### uVision Project, (C) Keil Software</Header>
|
<Header>### uVision Project, (C) Keil Software</Header>
|
||||||
|
|
||||||
<Targets>
|
<Targets>
|
||||||
<Target>
|
<Target>
|
||||||
<TargetName>DevC</TargetName>
|
<TargetName>DevC</TargetName>
|
||||||
@ -17,28 +20,28 @@
|
|||||||
<PackID>Keil.STM32F4xx_DFP.3.0.0</PackID>
|
<PackID>Keil.STM32F4xx_DFP.3.0.0</PackID>
|
||||||
<PackURL>https://www.keil.com/pack/</PackURL>
|
<PackURL>https://www.keil.com/pack/</PackURL>
|
||||||
<Cpu>IRAM(0x20000000-0x2001BFFF) IRAM2(0x2001C000-0x2001FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4") TZ</Cpu>
|
<Cpu>IRAM(0x20000000-0x2001BFFF) IRAM2(0x2001C000-0x2001FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4") TZ</Cpu>
|
||||||
<FlashUtilSpec />
|
<FlashUtilSpec></FlashUtilSpec>
|
||||||
<StartupFile />
|
<StartupFile></StartupFile>
|
||||||
<FlashDriverDll />
|
<FlashDriverDll></FlashDriverDll>
|
||||||
<DeviceId>0</DeviceId>
|
<DeviceId>0</DeviceId>
|
||||||
<RegisterFile />
|
<RegisterFile></RegisterFile>
|
||||||
<MemoryEnv />
|
<MemoryEnv></MemoryEnv>
|
||||||
<Cmp />
|
<Cmp></Cmp>
|
||||||
<Asm />
|
<Asm></Asm>
|
||||||
<Linker />
|
<Linker></Linker>
|
||||||
<OHString />
|
<OHString></OHString>
|
||||||
<InfinionOptionDll />
|
<InfinionOptionDll></InfinionOptionDll>
|
||||||
<SLE66CMisc />
|
<SLE66CMisc></SLE66CMisc>
|
||||||
<SLE66AMisc />
|
<SLE66AMisc></SLE66AMisc>
|
||||||
<SLE66LinkerMisc />
|
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||||
<SFDFile>$$Device:STM32F407IGHx$CMSIS\SVD\STM32F407.svd</SFDFile>
|
<SFDFile>$$Device:STM32F407IGHx$CMSIS\SVD\STM32F407.svd</SFDFile>
|
||||||
<bCustSvd>0</bCustSvd>
|
<bCustSvd>0</bCustSvd>
|
||||||
<UseEnv>0</UseEnv>
|
<UseEnv>0</UseEnv>
|
||||||
<BinPath />
|
<BinPath></BinPath>
|
||||||
<IncludePath />
|
<IncludePath></IncludePath>
|
||||||
<LibPath />
|
<LibPath></LibPath>
|
||||||
<RegisterFilePath />
|
<RegisterFilePath></RegisterFilePath>
|
||||||
<DBRegisterFilePath />
|
<DBRegisterFilePath></DBRegisterFilePath>
|
||||||
<TargetStatus>
|
<TargetStatus>
|
||||||
<Error>0</Error>
|
<Error>0</Error>
|
||||||
<ExitCodeStop>0</ExitCodeStop>
|
<ExitCodeStop>0</ExitCodeStop>
|
||||||
@ -53,15 +56,15 @@
|
|||||||
<CreateHexFile>1</CreateHexFile>
|
<CreateHexFile>1</CreateHexFile>
|
||||||
<DebugInformation>1</DebugInformation>
|
<DebugInformation>1</DebugInformation>
|
||||||
<BrowseInformation>1</BrowseInformation>
|
<BrowseInformation>1</BrowseInformation>
|
||||||
<ListingPath />
|
<ListingPath></ListingPath>
|
||||||
<HexFormatSelection>1</HexFormatSelection>
|
<HexFormatSelection>1</HexFormatSelection>
|
||||||
<Merge32K>0</Merge32K>
|
<Merge32K>0</Merge32K>
|
||||||
<CreateBatchFile>0</CreateBatchFile>
|
<CreateBatchFile>0</CreateBatchFile>
|
||||||
<BeforeCompile>
|
<BeforeCompile>
|
||||||
<RunUserProg1>0</RunUserProg1>
|
<RunUserProg1>0</RunUserProg1>
|
||||||
<RunUserProg2>0</RunUserProg2>
|
<RunUserProg2>0</RunUserProg2>
|
||||||
<UserProg1Name />
|
<UserProg1Name></UserProg1Name>
|
||||||
<UserProg2Name />
|
<UserProg2Name></UserProg2Name>
|
||||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||||
<nStopU1X>0</nStopU1X>
|
<nStopU1X>0</nStopU1X>
|
||||||
@ -70,8 +73,8 @@
|
|||||||
<BeforeMake>
|
<BeforeMake>
|
||||||
<RunUserProg1>0</RunUserProg1>
|
<RunUserProg1>0</RunUserProg1>
|
||||||
<RunUserProg2>0</RunUserProg2>
|
<RunUserProg2>0</RunUserProg2>
|
||||||
<UserProg1Name />
|
<UserProg1Name></UserProg1Name>
|
||||||
<UserProg2Name />
|
<UserProg2Name></UserProg2Name>
|
||||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||||
<nStopB1X>0</nStopB1X>
|
<nStopB1X>0</nStopB1X>
|
||||||
@ -80,15 +83,15 @@
|
|||||||
<AfterMake>
|
<AfterMake>
|
||||||
<RunUserProg1>0</RunUserProg1>
|
<RunUserProg1>0</RunUserProg1>
|
||||||
<RunUserProg2>1</RunUserProg2>
|
<RunUserProg2>1</RunUserProg2>
|
||||||
<UserProg1Name />
|
<UserProg1Name></UserProg1Name>
|
||||||
<UserProg2Name />
|
<UserProg2Name></UserProg2Name>
|
||||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||||
<nStopA1X>0</nStopA1X>
|
<nStopA1X>0</nStopA1X>
|
||||||
<nStopA2X>0</nStopA2X>
|
<nStopA2X>0</nStopA2X>
|
||||||
</AfterMake>
|
</AfterMake>
|
||||||
<SelectedForBatchBuild>1</SelectedForBatchBuild>
|
<SelectedForBatchBuild>1</SelectedForBatchBuild>
|
||||||
<SVCSIdString />
|
<SVCSIdString></SVCSIdString>
|
||||||
</TargetCommonOption>
|
</TargetCommonOption>
|
||||||
<CommonProperty>
|
<CommonProperty>
|
||||||
<UseCPPCompiler>0</UseCPPCompiler>
|
<UseCPPCompiler>0</UseCPPCompiler>
|
||||||
@ -102,8 +105,8 @@
|
|||||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||||
<PublicsOnly>0</PublicsOnly>
|
<PublicsOnly>0</PublicsOnly>
|
||||||
<StopOnExitCode>3</StopOnExitCode>
|
<StopOnExitCode>3</StopOnExitCode>
|
||||||
<CustomArgument />
|
<CustomArgument></CustomArgument>
|
||||||
<IncludeLibraryModules />
|
<IncludeLibraryModules></IncludeLibraryModules>
|
||||||
<ComprImg>0</ComprImg>
|
<ComprImg>0</ComprImg>
|
||||||
</CommonProperty>
|
</CommonProperty>
|
||||||
<DllOption>
|
<DllOption>
|
||||||
@ -137,10 +140,10 @@
|
|||||||
<bUseTDR>1</bUseTDR>
|
<bUseTDR>1</bUseTDR>
|
||||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||||
<Flash3>"" ()</Flash3>
|
<Flash3>"" ()</Flash3>
|
||||||
<Flash4 />
|
<Flash4></Flash4>
|
||||||
<pFcarmOut />
|
<pFcarmOut></pFcarmOut>
|
||||||
<pFcarmGrp />
|
<pFcarmGrp></pFcarmGrp>
|
||||||
<pFcArmRoot />
|
<pFcArmRoot></pFcArmRoot>
|
||||||
<FcArmLst>0</FcArmLst>
|
<FcArmLst>0</FcArmLst>
|
||||||
</Utilities>
|
</Utilities>
|
||||||
<TargetArmAds>
|
<TargetArmAds>
|
||||||
@ -173,7 +176,7 @@
|
|||||||
<RvctClst>0</RvctClst>
|
<RvctClst>0</RvctClst>
|
||||||
<GenPPlst>0</GenPPlst>
|
<GenPPlst>0</GenPPlst>
|
||||||
<AdsCpuType>"Cortex-M4"</AdsCpuType>
|
<AdsCpuType>"Cortex-M4"</AdsCpuType>
|
||||||
<RvctDeviceName />
|
<RvctDeviceName></RvctDeviceName>
|
||||||
<mOS>0</mOS>
|
<mOS>0</mOS>
|
||||||
<uocRom>0</uocRom>
|
<uocRom>0</uocRom>
|
||||||
<uocRam>0</uocRam>
|
<uocRam>0</uocRam>
|
||||||
@ -307,7 +310,7 @@
|
|||||||
<Size>0x4000</Size>
|
<Size>0x4000</Size>
|
||||||
</OCR_RVCT10>
|
</OCR_RVCT10>
|
||||||
</OnChipMemories>
|
</OnChipMemories>
|
||||||
<RvctStartVector />
|
<RvctStartVector></RvctStartVector>
|
||||||
</ArmAdsMisc>
|
</ArmAdsMisc>
|
||||||
<Cads>
|
<Cads>
|
||||||
<interw>1</interw>
|
<interw>1</interw>
|
||||||
@ -334,9 +337,9 @@
|
|||||||
<v6WtE>0</v6WtE>
|
<v6WtE>0</v6WtE>
|
||||||
<v6Rtti>0</v6Rtti>
|
<v6Rtti>0</v6Rtti>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls />
|
<MiscControls></MiscControls>
|
||||||
<Define>USE_HAL_DRIVER,STM32F407xx</Define>
|
<Define>USE_HAL_DRIVER,STM32F407xx</Define>
|
||||||
<Undefine />
|
<Undefine></Undefine>
|
||||||
<IncludePath>../Core/Inc;../USB_DEVICE/App;../USB_DEVICE/Target;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2;../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F;../Middlewares/ST/STM32_USB_Device_Library/Core/Inc;../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Drivers/CMSIS/Include;../User</IncludePath>
|
<IncludePath>../Core/Inc;../USB_DEVICE/App;../USB_DEVICE/Target;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2;../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F;../Middlewares/ST/STM32_USB_Device_Library/Core/Inc;../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Drivers/CMSIS/Include;../User</IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
</Cads>
|
</Cads>
|
||||||
@ -352,9 +355,9 @@
|
|||||||
<useXO>0</useXO>
|
<useXO>0</useXO>
|
||||||
<ClangAsOpt>1</ClangAsOpt>
|
<ClangAsOpt>1</ClangAsOpt>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls />
|
<MiscControls></MiscControls>
|
||||||
<Define />
|
<Define></Define>
|
||||||
<Undefine />
|
<Undefine></Undefine>
|
||||||
<IncludePath>../Core/Inc;../USB_DEVICE/App;../USB_DEVICE/Target;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2;../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F;../Middlewares/ST/STM32_USB_Device_Library/Core/Inc;../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Drivers/CMSIS/Include</IncludePath>
|
<IncludePath>../Core/Inc;../USB_DEVICE/App;../USB_DEVICE/Target;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2;../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F;../Middlewares/ST/STM32_USB_Device_Library/Core/Inc;../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Drivers/CMSIS/Include</IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
</Aads>
|
</Aads>
|
||||||
@ -365,15 +368,15 @@
|
|||||||
<noStLib>0</noStLib>
|
<noStLib>0</noStLib>
|
||||||
<RepFail>1</RepFail>
|
<RepFail>1</RepFail>
|
||||||
<useFile>0</useFile>
|
<useFile>0</useFile>
|
||||||
<TextAddressRange />
|
<TextAddressRange></TextAddressRange>
|
||||||
<DataAddressRange />
|
<DataAddressRange></DataAddressRange>
|
||||||
<pXoBase />
|
<pXoBase></pXoBase>
|
||||||
<ScatterFile />
|
<ScatterFile></ScatterFile>
|
||||||
<IncludeLibs />
|
<IncludeLibs></IncludeLibs>
|
||||||
<IncludeLibsPath />
|
<IncludeLibsPath></IncludeLibsPath>
|
||||||
<Misc />
|
<Misc></Misc>
|
||||||
<LinkerInputFile />
|
<LinkerInputFile></LinkerInputFile>
|
||||||
<DisabledWarnings />
|
<DisabledWarnings></DisabledWarnings>
|
||||||
</LDads>
|
</LDads>
|
||||||
</TargetArmAds>
|
</TargetArmAds>
|
||||||
</TargetOption>
|
</TargetOption>
|
||||||
@ -919,6 +922,7 @@
|
|||||||
</Groups>
|
</Groups>
|
||||||
</Target>
|
</Target>
|
||||||
</Targets>
|
</Targets>
|
||||||
|
|
||||||
<RTE>
|
<RTE>
|
||||||
<apis/>
|
<apis/>
|
||||||
<components>
|
<components>
|
||||||
@ -931,6 +935,7 @@
|
|||||||
</components>
|
</components>
|
||||||
<files/>
|
<files/>
|
||||||
</RTE>
|
</RTE>
|
||||||
|
|
||||||
<LayerInfo>
|
<LayerInfo>
|
||||||
<Layers>
|
<Layers>
|
||||||
<Layer>
|
<Layer>
|
||||||
@ -939,5 +944,5 @@
|
|||||||
</Layer>
|
</Layer>
|
||||||
</Layers>
|
</Layers>
|
||||||
</LayerInfo>
|
</LayerInfo>
|
||||||
</Project>
|
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|||||||
@ -43,7 +43,7 @@ typedef struct {
|
|||||||
/* Exported functions prototypes -------------------------------------------- */
|
/* Exported functions prototypes -------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 注册一个DM电机
|
* @brief 注册一个LK电机
|
||||||
* @param param 电机参数
|
* @param param 电机参数
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -62,31 +62,11 @@ int8_t MOTOR_DM_Update(MOTOR_DM_Param_t *param);
|
|||||||
*/
|
*/
|
||||||
int8_t MOTOR_DM_UpdateAll(void);
|
int8_t MOTOR_DM_UpdateAll(void);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief MIT模式控制电机
|
|
||||||
* @param param 电机参数
|
|
||||||
* @param output MIT控制输出参数
|
|
||||||
* @return 操作结果,0为成功,负值为失败
|
|
||||||
*/
|
|
||||||
int8_t MOTOR_DM_MITCtrl(MOTOR_DM_Param_t *param, MOTOR_MIT_Output_t *output);
|
int8_t MOTOR_DM_MITCtrl(MOTOR_DM_Param_t *param, MOTOR_MIT_Output_t *output);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 位置速度双环控制电机
|
|
||||||
* @param param 电机参数
|
|
||||||
* @param target_pos 目标位置
|
|
||||||
* @param target_vel 目标速度
|
|
||||||
* @return 操作结果,0为成功,负值为失败
|
|
||||||
*/
|
|
||||||
int8_t MOTOR_DM_PosVelCtrl(MOTOR_DM_Param_t *param, float target_pos, float target_vel);
|
int8_t MOTOR_DM_PosVelCtrl(MOTOR_DM_Param_t *param, float target_pos, float target_vel);
|
||||||
|
|
||||||
/**
|
int8_t MOTOR_DM_VelCtrl(MOTOR_DM_Param_t *param, float target_vel);
|
||||||
* @brief 位置速度双环控制电机
|
|
||||||
* @param param 电机参数
|
|
||||||
* @param target_pos 目标位置
|
|
||||||
* @param target_vel 目标速度
|
|
||||||
* @return 操作结果,0为成功,负值为失败
|
|
||||||
*/
|
|
||||||
int8_t MOTOR_DM_PosVelCtrl(MOTOR_DM_Param_t *param, float target_pos, float target_vel);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 获取指定电机的实例指针
|
* @brief 获取指定电机的实例指针
|
||||||
@ -95,11 +75,6 @@ int8_t MOTOR_DM_PosVelCtrl(MOTOR_DM_Param_t *param, float target_pos, float targ
|
|||||||
*/
|
*/
|
||||||
MOTOR_DM_t* MOTOR_DM_GetMotor(MOTOR_DM_Param_t *param);
|
MOTOR_DM_t* MOTOR_DM_GetMotor(MOTOR_DM_Param_t *param);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief 使能电机
|
|
||||||
* @param param 电机参数
|
|
||||||
* @return 操作结果,0为成功,负值为失败
|
|
||||||
*/
|
|
||||||
int8_t MOTOR_DM_Enable(MOTOR_DM_Param_t *param);
|
int8_t MOTOR_DM_Enable(MOTOR_DM_Param_t *param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -139,13 +139,13 @@ static void Motor_RM_Decode(MOTOR_RM_t *motor, BSP_CAN_Message_t *msg) {
|
|||||||
motor->feedback.rotor_speed = rotor_speed;
|
motor->feedback.rotor_speed = rotor_speed;
|
||||||
motor->feedback.torque_current = torque_current;
|
motor->feedback.torque_current = torque_current;
|
||||||
}
|
}
|
||||||
|
if (motor->motor.reverse) {
|
||||||
while (motor->feedback.rotor_abs_angle < 0) {
|
while (motor->feedback.rotor_abs_angle < 0) {
|
||||||
motor->feedback.rotor_abs_angle += M_2PI;
|
motor->feedback.rotor_abs_angle += M_2PI;
|
||||||
}
|
}
|
||||||
while (motor->feedback.rotor_abs_angle >= M_2PI) {
|
while (motor->feedback.rotor_abs_angle >= M_2PI) {
|
||||||
motor->feedback.rotor_abs_angle -= M_2PI;
|
motor->feedback.rotor_abs_angle -= M_2PI;
|
||||||
}
|
}
|
||||||
if (motor->motor.reverse) {
|
|
||||||
motor->feedback.rotor_abs_angle = M_2PI - motor->feedback.rotor_abs_angle;
|
motor->feedback.rotor_abs_angle = M_2PI - motor->feedback.rotor_abs_angle;
|
||||||
motor->feedback.rotor_speed = -motor->feedback.rotor_speed;
|
motor->feedback.rotor_speed = -motor->feedback.rotor_speed;
|
||||||
motor->feedback.torque_current = -motor->feedback.torque_current;
|
motor->feedback.torque_current = -motor->feedback.torque_current;
|
||||||
|
|||||||
@ -93,60 +93,46 @@ int8_t RC_CAN_SendData(RC_CAN_t *rc_can, RC_CAN_DataType_t data_type) {
|
|||||||
}
|
}
|
||||||
BSP_CAN_StdDataFrame_t frame;
|
BSP_CAN_StdDataFrame_t frame;
|
||||||
frame.dlc = 8;
|
frame.dlc = 8;
|
||||||
// 边界裁剪宏
|
|
||||||
#define RC_CAN_CLAMP(x, min, max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
|
|
||||||
switch (data_type) {
|
switch (data_type) {
|
||||||
case RC_CAN_DATA_JOYSTICK: {
|
case RC_CAN_DATA_JOYSTICK:
|
||||||
frame.id = rc_can->param.joy_id;
|
frame.id = rc_can->param.joy_id;
|
||||||
float l_x = RC_CAN_CLAMP(rc_can->data.joy.ch_l_x, -0.999969f, 0.999969f);
|
frame.data[0] = (uint8_t)((int16_t)(rc_can->data.joy.ch_l_x * 32768.0f) & 0xFF);
|
||||||
float l_y = RC_CAN_CLAMP(rc_can->data.joy.ch_l_y, -0.999969f, 0.999969f);
|
frame.data[1] =
|
||||||
float r_x = RC_CAN_CLAMP(rc_can->data.joy.ch_r_x, -0.999969f, 0.999969f);
|
(uint8_t)(((int16_t)(rc_can->data.joy.ch_l_x * 32768.0f) >> 8) & 0xFF);
|
||||||
float r_y = RC_CAN_CLAMP(rc_can->data.joy.ch_r_y, -0.999969f, 0.999969f);
|
frame.data[2] = (uint8_t)((int16_t)(rc_can->data.joy.ch_l_y * 32768.0f) & 0xFF);
|
||||||
int16_t l_x_i = (int16_t)(l_x * 32768.0f);
|
frame.data[3] =
|
||||||
int16_t l_y_i = (int16_t)(l_y * 32768.0f);
|
(uint8_t)(((int16_t)(rc_can->data.joy.ch_l_y * 32768.0f) >> 8) & 0xFF);
|
||||||
int16_t r_x_i = (int16_t)(r_x * 32768.0f);
|
frame.data[4] = (uint8_t)((int16_t)(rc_can->data.joy.ch_r_x * 32768.0f) & 0xFF);
|
||||||
int16_t r_y_i = (int16_t)(r_y * 32768.0f);
|
frame.data[5] =
|
||||||
frame.data[0] = (uint8_t)(l_x_i & 0xFF);
|
(uint8_t)(((int16_t)(rc_can->data.joy.ch_r_x * 32768.0f) >> 8) & 0xFF);
|
||||||
frame.data[1] = (uint8_t)((l_x_i >> 8) & 0xFF);
|
frame.data[6] = (uint8_t)((int16_t)(rc_can->data.joy.ch_r_y * 32768.0f) & 0xFF);
|
||||||
frame.data[2] = (uint8_t)(l_y_i & 0xFF);
|
frame.data[7] =
|
||||||
frame.data[3] = (uint8_t)((l_y_i >> 8) & 0xFF);
|
(uint8_t)(((int16_t)(rc_can->data.joy.ch_r_y * 32768.0f) >> 8) & 0xFF);
|
||||||
frame.data[4] = (uint8_t)(r_x_i & 0xFF);
|
|
||||||
frame.data[5] = (uint8_t)((r_x_i >> 8) & 0xFF);
|
|
||||||
frame.data[6] = (uint8_t)(r_y_i & 0xFF);
|
|
||||||
frame.data[7] = (uint8_t)((r_y_i >> 8) & 0xFF);
|
|
||||||
break;
|
break;
|
||||||
}
|
case RC_CAN_DATA_SWITCH:
|
||||||
case RC_CAN_DATA_SWITCH: {
|
|
||||||
frame.id = rc_can->param.sw_id;
|
frame.id = rc_can->param.sw_id;
|
||||||
frame.data[0] = (uint8_t)(rc_can->data.sw.sw_l);
|
frame.data[0] = (uint8_t)(rc_can->data.sw.sw_l);
|
||||||
frame.data[1] = (uint8_t)(rc_can->data.sw.sw_r);
|
frame.data[1] = (uint8_t)(rc_can->data.sw.sw_r);
|
||||||
float ch_res = RC_CAN_CLAMP(rc_can->data.sw.ch_res, -0.999969f, 0.999969f);
|
frame.data[2] = (uint8_t)((int16_t)(rc_can->data.sw.ch_res * 32768.0f) & 0xFF);
|
||||||
int16_t ch_res_i = (int16_t)(ch_res * 32768.0f);
|
frame.data[3] =
|
||||||
frame.data[2] = (uint8_t)(ch_res_i & 0xFF);
|
(uint8_t)(((int16_t)(rc_can->data.sw.ch_res * 32768.0f) >> 8) & 0xFF);
|
||||||
frame.data[3] = (uint8_t)((ch_res_i >> 8) & 0xFF);
|
|
||||||
frame.data[4] = 0; // 保留字节
|
frame.data[4] = 0; // 保留字节
|
||||||
frame.data[5] = 0; // 保留字节
|
frame.data[5] = 0; // 保留字节
|
||||||
frame.data[6] = 0; // 保留字节
|
frame.data[6] = 0; // 保留字节
|
||||||
frame.data[7] = 0; // 保留字节
|
frame.data[7] = 0; // 保留字节
|
||||||
break;
|
break;
|
||||||
}
|
case RC_CAN_DATA_MOUSE:
|
||||||
case RC_CAN_DATA_MOUSE: {
|
|
||||||
frame.id = rc_can->param.mouse_id;
|
frame.id = rc_can->param.mouse_id;
|
||||||
// 鼠标x/y/z一般为增量,若有极限也可加clamp
|
frame.data[0] = (uint8_t)((int16_t)(rc_can->data.mouse.x) & 0xFF);
|
||||||
int16_t x = (int16_t)(rc_can->data.mouse.x);
|
frame.data[1] = (uint8_t)(((int16_t)(rc_can->data.mouse.x) >> 8) & 0xFF);
|
||||||
int16_t y = (int16_t)(rc_can->data.mouse.y);
|
frame.data[2] = (uint8_t)((int16_t)(rc_can->data.mouse.y) & 0xFF);
|
||||||
int16_t z = (int16_t)(rc_can->data.mouse.z);
|
frame.data[3] = (uint8_t)(((int16_t)(rc_can->data.mouse.y) >> 8) & 0xFF);
|
||||||
frame.data[0] = (uint8_t)(x & 0xFF);
|
frame.data[4] = (uint8_t)((int16_t)(rc_can->data.mouse.z) & 0xFF);
|
||||||
frame.data[1] = (uint8_t)((x >> 8) & 0xFF);
|
frame.data[5] = (uint8_t)(((int16_t)(rc_can->data.mouse.z) >> 8) & 0xFF);
|
||||||
frame.data[2] = (uint8_t)(y & 0xFF);
|
|
||||||
frame.data[3] = (uint8_t)((y >> 8) & 0xFF);
|
|
||||||
frame.data[4] = (uint8_t)(z & 0xFF);
|
|
||||||
frame.data[5] = (uint8_t)((z >> 8) & 0xFF);
|
|
||||||
frame.data[6] = (uint8_t)(rc_can->data.mouse.mouse_l ? 1 : 0);
|
frame.data[6] = (uint8_t)(rc_can->data.mouse.mouse_l ? 1 : 0);
|
||||||
frame.data[7] = (uint8_t)(rc_can->data.mouse.mouse_r ? 1 : 0);
|
frame.data[7] = (uint8_t)(rc_can->data.mouse.mouse_r ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
case RC_CAN_DATA_KEYBOARD:
|
||||||
case RC_CAN_DATA_KEYBOARD: {
|
|
||||||
frame.id = rc_can->param.keyboard_id;
|
frame.id = rc_can->param.keyboard_id;
|
||||||
frame.data[0] = (uint8_t)(rc_can->data.keyboard.key_value & 0xFF);
|
frame.data[0] = (uint8_t)(rc_can->data.keyboard.key_value & 0xFF);
|
||||||
frame.data[1] = (uint8_t)((rc_can->data.keyboard.key_value >> 8) & 0xFF);
|
frame.data[1] = (uint8_t)((rc_can->data.keyboard.key_value >> 8) & 0xFF);
|
||||||
@ -154,11 +140,9 @@ int8_t RC_CAN_SendData(RC_CAN_t *rc_can, RC_CAN_DataType_t data_type) {
|
|||||||
frame.data[2 + i] = (i < 6) ? (uint8_t)(rc_can->data.keyboard.keys[i]) : 0;
|
frame.data[2 + i] = (i < 6) ? (uint8_t)(rc_can->data.keyboard.keys[i]) : 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return DEVICE_ERR;
|
return DEVICE_ERR;
|
||||||
}
|
}
|
||||||
#undef RC_CAN_CLAMP
|
|
||||||
if (BSP_CAN_Transmit(rc_can->param.can, BSP_CAN_FORMAT_STD_DATA, frame.id,
|
if (BSP_CAN_Transmit(rc_can->param.can, BSP_CAN_FORMAT_STD_DATA, frame.id,
|
||||||
frame.data, frame.dlc) != BSP_OK) {
|
frame.data, frame.dlc) != BSP_OK) {
|
||||||
return DEVICE_ERR;
|
return DEVICE_ERR;
|
||||||
|
|||||||
@ -23,8 +23,6 @@
|
|||||||
Config_RobotParam_t robot_config = {
|
Config_RobotParam_t robot_config = {
|
||||||
.shoot_param = {
|
.shoot_param = {
|
||||||
.trig_step_angle=M_2PI/8,
|
.trig_step_angle=M_2PI/8,
|
||||||
.shot_delay_time=0.05f,
|
|
||||||
.shot_burst_num=1,
|
|
||||||
.fric_motor_param[0] = {
|
.fric_motor_param[0] = {
|
||||||
.can = BSP_CAN_2,
|
.can = BSP_CAN_2,
|
||||||
.id = 0x201,
|
.id = 0x201,
|
||||||
@ -43,7 +41,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
.can = BSP_CAN_1,
|
.can = BSP_CAN_1,
|
||||||
.id = 0x201,
|
.id = 0x201,
|
||||||
.module = MOTOR_M2006,
|
.module = MOTOR_M2006,
|
||||||
.reverse = true,
|
.reverse = false,
|
||||||
.gear=true,
|
.gear=true,
|
||||||
},
|
},
|
||||||
.fric_follow = {
|
.fric_follow = {
|
||||||
@ -56,7 +54,6 @@ Config_RobotParam_t robot_config = {
|
|||||||
.d_cutoff_freq=30.0f,
|
.d_cutoff_freq=30.0f,
|
||||||
.range=-1.0f,
|
.range=-1.0f,
|
||||||
},
|
},
|
||||||
|
|
||||||
.fric_err = {
|
.fric_err = {
|
||||||
.k=1.0f,
|
.k=1.0f,
|
||||||
.p=4.0f,
|
.p=4.0f,
|
||||||
@ -67,25 +64,15 @@ Config_RobotParam_t robot_config = {
|
|||||||
.d_cutoff_freq=40.0f,
|
.d_cutoff_freq=40.0f,
|
||||||
.range=-1.0f,
|
.range=-1.0f,
|
||||||
},
|
},
|
||||||
.trig_omg = {
|
|
||||||
.k=1.0f,
|
|
||||||
.p=1.5f,
|
|
||||||
.i=0.3f,
|
|
||||||
.d=0.5f,
|
|
||||||
.i_limit=0.2f,
|
|
||||||
.out_limit=0.9f,
|
|
||||||
.d_cutoff_freq=-1.0f,
|
|
||||||
.range=-1.0f,
|
|
||||||
},
|
|
||||||
.trig = {
|
.trig = {
|
||||||
.k=1.0f,
|
.k=1.0f,
|
||||||
.p=1.0f,
|
.p=1.2f,
|
||||||
.i=0.1f,
|
.i=0.0f,
|
||||||
.d=0.05f,
|
.d=0.05f,
|
||||||
.i_limit=0.8f,
|
.i_limit=0.2f,
|
||||||
.out_limit=0.5f,
|
.out_limit=0.9f,
|
||||||
.d_cutoff_freq=-1.0f,
|
.d_cutoff_freq=30.0f,
|
||||||
.range=M_2PI,
|
.range=-1.0f,
|
||||||
},
|
},
|
||||||
.filter.fric = {
|
.filter.fric = {
|
||||||
.in = 30.0f,
|
.in = 30.0f,
|
||||||
@ -101,7 +88,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
.gimbal_param = {
|
.gimbal_param = {
|
||||||
.pid = {
|
.pid = {
|
||||||
.yaw_omega = {
|
.yaw_omega = {
|
||||||
.k = 1.0f,
|
.k = 0.5f,
|
||||||
.p = 1.0f,
|
.p = 1.0f,
|
||||||
.i = 0.5f,
|
.i = 0.5f,
|
||||||
.d = 0.0f,
|
.d = 0.0f,
|
||||||
@ -114,7 +101,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
.k = 10.0f,
|
.k = 10.0f,
|
||||||
.p = 3.0f,
|
.p = 3.0f,
|
||||||
.i = 0.0f,
|
.i = 0.0f,
|
||||||
.d = 0.0f,
|
.d = 0.1f,
|
||||||
.i_limit = 0.0f,
|
.i_limit = 0.0f,
|
||||||
.out_limit = 10.0f,
|
.out_limit = 10.0f,
|
||||||
.d_cutoff_freq = -1.0f,
|
.d_cutoff_freq = -1.0f,
|
||||||
@ -143,7 +130,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
},
|
},
|
||||||
.mech_zero = {
|
.mech_zero = {
|
||||||
.yaw = 0.0f,
|
.yaw = 0.0f,
|
||||||
.pit = 1.77f,
|
.pit = 3.8f,
|
||||||
},
|
},
|
||||||
.travel = {
|
.travel = {
|
||||||
.yaw = -1.0f,
|
.yaw = -1.0f,
|
||||||
@ -155,7 +142,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
},
|
},
|
||||||
.pit_motor ={
|
.pit_motor ={
|
||||||
.can = BSP_CAN_2,
|
.can = BSP_CAN_2,
|
||||||
.id = 0x206,
|
.id = 0x209,
|
||||||
.gear = false,
|
.gear = false,
|
||||||
.module = MOTOR_GM6020,
|
.module = MOTOR_GM6020,
|
||||||
.reverse = true,
|
.reverse = true,
|
||||||
|
|||||||
@ -6,7 +6,6 @@
|
|||||||
#include "gimbal.h"
|
#include "gimbal.h"
|
||||||
#include "bsp/can.h"
|
#include "bsp/can.h"
|
||||||
#include "bsp/time.h"
|
#include "bsp/time.h"
|
||||||
#include <math.h>
|
|
||||||
#include "component/filter.h"
|
#include "component/filter.h"
|
||||||
#include "component/pid.h"
|
#include "component/pid.h"
|
||||||
#include "device/motor_dm.h"
|
#include "device/motor_dm.h"
|
||||||
@ -159,7 +158,7 @@ int8_t Gimbal_Control(Gimbal_t *g, Gimbal_CMD_t *g_cmd) {
|
|||||||
Gimbal_SetMode(g, g_cmd->mode);
|
Gimbal_SetMode(g, g_cmd->mode);
|
||||||
|
|
||||||
/* 处理yaw控制命令,软件限位 - 使用电机绝对角度 */
|
/* 处理yaw控制命令,软件限位 - 使用电机绝对角度 */
|
||||||
float delta_yaw = g_cmd->delta_yaw * g->dt * 1.5f;
|
float delta_yaw = g_cmd->delta_yaw * g->dt;
|
||||||
if (g->param->travel.yaw > 0) {
|
if (g->param->travel.yaw > 0) {
|
||||||
/* 计算当前电机角度与IMU角度的偏差 */
|
/* 计算当前电机角度与IMU角度的偏差 */
|
||||||
float motor_imu_offset = g->feedback.motor.yaw.rotor_abs_angle - g->feedback.imu.eulr.yaw;
|
float motor_imu_offset = g->feedback.motor.yaw.rotor_abs_angle - g->feedback.imu.eulr.yaw;
|
||||||
@ -218,8 +217,15 @@ int8_t Gimbal_Control(Gimbal_t *g, Gimbal_CMD_t *g_cmd) {
|
|||||||
g->feedback.imu.eulr.rol, 0.0f, g->dt);
|
g->feedback.imu.eulr.rol, 0.0f, g->dt);
|
||||||
g->out.pit = PID_Calc(&(g->pid.pit_omega), pit_omega_set_point,
|
g->out.pit = PID_Calc(&(g->pid.pit_omega), pit_omega_set_point,
|
||||||
g->feedback.imu.gyro.y, 0.f, g->dt);
|
g->feedback.imu.gyro.y, 0.f, g->dt);
|
||||||
|
// yaw_omega_set_point = PID_Calc(&(g->pid.yaw_angle), g->setpoint.eulr.yaw,
|
||||||
|
// g->feedback.motor.yaw.rotor_abs_angle, 0.0f, g->dt);
|
||||||
|
// g->out.yaw = PID_Calc(&(g->pid.pit_omega), yaw_omega_set_point,
|
||||||
|
// g->feedback.imu.gyro.z, 0.f, g->dt);
|
||||||
|
|
||||||
|
// pit_omega_set_point = PID_Calc(&(g->pid.pit_angle), g->setpoint.eulr.pit,
|
||||||
|
// g->feedback.motor.pit.rotor_abs_angle, 0.0f, g->dt);
|
||||||
|
// g->out.pit = PID_Calc(&(g->pid.pit_omega), pit_omega_set_point,
|
||||||
|
// g->feedback.imu.gyro.y, 0.f, g->dt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* 输出滤波 */
|
/* 输出滤波 */
|
||||||
@ -239,8 +245,7 @@ int8_t Gimbal_Control(Gimbal_t *g, Gimbal_CMD_t *g_cmd) {
|
|||||||
void Gimbal_Output(Gimbal_t *g){
|
void Gimbal_Output(Gimbal_t *g){
|
||||||
MOTOR_RM_SetOutput(&g->param->pit_motor, g->out.pit);
|
MOTOR_RM_SetOutput(&g->param->pit_motor, g->out.pit);
|
||||||
MOTOR_MIT_Output_t output = {0};
|
MOTOR_MIT_Output_t output = {0};
|
||||||
output.torque = g->out.yaw * 6.0f; // 乘以减速比
|
output.torque = g->out.yaw * 2.5;
|
||||||
output.kd = 0.5f;
|
|
||||||
MOTOR_RM_Ctrl(&g->param->pit_motor);
|
MOTOR_RM_Ctrl(&g->param->pit_motor);
|
||||||
MOTOR_DM_MITCtrl(&g->param->yaw_motor, &output);
|
MOTOR_DM_MITCtrl(&g->param->yaw_motor, &output);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
|
|
||||||
#include "shoot.h"
|
#include "shoot.h"
|
||||||
#include <string.h>
|
|
||||||
#include "can.h"
|
#include "bsp/can.h"
|
||||||
#include "component/filter.h"
|
#include "component/filter.h"
|
||||||
#include "component/user_math.h"
|
#include <string.h>
|
||||||
|
// #include
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "bsp/time.h"
|
#include "bsp/time.h"
|
||||||
|
|
||||||
static bool last_firecmd;
|
uint32_t shoot_ctrl_cnt_last;
|
||||||
|
float shoot_ctrl_dt;
|
||||||
|
bool last_firecmd=false;
|
||||||
|
|
||||||
static inline void ScaleSumTo1(float *a, float *b) {
|
static inline void ScaleSumTo1(float *a, float *b) {
|
||||||
float sum = *a + *b;
|
float sum = *a + *b;
|
||||||
@ -18,281 +21,148 @@ 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 (s == NULL) {
|
if (c == NULL || param == NULL || target_freq <= 0.0f) {
|
||||||
return -1; // 参数错误
|
return -1; // 参数错误
|
||||||
}
|
}
|
||||||
s->mode=mode;
|
c->param=param;
|
||||||
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);
|
|
||||||
PID_ResetIntegral(&s->pid.trig_omg);
|
|
||||||
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);
|
|
||||||
PID_Reset(&s->pid.trig_omg);
|
|
||||||
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.outagl_trig=0.0f;
|
|
||||||
s->output.outomg_trig=0.0f;
|
|
||||||
s->output.outlpf_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=4000.0f/MAX_FRIC_RPM;
|
|
||||||
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;
|
|
||||||
|
|
||||||
BSP_CAN_Init();
|
BSP_CAN_Init();
|
||||||
|
memset(&c->feedback, 0, sizeof(c->feedback));
|
||||||
|
|
||||||
for(int i=0;i<SHOOT_FRIC_NUM;i++){
|
for(int i=0;i<SHOOT_FRIC_NUM;i++){
|
||||||
MOTOR_RM_Register(¶m->fric_motor_param[i]);
|
MOTOR_RM_Register(¶m->fric_motor_param[i]);
|
||||||
PID_Init(&s->pid.fric_follow[i], KPID_MODE_CALC_D, target_freq,¶m->fric_follow);
|
PID_Init(&c->pid.fric_follow[i], KPID_MODE_CALC_D, target_freq,¶m->fric_follow);
|
||||||
LowPassFilter2p_Init(&s->filter.fric.in[i], target_freq, s->param->filter.fric.in);
|
LowPassFilter2p_Init(&c->filter.fric.in[i], target_freq, c->param->filter.fric.in);
|
||||||
LowPassFilter2p_Init(&s->filter.fric.out[i], target_freq, s->param->filter.fric.out);
|
LowPassFilter2p_Init(&c->filter.fric.out[i], target_freq, c->param->filter.fric.out);
|
||||||
}
|
}
|
||||||
MOTOR_RM_Register(¶m->trig_motor_param);
|
MOTOR_RM_Register(¶m->trig_motor_param);
|
||||||
PID_Init(&s->pid.trig, KPID_MODE_CALC_D, target_freq,¶m->trig);
|
PID_Init(&c->pid.trig, KPID_MODE_CALC_D, target_freq,¶m->trig);
|
||||||
PID_Init(&s->pid.trig_omg, KPID_MODE_CALC_D, target_freq,¶m->trig_omg);
|
|
||||||
|
|
||||||
LowPassFilter2p_Init(&s->filter.trig.in, target_freq, s->param->filter.trig.in);
|
LowPassFilter2p_Init(&c->filter.trig.in, target_freq, c->param->filter.trig.in);
|
||||||
LowPassFilter2p_Init(&s->filter.trig.out, target_freq, s->param->filter.trig.out);
|
LowPassFilter2p_Init(&c->filter.trig.out, target_freq, c->param->filter.trig.out);
|
||||||
|
|
||||||
memset(&s->shoot_Anglecalu,0,sizeof(s->shoot_Anglecalu));
|
|
||||||
memset(&s->output,0,sizeof(s->output));
|
|
||||||
s->target_variable.target_rpm=4000.0f;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t Chassis_UpdateFeedback(Shoot_t *s)
|
int8_t Chassis_UpdateFeedback(Shoot_t *c)
|
||||||
{
|
{
|
||||||
if (s == NULL) {
|
if (c == NULL) {
|
||||||
return -1; // 参数错误
|
return -1; // 参数错误
|
||||||
}
|
}
|
||||||
|
|
||||||
float rpm_sum=0.0f;
|
float rpm_sum=0.0f;
|
||||||
for(int i = 0; i < SHOOT_FRIC_NUM; i++) {
|
for(int i = 0; i < SHOOT_FRIC_NUM; i++) {
|
||||||
/* 更新摩擦电机反馈 */
|
MOTOR_RM_Update(&c->param->fric_motor_param[i]);
|
||||||
MOTOR_RM_Update(&s->param->fric_motor_param[i]);
|
MOTOR_RM_t *motor_fed = MOTOR_RM_GetMotor(&c->param->fric_motor_param[i]);
|
||||||
MOTOR_RM_t *motor_fed = MOTOR_RM_GetMotor(&s->param->fric_motor_param[i]);
|
|
||||||
if(motor_fed!=NULL)
|
if(motor_fed!=NULL)
|
||||||
{
|
{
|
||||||
s->feedback.fric[i]=motor_fed->motor.feedback;
|
c->feedback.fric[i]=motor_fed->motor.feedback;
|
||||||
}
|
}
|
||||||
/* 滤波反馈rpm */
|
c->feedback.fil_fric_rpm[i] = LowPassFilter2p_Apply(&c->filter.fric.in[i], c->feedback.fric[i].rotor_speed);
|
||||||
s->feedback.fil_fric_rpm[i] = LowPassFilter2p_Apply(&s->filter.fric.in[i], s->feedback.fric[i].rotor_speed);
|
c->feedback.fric_rpm[i] = c->feedback.fil_fric_rpm[i] / MAX_FRIC_RPM;
|
||||||
/* 归一化rpm */
|
if(c->feedback.fric_rpm[i]>1.0f)c->feedback.fric_rpm[i]=1.0f;
|
||||||
s->feedback.fric_rpm[i] = s->feedback.fil_fric_rpm[i] / MAX_FRIC_RPM;
|
if(c->feedback.fric_rpm[i]<-1.0f)c->feedback.fric_rpm[i]=-1.0f;
|
||||||
if(s->feedback.fric_rpm[i]>1.0f)s->feedback.fric_rpm[i]=1.0f;
|
rpm_sum+=c->feedback.fric_rpm[i];
|
||||||
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;
|
c->feedback.fric_avgrpm=rpm_sum/SHOOT_FRIC_NUM;
|
||||||
/* 更新拨弹电机反馈 */
|
MOTOR_RM_Update(&c->param->trig_motor_param);
|
||||||
MOTOR_RM_Update(&s->param->trig_motor_param);
|
c->feedback.trig = MOTOR_RM_GetMotor(&c->param->trig_motor_param);
|
||||||
MOTOR_RM_t *motor_fed = MOTOR_RM_GetMotor(&s->param->trig_motor_param);
|
//
|
||||||
if(motor_fed!=NULL)
|
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;
|
||||||
s->feedback.trig=motor_fed->feedback;
|
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;
|
||||||
/* 将多圈角度归化到单圈 (-M_PI, M_PI) */
|
//
|
||||||
s->feedback.trig_angle_cicle = s->feedback.trig.rotor_abs_angle;
|
c->errtosee = c->feedback.fric[0].rotor_speed - c->feedback.fric[1].rotor_speed;
|
||||||
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; //如果单环效果好就删
|
|
||||||
if(s->feedback.trig_rpm<-1.0f)s->feedback.trig_rpm=-1.0f;
|
|
||||||
|
|
||||||
s->errtosee = s->feedback.fric[0].rotor_speed - s->feedback.fric[1].rotor_speed;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t Shoot_Control(Shoot_t *s, Shoot_CMD_t *cmd)
|
int8_t Shoot_Control(Shoot_t *c, const Shoot_CMD_t *cmd)
|
||||||
{
|
{
|
||||||
if (s == NULL || cmd == NULL) {
|
if (c == NULL || cmd == NULL) {
|
||||||
return -1; // 参数错误
|
return -1; // 参数错误
|
||||||
}
|
}
|
||||||
s->now = BSP_TIME_Get_us() / 1000000.0f;
|
c->dt = (BSP_TIME_Get_us() - c->lask_wakeup) / 1000000.0f;
|
||||||
s->dt = (BSP_TIME_Get_us() - s->lask_wakeup) / 1000000.0f;
|
c->lask_wakeup = BSP_TIME_Get_us();
|
||||||
s->lask_wakeup = BSP_TIME_Get_us();
|
c->online = cmd->online;
|
||||||
s->online = cmd->online;
|
if(!c->online /*|| c->mode==SHOOT_MODE_SAFE*/){
|
||||||
if(!s->online /*|| s->mode==SHOOT_MODE_SAFE*/){
|
|
||||||
for(int i=0;i<SHOOT_FRIC_NUM;i++)
|
for(int i=0;i<SHOOT_FRIC_NUM;i++)
|
||||||
{
|
{
|
||||||
MOTOR_RM_Relax(&s->param->fric_motor_param[i]);
|
MOTOR_RM_Relax(&c->param->fric_motor_param[i]);
|
||||||
}
|
}
|
||||||
MOTOR_RM_Relax(&s->param->trig_motor_param);
|
MOTOR_RM_Relax(&c->param->trig_motor_param);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
switch(s->running_state)
|
switch(c->running_state)
|
||||||
{
|
{
|
||||||
case SHOOT_STATE_IDLE:/*熄火等待*/
|
case SHOOT_STATE_IDLE:/*熄火等待*/
|
||||||
for(int i=0;i<SHOOT_FRIC_NUM;i++)
|
for(int i=0;i<SHOOT_FRIC_NUM;i++)
|
||||||
{
|
{
|
||||||
PID_ResetIntegral(&s->pid.fric_follow[i]);
|
PID_ResetIntegral(&c->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);
|
c->output.out_follow[i]=PID_Calc(&c->pid.fric_follow[i],0.0f,c->feedback.fric_rpm[i],0,c->dt);
|
||||||
s->output.out_fric[i]=s->output.out_follow[i];
|
c->output.out_fric[i]=c->output.out_follow[i];
|
||||||
s->output.lpfout_fric[i] = LowPassFilter2p_Apply(&s->filter.fric.out[i], s->output.out_fric[i]);
|
c->output.lpfout_fric[i] = LowPassFilter2p_Apply(&c->filter.fric.out[i], c->output.out_fric[i]);
|
||||||
MOTOR_RM_SetOutput(&s->param->fric_motor_param[i], s->output.lpfout_fric[i]);
|
MOTOR_RM_SetOutput(&c->param->fric_motor_param[i], c->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);
|
c->output.out_trig=PID_Calc(&c->pid.trig,c->target_variable.target_angle,c->feedback.trig->gearbox_total_angle,0,c->dt);
|
||||||
s->output.outomg_trig =PID_Calc(&s->pid.trig_omg,s->output.outagl_trig,s->feedback.trig_rpm,0,s->dt);
|
MOTOR_RM_SetOutput(&c->param->trig_motor_param, c->output.out_trig);
|
||||||
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)
|
if(cmd->ready)
|
||||||
{
|
{
|
||||||
Shoot_ResetCalu(s);
|
c->running_state=SHOOT_STATE_READY;
|
||||||
Shoot_ResetIntegral(s);
|
|
||||||
Shoot_ResetOutput(s);
|
|
||||||
s->running_state=SHOOT_STATE_READY;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHOOT_STATE_READY:/*准备射击*/
|
case SHOOT_STATE_READY:/*准备射击*/
|
||||||
|
|
||||||
for(int i=0;i<SHOOT_FRIC_NUM;i++)
|
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);
|
// 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);
|
||||||
s->output.out_err[i]=PID_Calc(&s->pid.fric_err[i],s->feedback.fric_avgrpm,s->feedback.fric_rpm[i],0,s->dt);
|
c->output.out_follow[i]=PID_Calc(&c->pid.fric_follow[i],3000.0f/MAX_FRIC_RPM,c->feedback.fric_rpm[i],0,c->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.outlpf_trig =LowPassFilter2p_Apply(&s->filter.trig.out, s->output.outomg_trig);
|
|
||||||
MOTOR_RM_SetOutput(&s->param->trig_motor_param, s->output.outlpf_trig);
|
|
||||||
|
|
||||||
/* 检查状态机 */
|
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]);
|
||||||
|
}
|
||||||
|
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);
|
||||||
if(!cmd->ready)
|
if(!cmd->ready)
|
||||||
{
|
{
|
||||||
Shoot_ResetCalu(s);
|
c->running_state=SHOOT_STATE_IDLE;
|
||||||
Shoot_ResetOutput(s);
|
|
||||||
s->running_state=SHOOT_STATE_IDLE;
|
|
||||||
}
|
}
|
||||||
else if(last_firecmd==false&&cmd->firecmd==true)
|
else if(cmd->last_firecmd==false&&cmd->firecmd==true)//可以加一个到达目标速度的判断
|
||||||
{
|
{
|
||||||
Shoot_ResetCalu(s);
|
c->running_state=SHOOT_STATE_FIRE;
|
||||||
Shoot_ResetOutput(s);
|
c->target_variable.target_angle-=c->param->trig_step_angle;
|
||||||
s->running_state=SHOOT_STATE_FIRE;
|
|
||||||
s->shoot_Anglecalu.num_to_shoot+=s->param->shot_burst_num;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHOOT_STATE_FIRE:
|
case SHOOT_STATE_FIRE:
|
||||||
Shoot_CaluTargetAngle(s, cmd);
|
// c->target_variable.target_angle+=c->param->trig_step_angle;
|
||||||
for(int i=0;i<SHOOT_FRIC_NUM;i++)
|
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);
|
// 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);
|
||||||
s->output.out_err[i]=PID_Calc(&s->pid.fric_err[i],s->feedback.fric_avgrpm,s->feedback.fric_rpm[i],0,s->dt);
|
c->output.out_follow[i]=PID_Calc(&c->pid.fric_follow[i],3000.0f/MAX_FRIC_RPM,c->feedback.fric_rpm[i],0,c->dt);
|
||||||
ScaleSumTo1(&s->output.out_follow[i], &s->output.out_err[i]);
|
c->output.out_err[i]=PID_Calc(&c->pid.fric_err[i],c->feedback.fric_avgrpm,c->feedback.fric_rpm[i],0,c->dt);
|
||||||
s->output.out_fric[i]=s->output.out_follow[i]+s->output.out_err[i];
|
ScaleSumTo1(&c->output.out_follow[i], &c->output.out_err[i]);
|
||||||
s->output.lpfout_fric[i] = LowPassFilter2p_Apply(&s->filter.fric.out[i], s->output.out_fric[i]);
|
c->output.out_fric[i]=c->output.out_follow[i]+c->output.out_err[i];
|
||||||
MOTOR_RM_SetOutput(&s->param->fric_motor_param[i], s->output.lpfout_fric[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.outagl_trig =PID_Calc(&s->pid.trig,s->target_variable.target_angle,s->feedback.trig_angle_cicle,0,s->dt);
|
c->output.out_trig=PID_Calc(&c->pid.trig,c->target_variable.target_angle,c->feedback.trig->gearbox_total_angle,0,c->dt);
|
||||||
s->output.outomg_trig =PID_Calc(&s->pid.trig_omg,s->output.outagl_trig,s->feedback.trig_rpm,0,s->dt);
|
MOTOR_RM_SetOutput(&c->param->trig_motor_param, c->output.out_trig);
|
||||||
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)
|
if(!cmd->firecmd)
|
||||||
{
|
{
|
||||||
Shoot_ResetCalu(s);
|
c->running_state=SHOOT_STATE_READY;
|
||||||
Shoot_ResetOutput(s);
|
|
||||||
s->running_state=SHOOT_STATE_READY;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
s->running_state=SHOOT_STATE_IDLE;
|
c->running_state=SHOOT_STATE_IDLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MOTOR_RM_Ctrl(&s->param->fric_motor_param[0]);
|
MOTOR_RM_Ctrl(&c->param->fric_motor_param[0]);
|
||||||
MOTOR_RM_Ctrl(&s->param->trig_motor_param);
|
MOTOR_RM_Ctrl(&c->param->trig_motor_param);
|
||||||
last_firecmd = cmd->firecmd;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define SHOOT_FRIC_NUM (2) /* 摩擦轮数量 */
|
#define SHOOT_FRIC_NUM (2) /* 摩擦轮数量 */
|
||||||
#define MAX_FRIC_RPM 7000.0f
|
#define MAX_FRIC_RPM 7000.0f
|
||||||
#define MAX_TRIG_RPM 5000.0f
|
#define MAX_TRIG_RPM 1000.0f
|
||||||
/* Exported macro ----------------------------------------------------------- */
|
/* Exported macro ----------------------------------------------------------- */
|
||||||
/* Exported types ----------------------------------------------------------- */
|
/* Exported types ----------------------------------------------------------- */
|
||||||
|
|
||||||
@ -45,28 +45,23 @@ typedef struct {
|
|||||||
bool ready; /* 准备射击 */
|
bool ready; /* 准备射击 */
|
||||||
bool firecmd; /* 射击指令 */
|
bool firecmd; /* 射击指令 */
|
||||||
|
|
||||||
|
bool last_firecmd;
|
||||||
|
|
||||||
} Shoot_CMD_t;
|
} Shoot_CMD_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MOTOR_Feedback_t fric[SHOOT_FRIC_NUM]; /* 摩擦轮电机反馈 */
|
MOTOR_Feedback_t fric[SHOOT_FRIC_NUM]; /* 摩擦轮电机反馈 */
|
||||||
MOTOR_Feedback_t trig; /* 拨弹电机反馈 */
|
MOTOR_RM_t *trig; /* 拨弹电机反馈 */
|
||||||
|
|
||||||
float fil_fric_rpm[SHOOT_FRIC_NUM]; /* 滤波后的摩擦轮转速 */
|
float fil_fric_rpm[SHOOT_FRIC_NUM]; /* 滤波后的摩擦轮转速 */
|
||||||
float fil_trig_rpm; /* 滤波后的拨弹电机转速*/
|
float fil_trig_rpm; /* 滤波后的拨弹电机转速*/
|
||||||
|
|
||||||
float trig_angle_cicle; /* 拨弹电机减速输出轴单圈角度(0~M_2PI) */
|
|
||||||
|
|
||||||
float fric_rpm[SHOOT_FRIC_NUM]; /* 归一化摩擦轮转速 */
|
float fric_rpm[SHOOT_FRIC_NUM]; /* 归一化摩擦轮转速 */
|
||||||
float fric_avgrpm; /* 归一化摩擦轮平均转速*/
|
float fric_avgrpm; /* 归一化摩擦轮平均转速*/
|
||||||
float trig_rpm; /* 归一化拨弹电机转速*/
|
float trig_rpm; /* 归一化拨弹电机转速*/
|
||||||
|
|
||||||
}Shoot_Feedback_t;
|
}Shoot_Feedback_t;
|
||||||
|
|
||||||
typedef struct{
|
|
||||||
float time_last_shoot;
|
|
||||||
uint8_t num_to_shoot;
|
|
||||||
uint8_t num_shooted;
|
|
||||||
}Shoot_AngleCalu_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float out_follow[SHOOT_FRIC_NUM];
|
float out_follow[SHOOT_FRIC_NUM];
|
||||||
float out_err[SHOOT_FRIC_NUM];
|
float out_err[SHOOT_FRIC_NUM];
|
||||||
@ -74,17 +69,14 @@ typedef struct {
|
|||||||
float lpfout_fric[SHOOT_FRIC_NUM];
|
float lpfout_fric[SHOOT_FRIC_NUM];
|
||||||
|
|
||||||
|
|
||||||
float outagl_trig;
|
float out_trig;
|
||||||
float outomg_trig;
|
float lpfout_trig;
|
||||||
float outlpf_trig;
|
|
||||||
}Shoot_Output_t;
|
}Shoot_Output_t;
|
||||||
|
|
||||||
|
|
||||||
/* 底盘参数的结构体,包含所有初始化用的参数,通常是const,存好几组 */
|
/* 底盘参数的结构体,包含所有初始化用的参数,通常是const,存好几组 */
|
||||||
typedef struct {
|
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 fric_motor_param[SHOOT_FRIC_NUM];
|
||||||
MOTOR_RM_Param_t trig_motor_param;
|
MOTOR_RM_Param_t trig_motor_param;
|
||||||
@ -93,7 +85,7 @@ typedef struct {
|
|||||||
KPID_Params_t fric_follow; /* 摩擦轮电机PID控制参数,用于跟随目标速度 */
|
KPID_Params_t fric_follow; /* 摩擦轮电机PID控制参数,用于跟随目标速度 */
|
||||||
KPID_Params_t fric_err; /* 摩擦轮电机PID控制参数,用于消除转速误差 */
|
KPID_Params_t fric_err; /* 摩擦轮电机PID控制参数,用于消除转速误差 */
|
||||||
KPID_Params_t trig; /* 拨弹电机PID控制参数 */
|
KPID_Params_t trig; /* 拨弹电机PID控制参数 */
|
||||||
KPID_Params_t trig_omg; /* 拨弹电机PID控制参数 */
|
|
||||||
|
|
||||||
/* 低通滤波器截止频率 */
|
/* 低通滤波器截止频率 */
|
||||||
struct {
|
struct {
|
||||||
@ -115,7 +107,6 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
bool online;
|
bool online;
|
||||||
|
|
||||||
float now;
|
|
||||||
uint64_t lask_wakeup;
|
uint64_t lask_wakeup;
|
||||||
float dt;
|
float dt;
|
||||||
|
|
||||||
@ -126,7 +117,6 @@ typedef struct {
|
|||||||
/* 反馈信息 */
|
/* 反馈信息 */
|
||||||
Shoot_Feedback_t feedback;
|
Shoot_Feedback_t feedback;
|
||||||
/* 控制信息*/
|
/* 控制信息*/
|
||||||
Shoot_AngleCalu_t shoot_Anglecalu;
|
|
||||||
Shoot_Output_t output;
|
Shoot_Output_t output;
|
||||||
/* 目标控制量 */
|
/* 目标控制量 */
|
||||||
struct {
|
struct {
|
||||||
@ -139,7 +129,6 @@ typedef struct {
|
|||||||
KPID_t fric_follow[SHOOT_FRIC_NUM]; /* */
|
KPID_t fric_follow[SHOOT_FRIC_NUM]; /* */
|
||||||
KPID_t fric_err[SHOOT_FRIC_NUM]; /* */
|
KPID_t fric_err[SHOOT_FRIC_NUM]; /* */
|
||||||
KPID_t trig;
|
KPID_t trig;
|
||||||
KPID_t trig_omg;
|
|
||||||
} pid;
|
} pid;
|
||||||
|
|
||||||
/* 滤波器 */
|
/* 滤波器 */
|
||||||
@ -163,32 +152,32 @@ typedef struct {
|
|||||||
/**
|
/**
|
||||||
* \brief 初始化发射
|
* \brief 初始化发射
|
||||||
*
|
*
|
||||||
* \param s 包含发射数据的结构体
|
* \param c 包含发射数据的结构体
|
||||||
* \param param 包含发射参数的结构体指针
|
* \param param 包含发射参数的结构体指针
|
||||||
* \param target_freq 任务预期的运行频率
|
* \param target_freq 任务预期的运行频率
|
||||||
*
|
*
|
||||||
* \return 函数运行结果
|
* \return 函数运行结果
|
||||||
*/
|
*/
|
||||||
int8_t Shoot_Init(Shoot_t *s, Shoot_Params_t *param, float target_freq);
|
int8_t Shoot_Init(Shoot_t *c, Shoot_Params_t *param, float target_freq);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief 更新反馈
|
* \brief 更新反馈
|
||||||
*
|
*
|
||||||
* \param s 包含发射数据的结构体
|
* \param c 包含发射数据的结构体
|
||||||
*
|
*
|
||||||
* \return 函数运行结果
|
* \return 函数运行结果
|
||||||
*/
|
*/
|
||||||
int8_t Chassis_UpdateFeedback(Shoot_t *s);
|
int8_t Chassis_UpdateFeedback(Shoot_t *c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief 初始化发射
|
* \brief 初始化发射
|
||||||
*
|
*
|
||||||
* \param s 包含发射数据的结构体
|
* \param c 包含发射数据的结构体
|
||||||
* \param cmd 包含发射命令的结构体
|
* \param cmd 包含发射命令的结构体
|
||||||
*
|
*
|
||||||
* \return 函数运行结果
|
* \return 函数运行结果
|
||||||
*/
|
*/
|
||||||
int8_t Shoot_Control(Shoot_t *s, Shoot_CMD_t *cmd);
|
int8_t Shoot_Control(Shoot_t *c, const Shoot_CMD_t *cmd);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ void Task_rc(void *argument) {
|
|||||||
rc_can.data.joy.ch_r_y = dr16.data.ch_r_y;
|
rc_can.data.joy.ch_r_y = dr16.data.ch_r_y;
|
||||||
rc_can.data.sw.sw_l = (RC_CAN_SW_t)dr16.data.sw_l;
|
rc_can.data.sw.sw_l = (RC_CAN_SW_t)dr16.data.sw_l;
|
||||||
rc_can.data.sw.sw_r = (RC_CAN_SW_t)dr16.data.sw_r;
|
rc_can.data.sw.sw_r = (RC_CAN_SW_t)dr16.data.sw_r;
|
||||||
rc_can.data.sw.ch_res = dr16.data.ch_res;
|
rc_can.data.sw.ch_res = dr16.data.res;
|
||||||
|
|
||||||
RC_CAN_SendData(&rc_can, RC_CAN_DATA_JOYSTICK);
|
RC_CAN_SendData(&rc_can, RC_CAN_DATA_JOYSTICK);
|
||||||
RC_CAN_SendData(&rc_can, RC_CAN_DATA_SWITCH);
|
RC_CAN_SendData(&rc_can, RC_CAN_DATA_SWITCH);
|
||||||
@ -90,7 +90,7 @@ void Task_rc(void *argument) {
|
|||||||
cmd_for_gimbal.delta_pit = dr16.data.ch_r_y*5.0f;
|
cmd_for_gimbal.delta_pit = dr16.data.ch_r_y*5.0f;
|
||||||
break;
|
break;
|
||||||
case DR16_SW_DOWN:
|
case DR16_SW_DOWN:
|
||||||
cmd_for_gimbal.mode = GIMBAL_MODE_ABSOLUTE;
|
cmd_for_gimbal.mode = GIMBAL_MODE_RELATIVE;
|
||||||
cmd_for_gimbal.delta_yaw = -dr16.data.ch_r_x* 5.0f;
|
cmd_for_gimbal.delta_yaw = -dr16.data.ch_r_x* 5.0f;
|
||||||
cmd_for_gimbal.delta_pit = dr16.data.ch_r_y*5.0f;
|
cmd_for_gimbal.delta_pit = dr16.data.ch_r_y*5.0f;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -22,12 +22,12 @@ void OnProjectLoad (void) {
|
|||||||
//
|
//
|
||||||
// Dialog-generated settings
|
// Dialog-generated settings
|
||||||
//
|
//
|
||||||
|
Project.AddPathSubstitute ("/Users/lvzucheng/Documents/R/balance_infantry", "$(ProjectDir)");
|
||||||
|
Project.AddPathSubstitute ("/users/lvzucheng/documents/r/balance_infantry", "$(ProjectDir)");
|
||||||
Project.SetDevice ("STM32F407IG");
|
Project.SetDevice ("STM32F407IG");
|
||||||
Project.SetHostIF ("USB", "207400620");
|
Project.SetHostIF ("USB", "207400620");
|
||||||
Project.SetTargetIF ("SWD");
|
Project.SetTargetIF ("SWD");
|
||||||
Project.SetTIFSpeed ("4 MHz");
|
Project.SetTIFSpeed ("4 MHz");
|
||||||
Project.AddPathSubstitute ("/Users/lvzucheng/Documents/R/balance_infantry", "$(ProjectDir)");
|
|
||||||
Project.AddPathSubstitute ("/users/lvzucheng/documents/r/balance_infantry", "$(ProjectDir)");
|
|
||||||
Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-M4F.svd");
|
Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-M4F.svd");
|
||||||
//
|
//
|
||||||
// User settings
|
// User settings
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user