-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathrobot_constants.h
More file actions
218 lines (167 loc) · 7.59 KB
/
Copy pathrobot_constants.h
File metadata and controls
218 lines (167 loc) · 7.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#pragma once
#include "shared/constants.h"
namespace robot_constants
{
struct RobotConstants
{
// The radius of the robot [m]
float robot_radius_m;
// clang-format off
// The front_wheel_angle_deg and back_wheel_angle_deg are measured as absolute
// angles from the robot's y-axis to each wheel axle.
//
// In the ASCII diagram below:
// - front_wheel_angle_deg = A
// - back_wheel_angle_deg = B
// The angles are assumed to be symmetric for the left and right sides of the robot.
//
// FRONT OF ROBOT
// | ▲ X-Axis
// | / -------+--------- \ eric
// |A / .' │ '. \ ◄─── Front wheel
// | /.' │ .'.\ grayson
// |// │ . \\ samuel
// ; │ . Lever ;
// | │ . Arm |
// ◄─────┼──────────────┼ |
// Y-Axis| |
// ; ;
// |\\ //
// | \'. .'/
// |B \ '. .' / ◄─── Back wheel
// | \ '-. _.-' /
// | ''------''
// clang-format on
// The angle between y-axis of the robot and the front wheel axles [degrees]
float front_wheel_angle_deg;
// The angle between y-axis of the robot and the rear wheel axles [degrees]
float back_wheel_angle_deg;
// X position of centre of front right wheel
float fr_x_pos_meters;
// Y position of centre of front right wheel
float fr_y_pos_meters;
// X position of centre of front left wheel
float fl_x_pos_meters;
// Y position of centre of front left wheel
float fl_y_pos_meters;
// X position of centre of back left wheel
float bl_x_pos_meters;
// Y position of centre of back left wheel
float bl_y_pos_meters;
// X position of centre of back right wheel
float br_x_pos_meters;
// Y position of centre of back right wheel
float br_y_pos_meters;
// The total width of the entire flat face on the front of the robot [metres]
float front_of_robot_width_meters;
// The distance from one end of the dribbler to the other [metres]
float dribbler_width_meters;
// Indefinite dribbler mode sets a speed that can be maintained indefinitely [rpm]
int indefinite_dribbler_speed_rpm;
// Max force dribbler mode sets the speed that applies the maximum amount of force on
// the ball [rpm]
int max_force_dribbler_speed_rpm;
// The maximum acceleration achievable by our motors [m/s^2]
float motor_max_acceleration_m_per_s_2;
// The maximum speed achievable by our robots, in metres per second [m/s]
float robot_max_speed_m_per_s;
// The maximum speed that the trajectory planner is allowed to command the robot to
// move at, while still leaving headroom for the PID to apply correction on lag. [m/s]
float robot_trajectory_max_speed_m_per_s;
// The maximum acceleration achievable by our robots [m/s^2]
float robot_max_acceleration_m_per_s_2;
// The maximum deceleration (break) achievable by our robots [m/s^2]
float robot_max_deceleration_m_per_s_2;
// The maximum angular speed achievable by our robots [rad/s]
float robot_max_ang_speed_rad_per_s;
// The maximum speed that the trajectory planner is allowed to command the robot to
// move at, while still leaving headroom for the PID to apply correction on lag.
// [rad/s]
float robot_trajectory_max_ang_speed_rad_per_s;
// The maximum angular acceleration achievable by our robots [rad/s^2]
float robot_max_ang_acceleration_rad_per_s_2;
// The radius of the wheel, in metres
float wheel_radius_meters;
// Distance [metres] from centre of robot to centre of wheel.
// Found by sqrt(x^2 + y^2) of a wheel.
// Front wheel arm = Rear wheel arm. See ASCII image above.
float expected_lever_arm;
// Various variances for the robot localizer Kalman filter
float kalman_process_noise_variance_rad_per_s_4;
float kalman_vision_noise_variance_rad_2;
float kalman_motor_sensor_noise_variance_rad_per_s_2;
};
/**
* Creates robot constants for the robot
*
* @return robot constants for the robot
*/
#if CHECK_VERSION(2026)
constexpr RobotConstants createRobotConstants()
{
return {
.robot_radius_m = static_cast<float>(ROBOT_MAX_RADIUS_METERS),
.front_wheel_angle_deg = 32.0f,
.back_wheel_angle_deg = 44.0f,
.fr_x_pos_meters = 0.03485f,
.fr_y_pos_meters = -0.06632f,
.fl_x_pos_meters = 0.03485f,
.fl_y_pos_meters = 0.06632f,
.bl_x_pos_meters = -0.04985f,
.bl_y_pos_meters = 0.05592f,
.br_x_pos_meters = -0.04985f,
.br_y_pos_meters = -0.05592f,
.front_of_robot_width_meters = 0.11f,
.dribbler_width_meters = 0.07825f,
// Dribbler speeds are negative as that is the direction that sucks the ball in
.indefinite_dribbler_speed_rpm = -10000,
.max_force_dribbler_speed_rpm = -12000,
// Motor constant
.motor_max_acceleration_m_per_s_2 = 2.0f,
// Robot's linear movement constants
.robot_max_speed_m_per_s = 3.0f,
.robot_trajectory_max_speed_m_per_s = 2.5f,
.robot_max_acceleration_m_per_s_2 = 3.0f,
.robot_max_deceleration_m_per_s_2 = 2.0f,
// Robot's angular movement constants
.robot_max_ang_speed_rad_per_s = 10.0f,
.robot_trajectory_max_ang_speed_rad_per_s = 7.0f,
.robot_max_ang_acceleration_rad_per_s_2 = 30.0f,
.wheel_radius_meters = 0.03f,
.expected_lever_arm = 0.0749f,
// Kalman filter variances for robot localizer
.kalman_process_noise_variance_rad_per_s_4 = 1.0f,
.kalman_vision_noise_variance_rad_2 = 0.01f * 0.01f,
.kalman_motor_sensor_noise_variance_rad_per_s_2 = 0.5f};
}
#elif CHECK_VERSION(2021)
constexpr RobotConstants createRobotConstants()
{
return {
.robot_radius_m = static_cast<float>(ROBOT_MAX_RADIUS_METERS),
.front_wheel_angle_deg = 32.06f,
.back_wheel_angle_deg = 46.04f,
.front_of_robot_width_meters = 0.11f,
.dribbler_width_meters = 0.07825f,
// Dribbler speeds are negative as that is the direction that sucks the ball in
.indefinite_dribbler_speed_rpm = -10000,
.max_force_dribbler_speed_rpm = -12000,
// Motor constant
.motor_max_acceleration_m_per_s_2 = 4.5f,
// Robot's linear movement constants
.robot_max_speed_m_per_s = 3.000f,
.robot_trajectory_max_speed_m_per_s = 3.000f,
.robot_max_acceleration_m_per_s_2 = 3.0f,
.robot_max_deceleration_m_per_s_2 = 3.0f,
// Robot's angular movement constants
.robot_max_ang_speed_rad_per_s = 10.0f,
.robot_trajectory_max_ang_speed_rad_per_s = 7.0f,
.robot_max_ang_acceleration_rad_per_s_2 = 30.0f,
.wheel_radius_meters = 0.03f,
// Kalman filter variances for robot localizer
.kalman_process_noise_variance_rad_per_s_4 = 0.5f,
.kalman_vision_noise_variance_rad_2 = 0.01f * 0.01f,
.kalman_motor_sensor_noise_variance_rad_per_s_2 = 0.5f * 0.5f};
}
#endif
} // namespace robot_constants