Skip to content

Commit

Permalink
Add SetEpsilons in control law and WayPoint for OptimalTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Rabotin committed Jan 16, 2018
1 parent e7bb62b commit 412062a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
16 changes: 16 additions & 0 deletions prop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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}
}
Expand All @@ -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"
}
Expand Down
5 changes: 5 additions & 0 deletions waypoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 412062a

Please sign in to comment.