-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
56 lines (45 loc) · 1.79 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Example simulation using a pre-built paraglider model."""
# https://pfheatwole.github.io/glidersim/usage.html#running-simulations
import pfh.glidersim as gsim
import scipy.interpolate
from mescal_6 import skywalk_mescal_6
# Component models: use a pre-built wing and add a suitable harness
wing = skywalk_mescal_6(size='XS', verbose=True)
harness = gsim.paraglider_harness.Spherical(
mass=75,
z_riser=0.5,
S=0.55,
CD=0.8,
kappa_w=0.1,
)
# The system dynamics model provides the physical accelerations
paraglider = gsim.paraglider.ParagliderSystemDynamics6a(wing, harness)
# Build a control input sequence for right brake using linear interpolation:
# the input is 0 until t=3, increases to 1 over t=3..5, holds at 1 until t=22,
# decreases to zero over t=22..23, and holds at 0 indefinitely.
delta_br = scipy.interpolate.interp1d(
[0, 3, 5, 22, 23], # times
[0, 0, 1, 1, 0], # percentages
fill_value=0,
bounds_error=False,
)
# Inputs to the state dynamics are either constants or functions of time `t`
sim_parameters = {
"delta_a": 0.0,
"delta_bl": 0.0,
"delta_br": delta_br,
"delta_w": 0.0,
"rho_air": 1.225,
"v_W2e": (0, 0, 0), # Uniform global wind velocity
}
input('Waiting for user input ...')
# The state dynamics model provides the state derivatives
model = gsim.simulator.ParagliderStateDynamics6a(paraglider, **sim_parameters)
# Setup and run the simulation
state0 = model.starting_equilibrium() # Start the simulation at equilibrium
dt = 0.5 # Record the state every 0.5 seconds
T = 25 # Run for 25 seconds
times, states = gsim.simulator.simulate(model, state0, dt=dt, T=T)
# 3D plot: position over time
points = gsim.extras.simulation.sample_paraglider_positions(model, states, times)
gsim.extras.plots.plot_3d_simulation_path(**points)