Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented arm constraint formula #268

Merged
merged 20 commits into from
Feb 5, 2024
Merged

implemented arm constraint formula #268

merged 20 commits into from
Feb 5, 2024

Conversation

sarahfredrickson
Copy link
Contributor

The formatting for the "a" value looks weird but that's what the formatter told me to do. Also will probably have git issues bc I pulled changes to origin before pushing but still says I'm 4 commits behind master.

Copy link
Member

@abhaybd abhaybd left a comment

Choose a reason for hiding this comment

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

overall looks good, just some minor stuff

src/control/PlanarArmController.h Outdated Show resolved Hide resolved
src/control/PlanarArmController.h Outdated Show resolved Hide resolved
Copy link
Member

@abhaybd abhaybd 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, we just need some documentation. 2 things:

  1. Victor will merge his PR soon, so be prepared to resolve those merge conflicts. Basically just move your code into the normalizeEEPosWithinRadius method (I forget the exact name)
  2. You'll need to edit Victor's testcase for our updated logic. Basically it should just be changing the constants in the testcase

src/control/PlanarArmController.h Outdated Show resolved Hide resolved
Copy link
Member

@abhaybd abhaybd left a comment

Choose a reason for hiding this comment

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

Took a look, I understand what the bug you were bumping into was. First, the math had a minor typo, so some parenthesis were missing.

Secondly, it wasn't a bug that you introduced necessarily. Your code was working properly, and normalizing the length to 9.5, but due to floating point rounding errors it was just over 9.5. So when get_setpoint() was called, it tries to normalize it again, but eePos is the same as setpoint, so the numerator becomes 0, so the whole thing becomes nan.

I'd say we could fix this by just adding a very small epsilon to the radius when we're checking if we should normalize. So, in normalizeEEWithinRadius(), change if (eePos.norm() > radius) to if (eePos.norm() > radius + 1e-4), so it will only normalize if we exceed the radius by any perceptible amount.

Note that after fixing this you'll have to fix your testcase, since the correct answer isn't (9.5,0) anymore.

src/control/PlanarArmController.h Outdated Show resolved Hide resolved
src/control/PlanarArmController.h Outdated Show resolved Hide resolved
src/control/PlanarArmController.h Outdated Show resolved Hide resolved
Copy link
Member

@abhaybd abhaybd left a comment

Choose a reason for hiding this comment

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

Functionality-wise looks great! Just some clean-up needed on comments

@abhaybd
Copy link
Member

abhaybd commented Nov 10, 2023

Great job, this looks good! The code looks fine, let's do some hardware testing before merge. Firmware should get ironed out very soon, which will enable this testing. Let's look into sim testing as well

@@ -41,7 +41,7 @@ class PlanarArmController {
// NOTE: currJointPos could extend beyond the safetyFactor, so safety factor
// normalization logic is performed.
set_setpoint(currJointPos);
CHECK_F(safetyFactor > 0.0 && safetyFactor < 1.0);
assert(safetyFactor > 0.0 && safetyFactor < 1.0);
Copy link
Member

Choose a reason for hiding this comment

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

Why the change from CHECK_F to assert? In general we should usually prefer CHECK_F, since loguru has some nicer features, and still runs the checks in release mode.

@sarahfredrickson
Copy link
Contributor Author

Setpoint no longer goes out of bounds and arm doesn't crumple on itself

Copy link
Member

@abhaybd abhaybd left a comment

Choose a reason for hiding this comment

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

Super minor nitpicks

src/control/PlanarArmController.h Outdated Show resolved Hide resolved
src/control/PlanarArmController.h Outdated Show resolved Hide resolved
@sarahfredrickson sarahfredrickson requested review from abhaybd and removed request for imisaacwu February 3, 2024 19:57
Copy link
Member

@abhaybd abhaybd 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! Nice job on this, especially finding and fixing that bug

@abhaybd abhaybd merged commit 8dee7db into master Feb 5, 2024
3 checks passed
@abhaybd abhaybd deleted the improve-arm-constraint branch February 5, 2024 22:59
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.

3 participants