Skip to content

Euclidean Debug#3731

Open
sunghyuneun wants to merge 18 commits into
UBC-Thunderbots:masterfrom
sunghyuneun:sunghyuneun/euclidean_debug
Open

Euclidean Debug#3731
sunghyuneun wants to merge 18 commits into
UBC-Thunderbots:masterfrom
sunghyuneun:sunghyuneun/euclidean_debug

Conversation

@sunghyuneun
Copy link
Copy Markdown

@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

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

  • 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 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.

.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
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

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

3 participants