# sentry_steering_25 **Repository Path**: cod_-control/sentry_steering_25 ## Basic Information - **Project Name**: sentry_steering_25 - **Description**: 25赛季哨兵电控代码 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-12-07 - **Last Updated**: 2025-07-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # sentry_steering_25 ## 介绍 25赛季哨兵电控代码 分为chassis和gimbal两个文件分别存放底盘和云台代码 chassis和gimbal软件架构和文件结构基本一致 ## 软件架构 开发工具:Keil MDK-ARM V5.39, Visual Studio Code 软件环境:Window11 硬件环境:DAMIAO DM-MC-Board02 (STM32H723VGT6) 编译工具:Arm Compiler v6.19 ## 文件结构 `````` ├─Algorithm │ ├─Inc │ └─Src ├─API │ ├─Inc │ └─Src ├─BSP │ ├─Inc │ └─Src ├─Core │ ├─Inc │ └─Src ├─Device │ ├─Inc │ └─Src ├─Drivers │ ├─CMSIS │ │ ├─Device │ │ │ └─ST │ │ │ └─STM32H7xx │ │ │ ├─Include │ │ │ └─Source │ │ │ └─Templates │ │ └─Include │ └─STM32H7xx_HAL_Driver │ ├─Inc │ │ └─Legacy │ └─Src ├─MDK-ARM │ ├─.vscode │ ├─COD_H7_Template │ ├─DebugConfig │ └─RTE │ └─_COD_H7_Template ├─Middlewares │ ├─ST │ │ └─ARM │ │ └─DSP │ │ ├─Inc │ │ └─Lib │ └─Third_Party │ ├─ARM │ │ └─DSP │ └─FreeRTOS │ └─Source │ ├─CMSIS_RTOS │ ├─include │ └─portable │ ├─MemMang │ └─RVDS │ └─ARM_CM4F ├─SystemView │ ├─Config │ ├─Sample │ │ └─FreeRTOSV10 │ │ ├─Config │ │ │ └─Cortex-M │ │ └─Patch │ └─SEGGER │ └─Syscalls └─Task ├─Inc └─Src `````` ## chassis中的模块功能说明 ### IMU 惯性测量单元 参考[哈尔滨工程大学创梦之翼战队惯导姿态解算项目。](https://github.com/WangHongxi2001/RoboMaster-C-Board-INS-Example) ## chassis重要文件说明 ### Control_Task 主要包含舵轮解算,云台yaw轴控制,使用接近开关记录零点位置等 ``` Chassis_Info.angle[0]=atan2f((Chassis_Info.Vx - Chassis_Info.Vw * sin45*R),(Chassis_Info.Vy + Chassis_Info.Vw * sin45*R))*RadiansToDegrees; Chassis_Info.angle[1]=atan2f((Chassis_Info.Vx + Chassis_Info.Vw * sin45*R),(Chassis_Info.Vy + Chassis_Info.Vw * sin45*R))*RadiansToDegrees; Chassis_Info.angle[2]=atan2f((Chassis_Info.Vx + Chassis_Info.Vw * sin45*R),(Chassis_Info.Vy - Chassis_Info.Vw * sin45*R))*RadiansToDegrees; Chassis_Info.angle[3]=atan2f((Chassis_Info.Vx - Chassis_Info.Vw * sin45*R),(Chassis_Info.Vy - Chassis_Info.Vw * sin45*R))*RadiansToDegrees; Chassis_Info.advace.target[0] = sqrtf(powf(Chassis_Info.Vx - Chassis_Info.Vw * sin45, 2.f) + powf(Chassis_Info.Vy - Chassis_Info.Vw * sin45, 2.f)); Chassis_Info.advace.target[1] = sqrtf(powf(Chassis_Info.Vx - Chassis_Info.Vw * sin45, 2.f) + powf(Chassis_Info.Vy + Chassis_Info.Vw * sin45, 2.f)); Chassis_Info.advace.target[2] = sqrtf(powf(Chassis_Info.Vx + Chassis_Info.Vw * sin45, 2.f) + powf(Chassis_Info.Vy + Chassis_Info.Vw * sin45, 2.f)); Chassis_Info.advace.target[3] = sqrtf(powf(Chassis_Info.Vx + Chassis_Info.Vw * sin45, 2.f) + powf(Chassis_Info.Vy - Chassis_Info.Vw * sin45, 2.f)); ``` ### Can_Task 使用can通信发送数据 ### bsp_uart 使用dma双缓存和rs485用来接收gimbal发送chassis的数据 ``` static void USART_RxDMA_MultiBuffer_Init(UART_HandleTypeDef *huart, uint32_t *DstAddress, uint32_t *SecondMemAddress, uint32_t DataLength){ huart->ReceptionType = HAL_UART_RECEPTION_TOIDLE; huart->RxXferSize = DataLength; SET_BIT(huart->Instance->CR3,USART_CR3_DMAR); __HAL_UART_ENABLE_IT(huart, UART_IT_IDLE); do{ __HAL_DMA_DISABLE(huart->hdmarx); }while(((DMA_Stream_TypeDef *)huart->hdmarx->Instance)->CR & DMA_SxCR_EN); /* Configure the source memory Buffer address */ ((DMA_Stream_TypeDef *)huart->hdmarx->Instance)->PAR = (uint32_t)&huart->Instance->RDR; /* Configure the destination memory Buffer address */ ((DMA_Stream_TypeDef *)huart->hdmarx->Instance)->M0AR = (uint32_t)DstAddress; /* Configure DMA Stream destination address */ ((DMA_Stream_TypeDef *)huart->hdmarx->Instance)->M1AR = (uint32_t)SecondMemAddress; /* Configure the length of data to be transferred from source to destination */ ((DMA_Stream_TypeDef *)huart->hdmarx->Instance)->NDTR = DataLength; /* Enable double memory buffer */ SET_BIT(((DMA_Stream_TypeDef *)huart->hdmarx->Instance)->CR, DMA_SxCR_DBM); /* Enable DMA */ __HAL_DMA_ENABLE(huart->hdmarx); } ``` ## gimbal中的模块功能说明 ### IMU 惯性测量单元 参考[哈尔滨工程大学创梦之翼战队惯导姿态解算项目。](https://github.com/WangHongxi2001/RoboMaster-C-Board-INS-Example) ### MiniPC通信 使用`MiniPC_Re_Auto_aim(uint8_t* Buf, const uint32_t *Len)`和`MiniPC_Re_navagation(uint8_t* Buf, const uint32_t *Len)`对上位机的数据进行接收 ``` static int8_t CDC_Receive_HS(uint8_t* Buf, uint32_t *Len) ``` 在函数中调用实现数据接收 ``` uint8_t CDC_Transmit_HS(uint8_t* Buf, uint16_t Len) ``` 使用函数发送数据给上位机 详见Device中Src的minipc.c ## gimbal重要文件说明 ### Control_Task 主要包含pitch轴控制等 ### Can_Task can通信发送的数据,使用`uint8_t CDC_Transmit_HS(uint8_t* Buf, uint16_t Len)`对上位机发送数据的处理