-
Notifications
You must be signed in to change notification settings - Fork 277
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
Lighter Than Air Dynamics Systems #2241
Lighter Than Air Dynamics Systems #2241
Conversation
Hi, I tried to get this PR as ready as possible for merging (reading the contribution docs and implementing the requirements), and have reached an unproductive state where I need some feedback to take this forward. So any comments, and or further requirements to implement would help alot. I am still thinking of more tests to add to ensure any future additions will keep the core dynamics of LTA vehicles unchanged (except if some new modelling arises), since the system is unstable when having a velocity. |
10a6d18
to
9e6800d
Compare
src/systems/lighter_than_air_dynamics/LighterThanAirDynamics.cc
Outdated
Show resolved
Hide resolved
src/systems/lighter_than_air_dynamics/LighterThanAirDynamics.cc
Outdated
Show resolved
Hide resolved
src/systems/lighter_than_air_dynamics/LighterThanAirDynamics.cc
Outdated
Show resolved
Hide resolved
src/systems/lighter_than_air_dynamics/LighterThanAirDynamics.cc
Outdated
Show resolved
Hide resolved
src/systems/lighter_than_air_dynamics/LighterThanAirDynamics.cc
Outdated
Show resolved
Hide resolved
src/systems/lighter_than_air_dynamics/LighterThanAirDynamics.hh
Outdated
Show resolved
Hide resolved
math::Matrix3d m11, math::Matrix3d m12, | ||
math::Matrix3d m21, math::Matrix3d m22); | ||
|
||
public: math::Vector3d added_mass_force(math::Vector3d lin_vel, |
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.
add docs
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.
resolved
*/ | ||
|
||
#include <gtest/gtest.h> | ||
|
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.
include vector, string
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.
resolved
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.
Apart from @ahcorde's style comments, there are some functionality related things which need minor changes that I've highlighted. Also a file in the examples/
folder would be nice as end users who install binaries don't get the unit tests!
src/systems/lighter_than_air_dynamics/LighterThanAirDynamics.cc
Outdated
Show resolved
Hide resolved
} | ||
|
||
this->dataPtr->airDensity = SdfParamDouble(_sdf, "airDensity", | ||
SdfParamDouble(_sdf, "air_density", 998) |
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.
Just keep air_density
.
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.
resolved
Can you fix your commit sign-off. Instructions are here |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## gz-sim7 #2241 +/- ##
===========================================
- Coverage 64.88% 64.82% -0.06%
===========================================
Files 360 358 -2
Lines 29448 29337 -111
===========================================
- Hits 19108 19019 -89
+ Misses 10340 10318 -22 ☔ View full report in Codecov by Sentry. |
4bfa7d1
to
ea20b0d
Compare
I hope its okay that I squashed and force pushed, I didnt intent to remove the co-author commits, but rather keep the history much more clearer. |
No worries. You have to force push for DCO so 🤷 |
6092565
to
78a99a2
Compare
Somehow missed all the other style suggestions. |
Anything else todo here? |
4c468db
to
bfd3d26
Compare
-visc_normal_y_); | ||
|
||
// Added Mass forces & Torques | ||
auto force_added_mass = -1.0 * this->added_mass_force(linear_vel, |
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.
IIUC, if you use the SDF <fluid_added_mass>
tags, the added mass gets added by the physics engine. Theres no need to add the added mass terms here. I think @azeey, @mabelzhang or @quarkytale may be able to elaborate more on that.
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.
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.
Thanks for this!
Referring to the paper, on which I have based the dynamics, the added mass effects should be incorporated in two places: (1) In the linear body acceleration and angular body acceleration, and then (2) in the coupling of the linear and angular velocities. I have added picture from the paper.
From my understanding, the physics engine incorporates it into the former (the acceleration terms). I have just added the forces and torques which is created by the added mass due to the coupling of the linear and angular velocities. I hope this make sense.
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.
Would be awesome if someone could provide insight into the backend of the physics engine and how it incorporate the added mass effects. From my understanding, it would only compute the first term in equation (6) and not both terms.
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.
Yep! You are right. The physics engine will only include added mass in the acceleration term. Any interaction due to velocities would have to be done outside of the engine.
<gravity>0 0 -9.81</gravity> | ||
|
||
<plugin | ||
filename="ignition-gazebo-physics-system" |
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.
For forward compatibility use gz-sim-physics-system
instead.
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.
resolved
auto pose = baseLink.WorldPose(_ecm); | ||
// Since we are transforming angular and linear velocity we only care about | ||
// rotation. Also this is where we apply the effects of current to the link | ||
auto linear_vel = pose->Rot().Inverse() * (linearVelocity->Data()); |
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.
please use camelCase
for all variable names. See https://gazebosim.org/docs/harmonic/contributing#style-guides
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.
Will do!
I see there isnt really a style requirement for function parameters. Should I make my function parameters also camelCase?
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.
All variable names and function names use camelCase
-visc_normal_y_); | ||
|
||
// Added Mass forces & Torques | ||
auto force_added_mass = -1.0 * this->added_mass_force(linear_vel, |
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.
bfd3d26
to
bf74047
Compare
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.
Sorry for the long feedback time. The plugin itself looks good to me. However the test does not seem to check for any velocity/positon values. This means we may not be able to catch regressions.
EXPECT_EQ(2000u, bodyVels.size()); | ||
|
||
EXPECT_NE(model.Entity(), kNullEntity); | ||
EXPECT_NE(body.Entity(), kNullEntity); |
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.
Sorry for the incredibly long feedback time. But this test does not seem to be checking anything about the behaviour of the dynamics. It'll be hard to spot regressions if we dont test that.
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 agree that the tests are limited which I have implemented.
Will have a look at this more closely!
Thanks for the feedback.
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.
What we do for hydrodynamics is push a model and then try to measure its terminal velocity. Perhaps this is an approach which you want to adopt?
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.
Added tests to check the instability of pitch and yaw.
bf74047
to
07207f9
Compare
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.
Thanks for iterating on this PR. LGTM!
Thank you for your review and follow ups! Its much appreciated! |
Can you try merging the base branch once it seems the ABI checker is not happy. |
Rebased on top of gz-sim7? |
Yep. |
copy of Hydrodynamics folder, and rename to lta Renamed to LighterThanAirDynamics - Added some initial private data - Requires still alot of cleanup some initial dynamics added Building sucessfully with some warnings Running test to determine succesfull Spawning successfull ran tests, but still debugging alot Added additional debug messages Protection for zero division - Test running sucessfully with adding forces and torques, but requires more extensive testing and validation Improved Documentation,some more work on tests Improve documentation to include math Silver bullet model withs its coefficients small documentation update Code style updates. wip Style checks completed Small correction to dynamics Added Mass Force and Torques included - Link class now provides the FluidAddedMassMatrix Removed Munk from added mass & correct coeff names Signed-off-by: henrykotze <[email protected]> update year Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> update format suggestion Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> update format suggestion in added_mass_force Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> format fix: function header Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> update formatting Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> Update src/systems/lighter_than_air_dynamics/LighterThanAirDynamics.hh Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> update year Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> Functionality updates and style updates Signed-off-by: henrykotze <[email protected]> Example added for Lighter-than-air envelope Signed-off-by: henrykotze <[email protected]> Use numerical limits to query precision of types Signed-off-by: henrykotze <[email protected]> fix integration path for sdf file Signed-off-by: henrykotze <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> update year Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> style format update Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Henry Kotzé <[email protected]> remove commented wind component Signed-off-by: henrykotze <[email protected]> fix whitespace error from pre-commit Signed-off-by: henrykotze <[email protected]> codecheck fix conform to style guide requirements wip: test with forces acting on it working tests implementing, cleanup required cleanup and formatting revert back to original example more revert to original
07207f9
to
3705ccd
Compare
🎉 New feature
Summary
This adds the dynamics to simulate a lighter-than-air vehicle such as blimps/airships. The modelling is based on [1] and [2]. Previously we added an airship-dynamics-plugin to Gazebo-Classic for PX4 Gazebo SITL , but we suffered simulation instability similar to that of the underwater-vehicles since Gazebo-Classic could not simulate the Added Mass dynamics.
This PR brings that airship-dynamics-plugin to Gazebo which supports the Added Mass dynamics.
Furthermore, I have extended, the Link class to provide access to the AddedMassMatrix, to allow the lighter-than-air system to easily access this matrix.
The code is somewhat based of the Hydrodynamics system.
I have an STL file which I can contribute, which is an envelope from Wind Reiter, and the coefficients in the integrations test is for this envelope model.
Citations
[1] Li, Y., & Nahon, M. (2007). Modeling and simulation of airship dynamics. Journal of Guidance, Control, and Dynamics, 30(6), 1691–1700.
[2] Li, Y., Nahon, M., & Sharf, I. (2011). Airship dynamics modeling: A literature review. Progress in Aerospace Sciences, 47(3), 217–239.
Test it
I have written a small integration test to check whether the lighter-than-air system is loaded correctly and stable.
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸