Got MBH working! It can find better-than-basic-spiral trajectories

This commit is contained in:
Connor
2021-09-02 17:21:40 -06:00
parent 58ad3c5293
commit 83886188db
8 changed files with 318 additions and 381 deletions

View File

@@ -72,9 +72,9 @@ end
"""
Converts a series of thrust vectors from R,Θ,H frame to cartesian
"""
function conv_T(Tr::Vector{Float64},
TΘ::Vector{Float64},
Th::Vector{Float64},
function conv_T(Tm::Vector{Float64},
Ta::Vector{Float64},
Tb::Vector{Float64},
init_state::Vector{Float64},
m::Float64,
craft::Sc,
@@ -84,29 +84,32 @@ function conv_T(Tr::Vector{Float64},
Txs = Float64[]
Tys = Float64[]
Tzs = Float64[]
state = init_state
for i in 1:length(Tr)
mag, α, β = Tr[i], [i], Th[i]
n::Int = length(Tm)
for i in 1:n
mag, α, β = Tm[i], Ta[i], Tb[i]
if mag > 1 || mag < 0
throw(ErrorException("ΔV input is too high: $mag"))
@error "ΔV input is too high: $mag"
elseif α > π || α < -π
throw(ErrorException("α angle is incorrect: $α"))
@error "α angle is incorrect: $α"
elseif β > π/2 || β < -π/2
throw(ErrorException("β angle is incorrect: "))
@error "β angle is incorrect: "
end
end
state = init_state
for i in 1:n
mag, α, β = Tm[i], Ta[i], Tb[i]
thrust_rθh = mag * [cos(β)*sin(α), cos(β)*cos(α), sin(β)]
_,_,i,Ω,ω,ν = xyz_to_oe(state, μ)
θ = ω+ν
,,ci,si,, = cos(Ω),sin(Ω),cos(i),sin(i),cos(θ),sin(θ)
DCM = [*-*ci* -*-*ci* *si;
*+*ci* -*+*ci* -*si;
si* si* ci]
ΔV = DCM*thrust_rθh
Tx, Ty, Tz = max_ΔV(craft.duty_cycle, craft.num_thrusters, craft.max_thrust, time, 0., m) * ΔV
x, y, z, dx, dy, dz = state
state = prop_one_simple(Tx, Ty, Tz, x, y, z, dx, dy, dz, time/length(Tr), μ)
*+*ci* -*+*ci* -*si;
si* si* ci ]
Tx, Ty, Tz = DCM*thrust_rθh
state = prop_one([Tx, Ty, Tz], state, craft, μ, time/n)[1]
push!(Txs, Tx)
push!(Tys, Ty)
push!(Tzs, Tz)