Basic_Frame_TypeC_2023_Omni
Loading...
Searching...
No Matches
apps_types.h
1
2// TODO: Rename to apps_types.hpp
3// TODO: Add namespaces?
4// TODO: Add injectable configuration structs apps.
5#ifndef __APP_TYPES_H
6#define __APP_TYPES_H
7
8#include "attitude_types.h"
9#include "control_types.hpp"
10#include "subsystems_interfaces.h"
11#include "subsystems_types.h"
12#include "uarm_types.hpp"
13
14/* =========================================================================
15 * PUBLIC TYPES
16 * ====================================================================== */
17typedef enum { CTRLER_MODE = 1, PC_MODE } CtrlMode_t;
18
19typedef enum {
20 PATROL_MODE = 1,
21 AUTO_AIM_MODE,
22 AUTO_PILOT_MODE, // full control to mini-pc.
23 IDLE_MODE,
24 // PC_MODE
25} BoardMode_t;
26
27typedef enum {
28 GIMBAL_CENTER =
29 1, // relative angle control using encoder, chassis front always facing yaw center
30 GIMBAL_FOLLOW, // relative angle control using encoder, chassis always moving along gimbal coordinate but not align center.
31 SELF_GYRO, // relative angle control using encoder, chassis keep spinning while gimbal can move freely
32 INDPET_MODE, // chassis ground coordinate, or dummy version of self-gyro mode
33} BoardActMode_t; // should be determined by remore controller
34
35typedef enum { SHOOT_CONT = 1, SHOOT_CEASE } ShootActMode_t;
36enum class ShootState {
37 NORMAL,
38 ANTIJAM,
39};
40
41typedef enum { GYRO_MODE = 1, ENCODE_MODE } GimbalMotorMode_t;
42
43typedef struct {
44 float vx;
45 float vy;
46 float wz;
47} Gimbal_Axis_t; //for remote controller set gimbal dir
48
49/* =========================================================================
50 * CHASIS TYPES
51 * ====================================================================== */
52typedef enum {
53 AUTO_GEAR = 0, //referee system up, auto-adjust chassis spd limit
54 MANUAL_GEAR //referee system down, manual-adjust chassis spd limit
55} ChassisGearMode_t;
56
57typedef enum {
58 NO_GEAR = 0,
59 GEAR_LOW = 500,
60 GEAR_MID = 1000,
61 GEAR_HIGH = 2000
62} ChassisGearValue_t;
63
64typedef struct {
65 uint16_t current;
66 float power;
67 uint16_t buffer_energy;
69
70typedef struct {
78 float vx;
79 float vy;
80 float wz;
81 float max_vx;
82 float max_vy;
83 float max_wz;
84
92 float v_perp;
93
101
102 PID2_t spin_pid; //for Chassis twist(in Gimbal_Center mode)
103
104 uint16_t chassis_gear;
105 ChassisPowerStat_t ref_power_stat;
106 ChassisPowerStat_t local_power_stat;
107
108 BoardMode_t chassis_mode; //chassis mode selection
109 BoardActMode_t chassis_act_mode;
110 ChassisGearMode_t chassis_gear_mode;
111} Chassis_t;
112
113/* =========================================================================
114 * OMNI DRIVE TYPES
115 * ====================================================================== */
116typedef struct {
117 uint32_t stdid;
118 PID2_t f_pid; //first pid handler for single-loop control
119 Ramp sp_ramp;
120 Motor_Feedback_t feedback;
122
123/* =========================================================================
124 * SWERVE DRIVE TYPES
125 * ====================================================================== */
126typedef struct {
127 uint32_t stdid;
128 PID2_t f_pid; //first pid handler for single-loop control
129 Motor_Feedback_t feedback;
130 LK_Motor_Torque_Feedback_t lk_feedback;
131 uint32_t angle;
133
134typedef struct {
135 uint32_t stdid;
136 PID2_t f_pid;
137 Motor_Feedback_t feedback;
139
140typedef struct {
141 uint32_t stdid;
142 LK_Motor_Torque_Feedback_t lk_feedback;
144
145/* =========================================================================
146 * GIMBAL TYPES
147 * ====================================================================== */
148
149typedef struct Gimbal_t {
150 /* gimbal position related */
151 float yaw_target_angle;
152 float yaw_rel_angle;
153 float yaw_ecd_angle;
154 float yaw_imu_angle;
155
156 float pitch_target_angle;
157 float pitch_rel_angle;
158 float pitch_ecd_angle;
159 float pitch_imu_angle;
160
161 int16_t yaw_ecd_center; //center position of the yaw motor by encoder
162 int16_t pitch_ecd_center; //center position of the pitch motor by encoder
163
164 float yaw_imu_center;
165 float yaw_imu_center_cumsum;
166 uint32_t yaw_imu_center_sample_count;
167
169 folp_f_yaw; //first order low pass filter for imu data
171 folp_f_pitch; //first order low pass filter for imu data;
172
173 GimbalMotorMode_t gimbal_motor_mode; //gyro or encoder
174 GimbalMotorMode_t prev_gimbal_motor_mode; //gyro or encoder
175 BoardActMode_t gimbal_act_mode; //gimbal center, gimbal follow, etc
176 BoardActMode_t prev_gimbal_act_mode;
177 BoardMode_t gimbal_mode; //idle(safe) or normal
178} Gimbal_t;
179
180typedef struct {
181 uint32_t stdid;
182 PID2_t f_pid;
183 PID2_t s_pid;
184 Motor_Feedback_t feedback;
186
187typedef struct {
188 uint8_t sample_count;
189 float yaw_samples_cumsum;
190 float pitch_samples_cumsum;
192
193/* =========================================================================
194 * SHOOT TYPES
195 * ====================================================================== */
199
200struct Shoot {
201 float loader_target_rpm;
202 float flywheel_target_rpm;
203
204 EAmmoLidStatus lid_status;
205 ShootActMode_t shoot_act_mode;
206 ShootState shoot_state;
207
208 float stall_duration;
209 float no_stall_duration;
210 float antijam_direction;
211
212 uint32_t loader_delay_counter;
213};
214
216 Motor_CAN_ID_t stdid;
217 PID2_t speed_pid;
218 Motor_Feedback_t feedback;
219};
220
222 Motor_CAN_ID_t stdid;
223 PID2_t speed_pid;
224 Motor_Feedback_t feedback;
225 Ramp sp_ramp;
226};
227
228/* =========================================================================
229 * IMU TYPES
230 * ====================================================================== */
231typedef struct {
233} IMU_Heat_t;
234
235/* =========================================================================
236 * REFEREE SYSTEM TYPES
237 * ====================================================================== */
238typedef struct {
239 frame_header_t header;
240 referee_id_t id;
241 game_status_t game_status_data;
242 game_result_t game_result_data;
243 game_robot_HP_t robot_HP_data;
244 robot_status_t robot_status_data;
245 power_heat_data_t power_heat_data;
246 shoot_data_t shoot_data;
247 ref_ui_info_t ref_info_data;
248
249 uint8_t ref_data[MAX_REF_RX_DATA_LEN]; // MAX_REF_RX_DATA_LEN
250 // rx data
251 uint8_t ref_rx_frame[MAX_REF_BUFFER_SIZE]; // MAX_REF_BUFFER_SIZE
252 uint16_t ref_cmd_id;
253 robot_color_t robot_color;
254
255} Referee_t;
256
257/* =========================================================================
258 * RC TYPES
259 * ====================================================================== */
260typedef struct {
261 /* controll mode selection */
262 Controller ctrl;
263 PC pc;
264 CtrlMode_t control_mode;
265
266 /* status update */
267 BoardMode_t board_mode;
268 BoardActMode_t board_act_mode;
270#endif
Definition apps_types.h:116
Definition apps_types.h:70
float vx
Definition apps_types.h:78
float v_parallel
Definition apps_types.h:91
float gimbal_yaw_rel_angle
Definition apps_types.h:100
Definition apps_types.h:64
Definition subsystems_types.h:503
Definition apps_types.h:221
Definition apps_types.h:43
Definition apps_types.h:187
Definition apps_types.h:180
Definition apps_types.h:149
Definition apps_types.h:231
Definition motor_types.h:48
Definition apps_types.h:215
Definition motor_types.h:41
Definition subsystems_types.h:549
Enhanced PID controller structure with additional parameters.
Definition control_types.hpp:57
Prescaled PID controller for different frequency control loops.
Definition control_types.hpp:123
Ramp generator for smooth transitions.
Definition control_types.hpp:140
Definition apps_types.h:238
Definition apps_types.h:260
shoot task main struct
Definition apps_types.h:200
Definition apps_types.h:134
Definition apps_types.h:140
Definition apps_types.h:126
Definition uarm_types.hpp:14
Definition subsystems_types.h:323
Definition subsystems_types.h:435