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

fixed restoring forces formulation #4

Merged
merged 2 commits into from
May 26, 2024

Conversation

edxmorgan
Copy link
Contributor

Changes Made

The rotation matrix rot is now transposed before being applied to the force vectors fg and fb, ensuring correct force calculations as per guidelines in Thor Fossen's Handbook of Marine Craft.

Associated Issues

  • Fixes # (issue)

@evan-palmer evan-palmer self-requested a review May 25, 2024 07:44
Copy link
Contributor

@evan-palmer evan-palmer left a comment

Choose a reason for hiding this comment

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

Nice catch @Eddy-Morgan! Thanks for bringing this up and submitting a fix. I apologize for not submitting a review earlier. I didn't get a notification of this PR for some reason. I've left one comment for us to think about

@@ -155,8 +155,8 @@ Eigen::Vector6d RestoringForces::calculateRestoringForcesVector(const Eigen::Mat

Eigen::Vector6d g_rb;

g_rb.topRows(3) = rot * (fg + fb);
g_rb.bottomRows(3) = center_of_gravity_.cross(rot * fg) + center_of_buoyancy_.cross(rot * fb);
g_rb.topRows(3) = rot.transpose() * (fg + fb);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's two potential fixes here:

  1. The expected transform can be left as is and we can modify the rotation (what you've proposed)
  2. We update the documentation to state that users should provide the R_I_B instead of R_B_I

I'm currently leaning toward option 2 here, to simplify the implementation and avoid placing additional requirements on the function, but I could be swayed otherwise. What do you think @Eddy-Morgan? If we opt to modify the code, I think we could clean it up a bit to be:

const Eigen::Matrix3d rot_t = rot.transpose()
g_rb.topRows(3) = rot_t * (fg + fb);
// etc

Copy link
Contributor Author

@edxmorgan edxmorgan May 25, 2024

Choose a reason for hiding this comment

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

Both approaches are viable. However, to maintain adherence to the Fossen formulation, I recommend modifying the function to mirror the transformation method detailed in his book. This adjustment ensure consistency with his established standards and enhance the clarity of the code.

The suggested code snippet looks excellent:

const Eigen::Matrix3d rot_t = rot.transpose();
g_rb.topRows(3) = rot_t * (fg + fb);
// etc

Copy link
Contributor

Choose a reason for hiding this comment

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

Great lets go with that approach then

@evan-palmer
Copy link
Contributor

Looks good! Thanks for contributing @Eddy-Morgan!

@evan-palmer evan-palmer merged commit 3244aa8 into Robotic-Decision-Making-Lab:main May 26, 2024
1 check 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.

2 participants