Hurricane Robot Control System for SJTU RoboMaster Competition
This project is generated with STM32CubeMX and built with CMake.
This project depends on CAHRR. CAHRR (Chi's Advanced Hurricane Robot Runtime) is a well-tested yet simple library which defines modules such as tasks and contains many utility classes for this project. It can be integrated into any project.
All directory except Src-CAH are generated by STM32CubeMX.
Src/runtime
contains Dajiang official code.
We've made changes to Src/stm32f4xx_it.c
and main.c
, to redirect interrupts to Hurricane system and bootstrap the Hurricane control system.
- HurricaneArmSystem - control two arms of our robot
- HurricaneCANSystem - control CAN devices
- HurricaneChassisSystem - control chassis
HurricaneClawSystem - control claw, which is built with potentiometer and pwm motor- HurricaneClawSystem - control claw for collecting buff and elevator for the claw
- HurricaneCollectorSystem - control ball collector, which is built with servo
- HurricaneDebugSystem - transmit debug information
- HurricaneGPIOSystem - process GPIO interrupts
- HurricaneIMUSystem - get gyro data
- HurricaneRemoteSystem - get data from Dajiang joystick
HurricaneUltrasonicSystem- get data from 4 ultrasonic sensors while preventing interference. We didn't use those sensors in final competition and therefore deleted these parts. These changes can be found in code history.
- ArmTask - control arm
- TimedTask - timing task on STM32
- MainSwitchTask(s) - joystick switch control
- SaveDriveTask - control chassis when saving other robots
- ServoTask - control servo of ball collector
- TankDriveTask - control chassis
In particular, MainTask
Task *mainTask() {
return new ParallelTask(std::vector<Task *>({
new LeftSwitchNone(
nullptr, // [1]
new RightSwitchBottom(
new LeftSwitchBottom(
new LeftSwitchTop(
new TankDriveTask, // [4]
nullptr
),
new SaveDriveTask // [3]
),
new ArmTask // [2]
)
),
new RightSwitchTopTrigger( // [5]
new CollectorCloseTask,
new CollectorOpenTask)
}));
}
Tasks are organized like a tree in CAHRR
. They are processed and executed in the following sequence
[1] If joystick is not connected, do nothing.
[2] If right switch is switched to bottom, control arm.
[3] If left switch is switched to bottom, control chassis in save mode.
[4] If left switch is switched to middle, control chassis
[5] If right switch is switched to top, open or close the collector.
- Arm, ArmBottom, ArmTop - PID control of different arms
- ArmBase - PID control of arm base
- OI - pack all systems and bootstrap tasks
- HAL - include all HAL libraries
You can deploy the project with CLion and STM32 plugin.
MIT
We won the eighth place in the first SJTU (Inter-Campus) RoboMaster Competition. Here's our chaotic robot.
I personally would like to thank Shaofei Qin and SJTU RoboMaster Team for their open-source project RM_frame. Without them there won't be Hurricane and CAHRR. I learned a lot through the building of this project on embedded system STM32.