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

Add WingRock model (fixedwings) #22

Merged
merged 6 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FSimZoo"
uuid = "e2d5807d-1594-43f7-91a6-54c6eef5a9d2"
authors = ["JinraeKim <kjl950403@gmail.com> and contributors"]
version = "0.8.0"
version = "0.9.0"

[deps]
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ contains predefined environments and controllers for [FlightSims.jl](https://git

</details>

<details>
<summary>fixed wings</summary>

- `WingRock`

</details>

<details>
<summary>multicopters</summary>

Expand Down
2 changes: 2 additions & 0 deletions src/FSimZoo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export TwoDimensionalNonlinearDTSystem
export LQR, PID, BacksteppingPositionController
export GeometricTrackingController, OuterLoopGeometricTrackingController, InnerLoopGeometricTrackingController
export InputAffinePositionCBF
## fixedwings
export WingRock
## multicopters
export Multicopter
export Quadcopter, IslamQuadcopter, GoodarziQuadcopter, LeeQuadcopter, GoodarziAgileQuadcopter
Expand Down
3 changes: 3 additions & 0 deletions src/environments/environments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
## Basic environments
include("basics/basics.jl")

## Fixed wings
include("fixedwings/fixedwings.jl")

## Multicopters
include("multicopters/multicopters.jl")

Expand Down
1 change: 1 addition & 0 deletions src/environments/fixedwings/fixedwings.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("wingrock.jl")
39 changes: 39 additions & 0 deletions src/environments/fixedwings/wingrock.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Wing-rock phenomenon in the roll motion of slendar delta wings [1].

# Notes
## Nondimensional values
The time, state, and control input of this model are nondimensional [2].

## Ideal parameters
The default ideal parameters, W_true, are set as the specific model obtained at the angle of attack of 25 degrees in [1].
Note that the ideal parameters in [2] are (1000 x the ideal parameters in [1]).

# Refs
[1] J. M. Elzebda, A. H. Nayfeh, and D. T. Mook, “Development of an analyt- ical model of wing rock for slender delta wings,” J. Aircr., vol. 26, no. 8, pp. 737–743, 1989.
[2] N. Cho, H.-S. Shin, Y. Kim, and A. Tsourdos, “Composite Model Reference Adaptive Control with Parameter Convergence Under Finite Excitation,” IEEE Trans. Automat. Contr., vol. 63, no. 3, pp. 811–818, Mar. 2018, doi: 10.1109/TAC.2017.2737324.
"""
Base.@kwdef struct WingRock <: AbstractEnv
W_true = 1e-3 * [-18.59521, 15.162375, -62.45153, 9.54708, 21.45291]
end


function State(env::WingRock)
return function (x1=0.0, x2=0.0)
ComponentArray(x1=x1, x2=x2)
end
end


function Dynamics!(env::WingRock)
(; W_true) = env
@Loggable function dynamics!(dx, x, p, t; u)
(; x1, x2) = x
@log state = x
@log input = u
ϕ = [x1, x2, abs(x1)*x2, abs(x2)*x2, x1^3]
Δ = W_true' * ϕ
dx.x1 = x2
dx.x2 = u + Δ
end
end
1 change: 1 addition & 0 deletions test/environments/environments.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("fixedwings/fixedwings.jl")
1 change: 1 addition & 0 deletions test/environments/fixedwings/fixedwings.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("wingrock.jl")
20 changes: 20 additions & 0 deletions test/environments/fixedwings/wingrock.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using FSimZoo
using Test
using FSimBase


function main()
t = 0.0
W_true = rand(5)
env = WingRock(W_true)
x1, x2 = rand(2)
X = State(env)(x1, x2)
u = 0.0
dX = deepcopy(X)
Dynamics!(env)(dX, X, [], t; u=u)
end


@testset "wingrock" begin
main()
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ using Test
include("geometric_tracking.jl")
include("geometric_tracking_inner_outer.jl")
include("cbf.jl")
include("environments/environments.jl")
end