Skip to content

Euclidean Debug#3731

Merged
sunghyuneun merged 21 commits into
UBC-Thunderbots:masterfrom
sunghyuneun:sunghyuneun/euclidean_debug
May 29, 2026
Merged

Euclidean Debug#3731
sunghyuneun merged 21 commits into
UBC-Thunderbots:masterfrom
sunghyuneun:sunghyuneun/euclidean_debug

Conversation

@sunghyuneun
Copy link
Copy Markdown
Contributor

@sunghyuneun sunghyuneun commented May 22, 2026

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

Resolves #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

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

sunghyuneun added a commit that referenced this pull request May 22, 2026
pre-commit-ci-lite Bot and others added 2 commits May 22, 2026 03:47
Formatting accidentally deleted a requirements_lock
This reverts commit 7f7fb0f.
@sunghyuneun sunghyuneun self-assigned this May 22, 2026
Copy link
Copy Markdown
Contributor

@Andrewyx Andrewyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Left some comments

Comment on lines +27 to +30
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;
Copy link
Copy Markdown
Contributor

@Andrewyx Andrewyx May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We should store these constants in robot_constants.h alongside and also update the diagram for the wheel orientations in the meantime

euclidean_to_wheel_velocity_D_.transpose();
}

#else
Copy link
Copy Markdown
Contributor

@Andrewyx Andrewyx May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment on lines +173 to +180
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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// 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;
Copy link
Copy Markdown
Contributor

@Andrewyx Andrewyx May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Magic number

Comment on lines +16 to +17
auto p = robot_constants_.front_wheel_angle_deg * M_PI / 180.;
auto t = robot_constants_.back_wheel_angle_deg * M_PI / 180.;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for auto here, and also statically known values

williamckha pushed a commit that referenced this pull request May 23, 2026
@sunghyuneun sunghyuneun requested a review from Andrewyx May 23, 2026 04:19
Copy link
Copy Markdown
Contributor

@Andrewyx Andrewyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, left some comments!

Comment thread src/shared/robot_constants.h Outdated
Comment on lines +44 to +55
// 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should replace magnitude with pos, because I think position is more specific than just magnitude.

.wheel_radius_meters = 0.03f};
.wheel_radius_meters = 0.03f,

.expected_lever_arm = 0.0749f};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this computed? Also can you label this somewhere in the ASCII diagram or something to better explain what this value points to?

@sunghyuneun sunghyuneun requested a review from Andrewyx May 23, 2026 23:16
Copy link
Copy Markdown
Contributor

@StarrryNight StarrryNight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work. Left some comment on code quality and inversing matrices.

Comment thread src/software/physics/euclidean_to_wheel.cpp Outdated
Comment thread src/software/physics/euclidean_to_wheel.cpp Outdated
Comment thread src/software/physics/euclidean_to_wheel.cpp Outdated
StarrryNight
StarrryNight previously approved these changes May 24, 2026
Copy link
Copy Markdown
Contributor

@StarrryNight StarrryNight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread src/shared/robot_constants.h Outdated
Comment on lines +111 to +115
.front_wheel_x_magnitude_meters = 0.03485f,
.front_wheel_y_magnitude_meters = 0.06632f,
.back_wheel_x_magnitude_meters = 0.04985f,
.back_wheel_y_magnitude_meters = 0.05592f,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice placement

Comment thread src/shared/robot_constants.h Outdated
Comment on lines 94 to 96
// Computed by finding sqrt(x^2 + y^2) of front and rear wheels. Both equal
float expected_lever_arm;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps link some sort of graphic or wiki link here? I am still a bit confused as to what this is referring to wrt the geometry of the robot

@Andrewyx
Copy link
Copy Markdown
Contributor

Nice work! This looks basically done, I left two very minor comments regarding docs, but otherwise, I think this is ready to go 🚀

@sunghyuneun sunghyuneun requested a review from Andrewyx May 26, 2026 21:27
Copy link
Copy Markdown
Contributor

@Andrewyx Andrewyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work! 💯

Copy link
Copy Markdown
Contributor

@GrayHoang GrayHoang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, good work on this

Comment on lines +23 to +40
// FRONT OF ROBOT
// | ▲ X-Axis
// | / -------+--------- \ eric
// |A / .' │ '. \ ◄─── Front wheel
// | /.' │ .'.\ grayson
// |// │ . \\ samuel
// ; │ . Lever ;
// | │ . Arm |
// ◄─────┼──────────────┼ |
// Y-Axis| |
// ; ;
// |\\ //
// | \'. .'/
// |B \ '. .' / ◄─── Back wheel
// | \ '-. _.-' /
// | ''------''

// clang-format on
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ASCII art is ass-key. Make better? :)

float robot_max_ang_acceleration_rad_per_s_2;

// The radius of the wheel, in meters
// The radius of the wheel, in metres
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alr who's french

Copy link
Copy Markdown
Contributor Author

@sunghyuneun sunghyuneun May 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHAT THE FUCK IS A MILE

@sunghyuneun sunghyuneun merged commit b84795f into UBC-Thunderbots:master May 29, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug EuclidianToWheel Inverse Kinematics

4 participants