forked from UW-ACL/SCPToolbox.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parameters.jl
152 lines (132 loc) · 4.69 KB
/
parameters.jl
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#= Planar spacecraft rendezvous data structures and custom methods.
Sequential convex programming algorithms for trajectory optimization.
Copyright (C) 2021 Autonomous Controls Laboratory (University of Washington)
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>. =#
using ..SCPToolbox
# ..:: Data structures ::..
""" Planar rendezvous parameters. """
struct PlanarRendezvousParameters
# ..:: Indices ::..
id_r::IntRange # Position (state)
id_v::IntRange # Velocity (state)
id_θ::Int # Rotation angle (state)
id_ω::Int # Rotation rate (state)
id_f::IntRange # Thrust forces for RCS pods (input)
id_fr::IntRange # Reference thrust forces for RCS pods (input)
id_l1f::IntRange # Thrust force absolute values for RCS pods (input)
id_l1feq::IntRange # Thrust force difference one-norm (input)
id_t::Int # Time dilation (parameter)
# ..:: Mechanical parameters ::..
m::RealValue # [kg] Mass
J::RealValue # [kg*m²] Moment of inertia about CoM
lu::RealValue # [m] CoM longitudinal distance aft of thrusters
lv::RealValue # [m] CoM transverse distance from thrusters
uh::Function # Longitudinal "forward" axis in the inertial frame
vh::Function # Transverse "up" axis in the inertial frame
# ..:: Control parameters ::..
f_max::RealValue # [N] Maximum thrust force
f_db::RealValue # [N] Deadband thrust force
end
""" Planar rendezvous flight environment. """
struct PlanarRendezvousEnvironmentParameters
xh::RealVector # Inertial horizontal axis
yh::RealVector # Inertial vertical axis
n::RealValue # [rad/s] Orbital mean motion
end
""" Trajectory parameters. """
mutable struct PlanarRendezvousTrajectoryParameters
r0::RealVector # [m] Initial position
v0::RealVector # [m/s] Initial velocity
θ0::RealValue # [rad] Initial rotation angle
ω0::RealValue # [rad/s] Initial rotation rate
vf::RealValue # [m/s] Final approach speed
tf_min::RealValue # [s] Minimum flight time
tf_max::RealValue # [s] Maximum flight time
κ::RealValue # Sigmoid homotopy parameter
γ::RealValue # Control weight for deadband relaxation
end
""" Planar rendezvous trajectory optimization problem parameters all in
one. """
struct PlanarRendezvousProblem
vehicle::PlanarRendezvousParameters # The ego-vehicle
env::PlanarRendezvousEnvironmentParameters # The environment
traj::PlanarRendezvousTrajectoryParameters # The trajectory
end
# ..:: Methods ::..
"""
PlanarRendezvousProblem()
Constructor for the planar rendezvous problem.
# Returns
- `mdl`: the problem definition object.
"""
function PlanarRendezvousProblem()::PlanarRendezvousProblem
# ..:: Environment ::..
xh = [1.0; 0.0]
yh = [0.0; 1.0]
μ = 3.986e14 # [m³/s²] Standard gravitational parameter
Re = 6378e3 # [m] Earth radius
R = Re + 400e3 # [m] Orbit radius
n = sqrt(μ / R^3)
env = PlanarRendezvousEnvironmentParameters(xh, yh, n)
# ..:: Spacecraft vehicle ::..
# >> Indices <<
id_r = 1:2
id_v = 3:4
id_θ = 5
id_ω = 6
id_f = 1:3
id_fr = 4:6
id_l1f = 7:9
id_l1feq = 10:12
id_t = 1
# >> Mechanical parameters <<
m = 30e3
J = 1e5
lu = 0.6
lv = 2.1
uh = (θ) -> -cos(θ) * xh + sin(θ) * yh
vh = (θ) -> -sin(θ) * xh - cos(θ) * yh
# >> Control parameters <<
f_max = 750.0 # 445.0
f_db = 200.0
sc = PlanarRendezvousParameters(
id_r,
id_v,
id_θ,
id_ω,
id_f,
id_fr,
id_l1f,
id_l1feq,
id_t,
m,
J,
lu,
lv,
uh,
vh,
f_max,
f_db,
)
# ..:: Trajectory ::..
r0 = 100.0 * xh + 10.0 * yh
v0 = 0.0 * xh
θ0 = deg2rad(180.0)
ω0 = 0.0
vf = 0.1
tf_min = 100.0
tf_max = 500.0
κ = NaN
γ = 3e-1
traj = PlanarRendezvousTrajectoryParameters(r0, v0, θ0, ω0, vf, tf_min, tf_max, κ, γ)
mdl = PlanarRendezvousProblem(sc, env, traj)
return mdl
end