Euclidean Debug#3731
Conversation
Formatting accidentally deleted a requirements_lock This reverts commit 7f7fb0f.
Andrewyx
left a comment
There was a problem hiding this comment.
Nice work! Left some comments
| double fr_x = 0.03485, fr_y = -0.06632; | ||
| double fl_x = 0.03485, fl_y = 0.06632; | ||
| double bl_x = -0.04985, bl_y = 0.05592; | ||
| double br_x = -0.04985, br_y = -0.05592; |
There was a problem hiding this comment.
- We should store these constants in
robot_constants.halongside and also update the diagram for the wheel orientations in the meantime
| euclidean_to_wheel_velocity_D_.transpose(); | ||
| } | ||
|
|
||
| #else |
There was a problem hiding this comment.
- Either delete the legacy code or add a TODO & issue for removing this old code in the future.
| std::cos(b_br), std::sin(b_br), (br_x * std::sin(b_br) - br_y * std::cos(b_br)); | ||
| // clang-format on | ||
|
|
||
| // Calculate Pseudo-inverse dynamically |
There was a problem hiding this comment.
We know all of these values statically, is there some way to compute everything before runtime in this case? Can this entire constructor be constexpr?
| EXPECT_NEAR(std::abs(calculated_wheel_speeds[FRONT_RIGHT_WHEEL_SPACE_INDEX]), | ||
| expected_lever_arm, 0.001); | ||
| EXPECT_NEAR(std::abs(calculated_wheel_speeds[FRONT_LEFT_WHEEL_SPACE_INDEX]), | ||
| expected_lever_arm, 0.001); | ||
| EXPECT_NEAR(std::abs(calculated_wheel_speeds[BACK_LEFT_WHEEL_SPACE_INDEX]), | ||
| expected_lever_arm, 0.001); | ||
| EXPECT_NEAR(std::abs(calculated_wheel_speeds[BACK_RIGHT_WHEEL_SPACE_INDEX]), | ||
| expected_lever_arm, 0.001); |
There was a problem hiding this comment.
|
|
||
| // Because the wheels are offset, their speed at -1 rad/s equals their | ||
| // exact physical lever arm (in meters) multiplied by the negative velocity. | ||
| double expected_lever_arm = 0.0749; |
| auto p = robot_constants_.front_wheel_angle_deg * M_PI / 180.; | ||
| auto t = robot_constants_.back_wheel_angle_deg * M_PI / 180.; |
There was a problem hiding this comment.
No need for auto here, and also statically known values
Andrewyx
left a comment
There was a problem hiding this comment.
Almost there, left some comments!
| // X position of centre of front wheel | ||
| float front_wheel_x_mag; | ||
|
|
||
| // Y position of centre of front wheel | ||
| float front_wheel_y_mag; | ||
|
|
||
| // X position of centre of rear wheel | ||
| float back_wheel_x_mag; | ||
|
|
||
| // Y position of centre of rear wheel | ||
| float back_wheel_y_mag; | ||
|
|
There was a problem hiding this comment.
what is mag? Note that we should ideally keep units in the name too e.g. front_wheel_x_meters -> // X position of centre of front wheel relative to the center of the robot.
| .wheel_radius_meters = 0.03f}; | ||
| .wheel_radius_meters = 0.03f, | ||
|
|
||
| .expected_lever_arm = 0.0749f}; |
There was a problem hiding this comment.
How is this computed? Also can you label this somewhere in the ASCII diagram or something to better explain what this value points to?
StarrryNight
left a comment
There was a problem hiding this comment.
nice work. Left some comment on code quality and inversing matrices.
Description
Rewrote the inverse kinematics logic for increased readability and correctness.
Revised wrong tests to be correct.
Testing Done
Also edited
euclidean_to_wheel_test.cpp, and passed all tests in it.Resolved Issues
Fixes #3722
Length Justification and Key Files to Review
Review Checklist
It is the reviewers responsibility to also make sure every item here has been covered
.hfile) should have a javadoc style comment at the start of them. For examples, see the functions defined inthunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.TODO(or similar) statements should either be completed or associated with a github issue