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

Porting Advanced Lift Drag Plugin to Gazebo #2185

Merged
merged 17 commits into from Nov 2, 2023

Conversation

frede791
Copy link
Contributor

@frede791 frede791 commented Oct 2, 2023

🎉 New Feature

Summary

This is a plugin that ports the behaviour of the advanced lift drag plugin that was present in Gazebo Classic to Gazebo. The physics implementation have not changed, but the plugin has been adapted to work with the entity component system. Primary modeling differences in the advanced_lift_drag plugin from the original liftdrag_plugin include:

  • quadratic formulation for drag
  • side force
  • flat-plate post-stall model
  • aerodynamic moments about all three axes
  • body rate stability derivatives
  • actuator control derivatives

The objective is to provide a more accurate model of a wing than what is provided in the basic lift drag plugin.

Test it

Another PR is currently being pursued to also port the advanced plane to PX4. This should provide the ability to test the plugin on the already existing vehicles. Alternatively, one can also write their own model and use AVL to figure out the necessary parameters.

This plugin originates from a custom plugin from PX4 that was written for gazebo classic. It should be included in Gazebo in order to provide compatability with the advanced plane model in PX4. The original source code comes from https://github.com/PX4/PX4-SITL_gazebo-classic/blob/20ded0757b4f2cb362833538716caf1e938b162a/src/liftdrag_plugin/advanced_liftdrag_plugin.cpp and was written by @karthik-s-feather.

Port < Gazebo Classic advanced_lift_drag> to < Gazebo advanced_lift_drag>

Branch comparison: https://github.com/frede791/gz-sim/blob/gz-sim7/src/systems/advanced_lift_drag/AdvancedLiftDrag.cc ... https://github.com/PX4/PX4-SITL_gazebo-classic/blob/20ded0757b4f2cb362833538716caf1e938b162a/src/liftdrag_plugin/advanced_liftdrag_plugin.cpp

ahcorde
ahcorde previously requested changes Oct 2, 2023
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.hh Outdated Show resolved Hide resolved
@frede791
Copy link
Contributor Author

frede791 commented Oct 2, 2023

I have updated the PR description to include more detail regarding the PX4 origin and what is the plugin is aiming to achieve and also addressed the requested changes.

Signed-off-by: frederik <frederik@auterion.com>
Signed-off-by: frederik <frederik@auterion.com>
Signed-off-by: frederik <frederik@auterion.com>
@arjo129
Copy link
Contributor

arjo129 commented Oct 3, 2023

Any chance we could get a minimal example or test?

@frede791
Copy link
Contributor Author

frede791 commented Oct 3, 2023

Here is a flight log of a test flight I conducted with the advanced plane and the advanced lift drag plugin:
https://review.px4.io/plot_app?log=78a4f0e2-80f5-4165-96da-c18c544c9444
Does this suffice?

@frede791
Copy link
Contributor Author

frede791 commented Oct 3, 2023

Here is an additional flight, which also includes a landing.
https://review.px4.io/plot_app?log=e84b3567-6bf8-414b-bf46-717b30210427

Signed-off-by: frederik <frederik@auterion.com>
@arjo129
Copy link
Contributor

arjo129 commented Oct 5, 2023

Hi @frede791 ,
By example I mean a place where it is used so end users can see how to use it. For instance the DetachableJoint has the following example:

Similarly the original liftdrag plugin has the following example and tests:

It is important to include such minimal examples and tests so that when we change things we can catch regressions. It also allows us as reviewers to quickly test things otherwise I would be approving this blindly as many of us don't necessarily work with Pixhawk on a day-to-day basis.

If you can;t write a test, at least an example file or instructions to test would be nice. Perhaps basing it off the PR you created for the pixhawk community would be nice.

… codecheck

Signed-off-by: frederik <frederik@auterion.com>
@frede791
Copy link
Contributor Author

frede791 commented Oct 6, 2023

I've updated the formatting of the plugin files to conform with codecheck. I also included an example file that was adapted from the PX4 advanced plane and used a similar layout as in the lift drag plugin example.

@frede791
Copy link
Contributor Author

Anything else that needs to be addressed here? @ahcorde, @arjo129

@frede791
Copy link
Contributor Author

frede791 commented Oct 12, 2023

Since generating this plugin requires a lot of parameters taken from AVL, I have written a standalone tool that can automate this process by only requiring some physical dimensions of the vehicle. At the moment, I am planning on placing this within the PX4 codebase:
PX4/PX4-Autopilot#22204
However, it might make sense to provide this as an independent tool for Gazebo users?

@arjo129
Copy link
Contributor

arjo129 commented Oct 21, 2023

Apologies, I've been very busy the past few weeks and hence have not had the time to look at the tool. Perhaps you can present this tool at a simulation meeting or an aerial working group meeting. I'm not sure we should include it in here. Perhaps a tutorial linking to the tool you wrote would be good. 😄

@frede791
Copy link
Contributor Author

The README for the tool I created is pretty self-contained but it would perhaps make sense to add in a README here which links to the tool.

@arjo129
Copy link
Contributor

arjo129 commented Oct 22, 2023 via email

Signed-off-by: frederik <frederik@auterion.com>
Signed-off-by: frederik <frederik@auterion.com>
Signed-off-by: frederik <frederik@auterion.com>
@frede791
Copy link
Contributor Author

@arjo129 I've added in a short section in the header file that links to the tool itself. Also fixed some linting issues (that make codecheck weirdly enough didn't seem to pick up on). Let me know if there is anything else that needs improving.

Copy link
Contributor

@arjo129 arjo129 left a comment

Choose a reason for hiding this comment

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

This is getting closer however, I'm unable to run the examples as the mesh paths are hard coded. Consider uploading the plane model to fuel.

src/systems/advanced_lift_drag/AdvancedLiftDrag.hh Outdated Show resolved Hide resolved
examples/worlds/advanced_lift_drag_system.sdf Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
examples/worlds/advanced_lift_drag_system.sdf Outdated Show resolved Hide resolved
Signed-off-by: frederik <frederik@auterion.com>
Signed-off-by: frederik <frederik@auterion.com>
Signed-off-by: frederik <frederik@auterion.com>
@frede791
Copy link
Contributor Author

@arjo129 Addressed your issues and uploaded the plane to Gazebo fuel.

@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Merging #2185 (1755745) into gz-sim7 (5dbbd1b) will decrease coverage by 0.25%.
Report is 7 commits behind head on gz-sim7.
The diff coverage is 38.67%.

❗ Current head 1755745 differs from pull request most recent head c490b97. Consider uploading reports for the commit c490b97 to get more accurate results

@@             Coverage Diff             @@
##           gz-sim7    #2185      +/-   ##
===========================================
- Coverage    65.00%   64.75%   -0.25%     
===========================================
  Files          356      357       +1     
  Lines        28932    29145     +213     
===========================================
+ Hits         18808    18874      +66     
- Misses       10124    10271     +147     
Files Coverage Δ
src/systems/lift_drag/LiftDrag.hh 100.00% <ø> (ø)
src/systems/lift_drag/LiftDrag.cc 64.36% <86.66%> (+1.29%) ⬆️
src/systems/sensors/Sensors.cc 63.14% <88.00%> (+0.46%) ⬆️
.../systems/environment_preload/EnvironmentPreload.cc 64.74% <61.61%> (-4.95%) ⬇️
...c/systems/environment_preload/VisualizationTool.cc 2.56% <2.56%> (ø)

... and 3 files with indirect coverage changes

Signed-off-by: frederik <frederik@auterion.com>
Copy link
Contributor

@arjo129 arjo129 left a comment

Choose a reason for hiding this comment

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

There are still some things that aren't quite right.

src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
Signed-off-by: frederik <frederik@auterion.com>
Copy link
Contributor

@arjo129 arjo129 left a comment

Choose a reason for hiding this comment

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

I don't think you understood my point. The plane starts at zero velocity. You should not invalidate the config because of that. I recommend you try actually running the example rather than have me constantly correct your code.

src/systems/advanced_lift_drag/AdvancedLiftDrag.cc Outdated Show resolved Hide resolved
Signed-off-by: frederik <frederik@auterion.com>
@frede791
Copy link
Contributor Author

frede791 commented Nov 1, 2023

I added an additional variable position that defines the starting position of the vehicle where a speed of 0 is acceptable. Passes codecheck and the example plane does not throw an error.

@arjo129
Copy link
Contributor

arjo129 commented Nov 1, 2023

I'd argue that you could have more than one position where zero speed is acceptable. Say you are testing a delivery scenario. Its possible that you want your plane to take off and land multiple times. I think all you need to do is not apply any force if velocity is zero. This is consistent with real world dynamics as you can't have lift or drag unless relative airspeed is zero.

@frede791
Copy link
Contributor Author

frede791 commented Nov 1, 2023

Yes that is a valid point, so you would just return without throwing an error.

@arjo129
Copy link
Contributor

arjo129 commented Nov 1, 2023 via email

Signed-off-by: frederik <frederik@auterion.com>
@frede791
Copy link
Contributor Author

frede791 commented Nov 1, 2023

removed the position variable and let the update function return without throwing an error.

Copy link
Contributor

@arjo129 arjo129 left a comment

Choose a reason for hiding this comment

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

I just tried it. It looks great. I just have one small suggestion to improve the documentation in the example. Once you incorporate it, this looks good to me! Thanks for iterating on this PR.

examples/worlds/advanced_lift_drag_system.sdf Show resolved Hide resolved
Co-authored-by: Arjo Chakravarty <arjo129@gmail.com>
Signed-off-by: Frederik Markus <80588263+frede791@users.noreply.github.com>
Signed-off-by: Arjo Chakravarty <arjo129@gmail.com>
@arjo129 arjo129 enabled auto-merge (squash) November 1, 2023 23:14
@arjo129 arjo129 dismissed ahcorde’s stale review November 2, 2023 04:35

Points have been addressed. Review is stale.

@arjo129 arjo129 merged commit b8d1679 into gazebosim:gz-sim7 Nov 2, 2023
9 of 10 checks passed
@scpeters scpeters mentioned this pull request Jan 17, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants