Skip to content

Commit 68b301a

Browse files
committed
Finishing touches
1 parent 78245e1 commit 68b301a

3 files changed

Lines changed: 42 additions & 26 deletions

File tree

src/shared/robot_constants.h

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,34 @@ struct RobotConstants
4545
// The angle between y-axis of the robot and the rear wheel axles [degrees]
4646
float back_wheel_angle_deg;
4747

48-
// X position of centre of front wheel
49-
float front_wheel_x_magnitude_meters;
48+
// X position of centre of front right wheel
49+
float fr_x_pos_meters;
5050

51-
// Y position of centre of front wheel
52-
float front_wheel_y_magnitude_meters;
51+
// Y position of centre of front right wheel
52+
float fr_y_pos_meters;
5353

54-
// X position of centre of rear wheel
55-
float back_wheel_x_magnitude_meters;
54+
// X position of centre of front left wheel
55+
float fl_x_pos_meters;
5656

57-
// Y position of centre of rear wheel
58-
float back_wheel_y_magnitude_meters;
57+
// Y position of centre of front left wheel
58+
float fl_y_pos_meters;
5959

60-
// The total width of the entire flat face on the front of the robot [meters]
60+
// X position of centre of back left wheel
61+
float bl_x_pos_meters;
62+
63+
// Y position of centre of back left wheel
64+
float bl_y_pos_meters;
65+
66+
// X position of centre of back right wheel
67+
float br_x_pos_meters;
68+
69+
// Y position of centre of back right wheel
70+
float br_y_pos_meters;
71+
72+
// The total width of the entire flat face on the front of the robot [metres]
6173
float front_of_robot_width_meters;
6274

63-
// The distance from one end of the dribbler to the other [meters]
75+
// The distance from one end of the dribbler to the other [metres]
6476
float dribbler_width_meters;
6577

6678
// Indefinite dribbler mode sets a speed that can be maintained indefinitely [rpm]
@@ -88,10 +100,12 @@ struct RobotConstants
88100
// The maximum angular acceleration achievable by our robots [rad/s^2]
89101
float robot_max_ang_acceleration_rad_per_s_2;
90102

91-
// The radius of the wheel, in meters
103+
// The radius of the wheel, in metres
92104
float wheel_radius_meters;
93105

94-
// Computed by finding sqrt(x^2 + y^2) of front and rear wheels. Both equal
106+
// Distance [metres] from centre of robot to centre of wheel.
107+
// Found by sqrt(x^2 + y^2) of a wheel.
108+
// Front wheel arm = Rear wheel arm. See ASCII image above.
95109
float expected_lever_arm;
96110
};
97111

@@ -108,10 +122,14 @@ constexpr RobotConstants createRobotConstants()
108122
.front_wheel_angle_deg = 32.0f,
109123
.back_wheel_angle_deg = 44.0f,
110124

111-
.front_wheel_x_magnitude_meters = 0.03485f,
112-
.front_wheel_y_magnitude_meters = 0.06632f,
113-
.back_wheel_x_magnitude_meters = 0.04985f,
114-
.back_wheel_y_magnitude_meters = 0.05592f,
125+
.fr_x_pos_meters = 0.03485f,
126+
.fr_y_pos_meters = -0.06632f,
127+
.fl_x_pos_meters = 0.03485f,
128+
.fl_y_pos_meters = 0.06632f,
129+
.bl_x_pos_meters = -0.04985f,
130+
.bl_y_pos_meters = 0.05592f,
131+
.br_x_pos_meters = -0.04985f,
132+
.br_y_pos_meters = -0.05592f,
115133

116134
.front_of_robot_width_meters = 0.11f,
117135
.dribbler_width_meters = 0.07825f,

src/software/physics/euclidean_to_wheel.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ EuclideanToWheel::EuclideanToWheel(const robot_constants::RobotConstants& robot_
2323
const double b_br = (M_PI - t);
2424

2525
// Mapped to the robot frame: +X = Forward, +Y = Left
26-
const double fr_x = robot_constants_.front_wheel_x_magnitude_meters;
27-
const double fr_y = robot_constants_.front_wheel_y_magnitude_meters * -1.0;
28-
const double fl_x = robot_constants_.front_wheel_x_magnitude_meters;
29-
const double fl_y = robot_constants_.front_wheel_y_magnitude_meters;
30-
const double bl_x = robot_constants_.back_wheel_x_magnitude_meters * -1.0;
31-
const double bl_y = robot_constants_.back_wheel_y_magnitude_meters;
32-
const double br_x = robot_constants_.back_wheel_x_magnitude_meters * -1.0;
33-
const double br_y = robot_constants_.back_wheel_y_magnitude_meters * -1.0;
26+
const double fr_x = robot_constants_.fr_x_pos_meters;
27+
const double fr_y = robot_constants_.fr_y_pos_meters;
28+
const double fl_x = robot_constants_.fl_x_pos_meters;
29+
const double fl_y = robot_constants_.fl_y_pos_meters;
30+
const double bl_x = robot_constants_.bl_x_pos_meters;
31+
const double bl_y = robot_constants_.bl_y_pos_meters;
32+
const double br_x = robot_constants_.br_x_pos_meters;
33+
const double br_y = robot_constants_.br_y_pos_meters;
3434

3535

3636
// Assuming that CCW when looking end of shaft into motor is the positive direction.

src/software/physics/euclidean_to_wheel_test.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ TEST_F(EuclideanToWheelTest, test_target_wheel_speeds_positive_w_magnitude)
148148
// Because the wheels are offset, their speed at 1 rad/s equals their
149149
// exact physical lever arm (in meters), NOT the nominal robot_radius.
150150

151-
// Based on the physical offsets, the lever arm evaluates to 0.0749 meters.
152-
153151
EXPECT_NEAR(std::abs(calculated_wheel_speeds[FRONT_RIGHT_WHEEL_SPACE_INDEX]),
154152
expected_lever_arm, EQUALITY_COMPARISON);
155153
EXPECT_NEAR(std::abs(calculated_wheel_speeds[FRONT_LEFT_WHEEL_SPACE_INDEX]),

0 commit comments

Comments
 (0)