-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_input.jl
58 lines (45 loc) · 1.23 KB
/
user_input.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
# where the user will input their own functions to be used
# and where some basic defaults will be
using GNCTestServer
using LinearAlgebra
using Plots
using Random
struct Py4State
position::Vector{Float64}
velocity::Vector{Float64}
acceleration::Vector{Float64}
end
struct Py4
state::Py4State
params
end
struct basicSat
state::RBState
params::GNCTestServer.Parameters
end
# struct PycubedMiniState
function PyM_measurement(state, params)
return state.position
end
function PyM_control_law(measurement, t)
return GNCTestServer.Control(
[0, 0, 0]
)
end
function control_law(measurement, t)
ω = measurement[1].angular_velocity
b = measurement[2].b
b̂ = b / norm(b)
k = 7e-4
M = -k * (I(3) - b̂ * b̂') * ω
m = 1 / (dot(b, b)) * cross(b, M)
return GNCTestServer.Control(
m
)
end
function measurement_id(state, params)
return (state, params)
end
initial_state = basicSat(GNCTestServer.initialize_orbit(), GNCTestServer.initialize_params())
(data, time) = GNCTestServer.simulate(control_law, measurement_id, initial_state)
display(plot(time, data, title="DeTumbling", xlabel="Time (s)", ylabel="Angular Velocity (rad/s)", labels=["ω1" "ω2" "ω3" "ω"]))