-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
There was a problem hiding this 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
src/hydrodynamics.cpp
Outdated
@@ -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); |
There was a problem hiding this comment.
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:
- The expected transform can be left as is and we can modify the rotation (what you've proposed)
- We update the documentation to state that users should provide the
R_I_B
instead ofR_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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Looks good! Thanks for contributing @Eddy-Morgan! |
Changes Made
The rotation matrix
rot
is now transposed before being applied to the force vectorsfg
andfb
, ensuring correct force calculations as per guidelines in Thor Fossen's Handbook of Marine Craft.Associated Issues