diff --git a/mission_test.go b/mission_test.go index a2926c8..e8626f3 100644 --- a/mission_test.go +++ b/mission_test.go @@ -201,7 +201,9 @@ func TestCorrectOEa(t *testing.T) { EPThrusters := []EPThruster{new(PPS1350)} dryMass := 300.0 fuelMass := 67.0 - sc := NewSpacecraft("COE", dryMass, fuelMass, eps, EPThrusters, false, []*Cargo{}, []Waypoint{NewOrbitTarget(*oTarget, nil, meth, OptiΔaCL)}) + otgt := NewOrbitTarget(*oTarget, nil, meth, OptiΔaCL) + otgt.SetEpsilons(1e-1, 1e-5, Deg2rad(0.001)) + sc := NewSpacecraft("COE", dryMass, fuelMass, eps, EPThrusters, false, []*Cargo{}, []Waypoint{otgt}) start := time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC) end := start.Add(time.Duration(45*24) * time.Hour) astro := NewMission(sc, oInit, start, end, Perturbations{}, false, ExportConfig{Filename: fmt.Sprintf("ruggOEa-%s", meth), Cosmo: smdConfig().testExport, AsCSV: smdConfig().testExport}) diff --git a/prop.go b/prop.go index b047372..835a733 100644 --- a/prop.go +++ b/prop.go @@ -253,6 +253,7 @@ type OptimalΔOrbit struct { // local copy of the OEs of the inital and target orbits oInita, oInite, oIniti, oInitΩ, oInitω, oInitν float64 oTgta, oTgte, oTgti, oTgtΩ, oTgtω, oTgtν float64 + distanceε, eccentricityε, angleε float64 GenericCL } @@ -262,6 +263,9 @@ func NewOptimalΔOrbit(target Orbit, method ControlLawType, laws []ControlLaw) * cl.cleared = false cl.method = method cl.oTgta, cl.oTgte, cl.oTgti, cl.oTgtΩ, cl.oTgtω, cl.oTgtν, _, _, _ = target.Elements() + cl.distanceε = distanceε + cl.eccentricityε = eccentricityε + cl.angleε = angleε if len(laws) == 0 { laws = []ControlLaw{OptiΔaCL, OptiΔeCL, OptiΔiCL, OptiΔΩCL, OptiΔωCL} } @@ -277,6 +281,18 @@ func NewOptimalΔOrbit(target Orbit, method ControlLawType, laws []ControlLaw) * return &cl } +// SetTarget changes the target of this optimal control +func (cl *OptimalΔOrbit) SetTarget(target Orbit) { + cl.oTgta, cl.oTgte, cl.oTgti, cl.oTgtΩ, cl.oTgtω, cl.oTgtν, _, _, _ = target.Elements() +} + +// SetEpsilons changes the target of this optimal control +func (cl *OptimalΔOrbit) SetEpsilons(distanceε, eccentricityε, angleε float64) { + cl.distanceε = distanceε + cl.eccentricityε = eccentricityε + cl.angleε = angleε +} + func (cl *OptimalΔOrbit) String() string { return "OptimalΔOrbit" } diff --git a/waypoints.go b/waypoints.go index 37df862..2066bc6 100644 --- a/waypoints.go +++ b/waypoints.go @@ -164,6 +164,11 @@ func (wp *OrbitTarget) Action() *WaypointAction { return nil } +// SetEpsilons allows to set the epsilons of the control law +func (wp *OrbitTarget) SetEpsilons(distanceε, eccentricityε, angleε float64) { + wp.ctrl.SetEpsilons(distanceε, eccentricityε, angleε) +} + // ThrustDirection implements the optimal orbit target. func (wp *OrbitTarget) ThrustDirection(o Orbit, dt time.Time) (ThrustControl, bool) { if ok, err := wp.target.Equals(o); ok {