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

Tutorial for closed-Loop Simulation with SHARPy as a hardware-in-the-loop system #240

Merged
merged 35 commits into from Jun 30, 2023

Conversation

sduess
Copy link
Collaborator

@sduess sduess commented Jun 23, 2023

Hey team,

I have created a tutorial to familiarize users with the UDP capabilities of SHARPy, in particular the application of an external controller to a dynamic nonlinear aeroelastic simulation. As a simple example, the gust-induced wingtip deflection of the Pazy wing is reduced by an aileron deflection controlled by an external P controller. For the design of the controller, the tutorial also covers the generation of a linear reduced order model (ROM) for a given SHARPy model and an example of the next steps necessary to use this ROM for linear open-loop and closed-loop simulations on common platforms such as Matlab/SIMULINK.

Changes made are mostly adding the Jupyter notebook and other files needed for the tutorial. The documentation has been updated to include the download links of this example and for the tutorial to show up in the menu bar. Minor adaptations have been made in the template for flying wing models to specify the aileron type (necessary for closed-loop simulation) and initial aileron deflections, as well as using different indices for symmetric ailerons due to issue #193.

Looking forward to your feedback!

Best,
Steffi

sduess added 19 commits June 6, 2023 14:19
- add cs type to allow deflection control via external controller
- use different flap ids for right and left wing, because in the linear model they deflect in different directions 
- add hinge coord to avoid failure in linearization
- add input settings for number of control surfaces instead of getting number from number of inputted intital deflection values
- causes problem with iostream of jupyter notebook
- export simulink model to be accesible from older matlab versions too (2021a)
- also includes minor documentation adjustments
@sduess sduess requested a review from rafapalacios June 23, 2023 01:46
- causes error in unittest in pazy tests due to renaming and type change
@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2023

Codecov Report

Merging #240 (fffe2c0) into main (d9ca1b6) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #240      +/-   ##
==========================================
- Coverage   67.20%   67.20%   -0.01%     
==========================================
  Files         156      156              
  Lines       25924    25923       -1     
==========================================
- Hits        17423    17422       -1     
  Misses       8501     8501              
Impacted Files Coverage Δ
sharpy/cases/templates/flying_wings.py 89.92% <100.00%> (-0.02%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

rafapalacios and others added 8 commits June 25, 2023 19:45
- enables the matlab script execution without the need to have a Matlab desktop version (e.g. virtual machines)
…ng code

In a previous commit, the input type of the initial cs deflection (from float back to list of floats/ints) has been changed to avoid unittest issues and the updated type makes more sense. The code for closed loop simulation has to be adjusted now as well (instead of list, only give one number to the cilent) as control surfaces are symmetric. Further, float type initial value is enforced in client script, to avoid type errors when creating binary control input message containing control surface deflections.
…ng code

In a previous commit, the input type of the initial cs deflection (from float back to list of floats/ints) has been changed to avoid unittest issues and the updated type makes more sense. The code for closed loop simulation has to be adjusted now as well (instead of list, only give one number to the cilent) as control surfaces are symmetric. Further, float type initial value is enforced in client script, to avoid type errors when creating binary control input message containing control surface deflections.

This commit also includes the removal of code giving instructions of executing the matlab script from Matlab's Desktop version. Only, Matlab's engine API for Python is recommended here as it can be run within the same document.
Copy link
Collaborator

@rafapalacios rafapalacios left a comment

Choose a reason for hiding this comment

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

Great job. This will be a very useful example for the community to build upon.

@rafapalacios rafapalacios merged commit 328558b into main Jun 30, 2023
3 checks passed
- convert normalized open-loop tip deflection to percent and not in plotting funcition because it is reused later
- update fixed result graphs
@sduess sduess deleted the udp_control_tutorial branch July 1, 2023 03:27
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.

None yet

3 participants