RoboRTS infantry control firmware
- Toolchain/IDE : MDK-ARM V5
- cube version: STM32CubeMX 4.22.1
- package version: STM32Cube FW_F4 V1.16.0
- FreeRTOS version: 9.0.0
- CMSIS-RTOS version: 1.02
- Names of user-defined variables and function should follow Unix/Linux style.
- Due to real time control task executes in Application/AppCtrl, it is prohibited to use any blocking operation.
- When blocking is operated in other tasks, time-out period should be set rationally. Be careful of using mutex or other blocking operation in different priority level and frequency. For example, detect_task has lower frequency and info_get_task has higher frequency.
- All new document should be written in UTF-8 format in case Chinese characters gibberish generated.
- Document sys_config.h includes all configuration parameters of the whole infantry system and user can change those parameters as needed.
When one of the modules is off-line, user can find out which module is out of work based on indicated light and buzzer in board.
In this project, error warns depend on the priority of off-line modules.
Corresponding states of each module off-line are shown as following while the number corresponds the number of times of the red light flashes.
- Remote controller off-line
- Gimbal motor off-line
- Trigger motor or single gyroscope off-line
- Chassis motor off-line
- Single gyroscope sensor of chassis off-line
- Referee system or PC serial port off-line and the red light keeps on
The following is the location of each interface of the main control board.
Basic control command including remote control and key-mouse control is executed in manual mode.
ATTENTION: If the AUTO_NAVIGATION
macro is defined in the sys_config.h
file, the Debug Mode and Full-auto Mode will be turned on.
Upper layer PC takes the whole control of chassis, gimbal and shooting module in bottom layer in full auto mode.
Remote control: (Right switcher state: UP.)
- open or close friction wheel
- single shot or burst
Key-mouse control: (Right switcher state: UP. Left switcher state: MIDDLE.)
- open (Q) or close (Q + shift) friction wheel
- single shot (Click the left mouse button) or burst (Long press the left mouse button)
- twist to dodge bullets (E)
Debugging robot part (Right switcher state: MIDDLE.)
- twist to dodge bullets (Right switcher state: MIDDLE. Left switcher state: UP)
- Gimbal tracks strikers but chassis doesn't follow gimbal (Right switcher state: MIDDLE. Left switcher state: MIDDLE.)
- Gimbal tracks strikers and chassis follows gimbal (Right switcher state: MIDDLE. Left switcher state: DOWN.)
Normal competition part (Right switcher state: Down)
- Full-auto control from upper layer.
comment:
Bold parts shown following are the different modules working states in full-auto mode. User should notice initial value of each mode when upper layer PC transmit control signal.
typedef enum
{
GIMBAL_RELAX = 0,
GIMBAL_INIT = 1,
GIMBAL_NO_ARTI_INPUT = 2,
GIMBAL_FOLLOW_ZGYRO = 3,
GIMBAL_TRACK_ARMOR = 4,
GIMBAL_PATROL_MODE = 5,
GIMBAL_SHOOT_BUFF = 6,
GIMBAL_POSITION_MODE = 7,
} gimbal_mode_e;
Gimbal Mode | Function |
---|---|
GIMBAL_RELAX | Gimbal powers off |
GIMBAL_INIT | Gimbal is being restored from the power off status |
GIMBAL_NO_ARTI_INPUT | No manual control data input mode available |
GIMBAL_FOLLOW_ZGYRO | The mode in which the gimbal follows the chassis |
GIMBAL_TRACK_ARMOR | Gimbal tracks armor, Use GIMBAL_POSITION_MODE instead |
GIMBAL_PATROL_MODE | Patrol mode, the gimbal yaws periodically, pitch uncontrolled |
GIMBAL_SHOOT_BUFF | Shooting buff mode, icra not use |
GIMBAL_POSITION_MODE | Gimbal position mode, angle between two axes controlled on an upper layer |
typedef enum
{
CHASSIS_RELAX = 0,
CHASSIS_STOP = 1,
MANUAL_SEPARATE_GIMBAL = 2,
MANUAL_FOLLOW_GIMBAL = 3,
DODGE_MODE = 4,
AUTO_SEPARATE_GIMBAL = 5,
AUTO_FOLLOW_GIMBAL = 6,
} chassis_mode_e;
Chassis mode | Function |
---|---|
CHASSIS_RELAX | Power off chassis |
CHASSIS_STOP | Stop chassis |
MANUAL_SEPARATE_GIMBAL | Control chassis and gimbal separately in manual mode |
MANUAL_FOLLOW_GIMBAL | Chassis follows gimbal in manual mode |
DODGE_MODE | Chassis dodge bullets mode |
AUTO_SEPARATE_GIMBAL | Control chassis and gimbal separately in full-auto mode |
AUTO_FOLLOW_GIMBAL | Chassis follows gimbal in full-auto mode |
typedef enum
{
SHOT_DISABLE = 0,
REMOTE_CTRL_SHOT = 1,
KEYBOARD_CTRL_SHOT = 2,
SEMIAUTO_CTRL_SHOT = 3,
AUTO_CTRL_SHOT = 4,
} shoot_mode_e;
Shooting module mode | Function |
---|---|
SHOT_DISABLE | Power off shooting module |
REMOTE_CTRL_SHOT | Remote control |
KEYBOARD_CTRL_SHOT | Key-mouse control |
SEMIAUTO_CTRL_SHOT | Single shot or burst in semi-auto mode |
AUTO_CTRL_SHOT | Full-auto control |
- This program uses free open source called freertos operating system, which is compatible with other open source protocol license.
- This program uses standard CMSIS-ROTS ports, which is convenient to transplant between different operating system and platform.
- This program can be executed and modified in different compiling environment, such as TrueSTUDIO, SW4STM32 and makefile.
- Compared to the traditional infantry program framework, this program has multiple running tasks which can implement multi-threaded logic as well as blocking tasks.
- There is complete communication protocol between bottom layer and upper layer, which can receive feedback information from different modules of infantry and transmit control signal to corresponding modules.
- Each task, such as mode switch, data exchange and module control, is proceeded independently in internal program in order to add or remove task and function easily.
- Chassis, gimbal, shooting module is coupling based on the internal control task, which is easy to switch mode for different needs.
- The board support package layer (BSP) is based on the HAL library, which mainly offers communication ports and configuration of can, uart, spi, flash and io.
- Data exchange layer is the only place which calls the BSP layer program and exchanges data between applied program and hardware equipment.
- Communication layer is responsible for receiving and transmitting data and control information. Additionally, this layer is capable of packaging and unpacking data including protocol part.
- Data receiving layer transforms the direct data from exchange layer or parsed data from communication layer to feedback and control information.
- Without changing the software framework, mode switch task can implement different user-defined modes based on existing functional module.
- Control task, control of the three structures including the cloud platform, the chassis, and the shooting.
The following is the start sequence diagram for every task.
- Micro Controller Unit (MCU) is STM32F427IIHx and operating frequency is 180 MHz.
- Module communication method is CAN communication and the related equipments are electronic speed controller and gyroscope.
- Universal Asynchronous Receiver/Transmitter (UART) is used to communicated between bottom and upper layer.
- The method of installing Mecanum Wheels is X type.
Data transmitted to upper layer from bottom layer:
- Feedback information part consists of feedback information coming from each module sensors and calculated data from bottom layer.
- Bottom layer status information part consists of running state of all bottom layer equipments and response of bottom layer to corresponding upper layer data.
- Forward data information part consists of all the referee system information and the server user-defined information.
Data received from upper layer to bottom layer:
- Control information part is used to control the three executed mechanism in the bottom layer which are gimbal, chassis and shooting module respectively.
- Configuration information part includes main information to set up structural of the robot such as tread, wheelbase and initial gimbal position and running state of upper layer.
- Forward data information part consists of the data that forwards to referee system through bottom layer and the user-defined information that should be shown in server.