# 第二十四届全国机器人大赛 R1 **Repository Path**: ibst/curc ## Basic Information - **Project Name**: 第二十四届全国机器人大赛 R1 - **Description**: 世界机器人运动会 全国第四名 | 全国机器人大赛Robocon 全国第八名 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-10-31 - **Last Updated**: 2025-11-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: Robocon, 机器人, PID, RC, 控制 ## README # Fir_Car ## Project Overview Fir_Car is an embedded control system developed based on the STM32F4 series microcontroller, primarily designed for motion control of robots or intelligent vehicles. This project integrates the FreeRTOS real-time operating system and supports multiple peripheral communication protocols including CAN, UART, I2C, and PWM, combined with PID control algorithms to achieve precise control of modules such as motors, servos, and IMUs. Key functional modules include: - **CAN Bus Communication**: Enables data exchange with motor controllers (e.g., GM6020, M3508). - **FreeRTOS Multitasking Scheduler**: Implements multithreaded control for speed control, CAN communication, IMU data acquisition, and more. - **PID Control Algorithm**: Enables closed-loop control of motor speed and position. - **SBUS Receiver Communication**: Parses signals from remote controllers. - **IMU Data Parsing**: Provides attitude sensing and navigation capabilities. - **Motor Control**: Supports multiple motor drivers such as AK7010, GM6020, and M3508. ## Project Structure ``` Core/ ├── Inc/ // Core header files (e.g., main.h, stm32f4xx_hal_conf.h) ├── Src/ │ ├── main.c // Main program entry │ ├── freertos.c // FreeRTOS task initialization and thread functions │ ├── can.c // CAN bus initialization and filter configuration │ ├── gpio.c // GPIO pin configuration │ ├── i2c.c // I2C initialization │ ├── tim.c // Timer configuration │ ├── usart.c // UART initialization │ └── stm32f4xx_it.c // Interrupt handler functions ├── Drivers/ │ ├── CMSIS/ // ARM CMSIS core library │ └── STM32F4xx_HAL_Driver/ // STM32 HAL driver library ├── Middlewares/ │ └── Third_Party/FreeRTOS/ // FreeRTOS real-time operating system source code ├── USER/ │ ├── Inc/ // User-defined header files (e.g., PID.h, RobotControl.h) │ └── Src/ // User functional implementation code (e.g., PID control, motor drive, IMU parsing) ├── EWARM/ // IAR project files and build outputs └── README.txt // Project documentation ``` ## Key Functional Module Descriptions ### 1. FreeRTOS Multitasking Scheduler - Implements multitasking via FreeRTOS, including: - `StartDefaultTask`: Main task - `AK7010_Task`: Motor control task - `M3508_Task`: Motor control task - `speedtask`: Speed control task - `sbustask`: SBUS signal processing task - `ads1115`: ADC data acquisition task - `Change_yaw`: Yaw angle control task - `Change_N`: Navigation control task - `Ak7010_reinit`: Motor re-initialization task ### 2. CAN Bus Communication - Utilizes the STM32 CAN controller to communicate with external motor controllers (e.g., GM6020, M3508). - Supports dual-channel communication via CAN1 and CAN2. - Includes CAN filter configuration functions: `can1_filter_init` and `can2_filter_init`. ### 3. PID Control Algorithm - Implements incremental PID control for motor speed and position regulation. - Supports multiple PID instances for controlling different motors or sensors. ### 4. Motor Control - **GM6020**: CAN-controlled motor driver for speed and position control. - **M3508**: CAN-controlled motor driver for chassis motion control. - **AK7010**: CAN-controlled servo motor for robotic arm or servo control. ### 5. SBUS Signal Parsing - Supports the Futaba SBUS receiver protocol for remote controller input. - Parses channel data and maps it to control commands. ### 6. IMU Data Acquisition and Parsing - Supports CH Robotics IMU series via UART interface to obtain attitude data. - Implements data synchronization, CRC verification, and data parsing. ### 7. Robot Motion Control - Implements velocity decomposition and directional control based on kinematic models. - Supports transformation between world and body coordinate systems. - Includes features such as path planning, velocity limiting, and acceleration limiting. ## Compilation and Debugging - Compile and debug using **IAR Embedded Workbench**. - Project file: `EWARM/Fir_Car.ewp`. - Supports in-circuit debugging via IAR debuggers (e.g., J-Link). ## Dependencies - **STM32 HAL Library**: For STM32 peripheral drivers. - **FreeRTOS**: Real-time operating system for task scheduling. - **CMSIS**: ARM-provided mathematical and system control library. ## Development Environment - **IDE**: IAR Embedded Workbench for ARM - **MCU**: STM32F427xx - **Compiler**: IAR ARM Compiler ## Usage Instructions 1. Open the project file `EWARM/Fir_Car.ewp`. 2. Configure peripheral parameters for CAN, UART, I2C, etc. 3. Modify or implement control logic in `USER/Src/`. 4. Compile and download the firmware to the target board. 5. Connect with a debugger and run the program. ## Notes - Ensure pin configurations for CAN, UART, and other peripherals match the hardware design. - Properly configure FreeRTOS stack sizes and task priorities according to application requirements. - Tune PID parameters based on actual system behavior. ## Copyright Information This project is open-source under the MIT License. Refer to the `LICENSE` file in the project root directory. ## Contact For questions or suggestions, please submit an Issue or contact the project maintainer. --- **Project Repository**: [https://gitee.com/ibst/curc](https://gitee.com/ibst/curc)