Upgrade of AttitudesSequence
The AttitudeSequence class allows easy switching from one attitude law to another following switching events, with the following structure:
void addSwitchingCondition(final AttitudeProvider before,
final T switchEvent,
final boolean switchOnIncrease,
final boolean switchOnDecrease,
final AttitudeProvider after)
There are 2 points.
- For some attitude laws, in order to initialise the attitude provider it would be helpful to know the date when the switch occurs (which may not be know apriori), and more generally the spacecraft state (e.g. attitude law 'after' may need to know the switching date to implement some kind of transient kinematic motion).
Is it possible to add a handler to addSwitchingCondition() that would be
called independantly of the handler that may be implemented in the
swicthEvent, and that would provide a SpacecraftState.
I think that would be cleaner.
A work around is however, to add a handler to switchEvent (with
.withHandler()), though, but then I find it cumbersome because that
requires adding again a check on the conditions for the switching (check
increasing flag and so on).
Example:
Current approach:
final EventHandler mSwitchHandler = new EventHandler(){
@Override
public Action eventOccurred(SpacecraftState s, EventDetector detector,
boolean increasing)
throws OrekitException {
if ( (phaseTo.switchOnIncrease() && increasing) ||
(phaseTo.switchOnDecrease() && !increasing)) {
// attitude low specific code
// ...
// tell the new attitude law about when it became active ...
mAttitudeProvider.setStartDate(s.getDate());
}
return Action.CONTINUE;
}
@Override
public SpacecraftState resetState(EventDetector detector,
SpacecraftState oldState)
throws OrekitException {
return oldState;
}
};
mAttitudesSequence.addSwitchingCondition(attLawBefore,
phaseTo.getSwitchEvent().withHandler(mSwitchHandler),
phaseTo.switchOnIncrease(),
phaseTo.switchOnDecrease(),
mAttitudeProvider);
Upgraded approach: It could be interesting to change the call to something like,
mAttitudesSequence.addSwitchingCondition(attLawBefore,
phaseTo.getSwitchEvent(),
mSwitchHandler,
phaseTo.switchOnIncrease(),
phaseTo.switchOnDecrease(),
mAttitudeProvider);
And change the method of AttitudeSequence
public boolean performSwitch()
to
public boolean performSwitch(final SpacecraftState s)
where mSwitchHandler(s) could be called.
- I am not sure how the 'before' attitude provider can influence the
switching pattern. From the code, it seems any switch can be triggered
and can yield to a change of the attitude law regardless of the current
active attitude law.
I made some changes to account for this. As a possible correction, please find in attachment the differences between my current implementation and the current one in Orekit.
(from redmine: issue id 190, created on 2015-02-24, closed on 2016-02-10)
- Uploads:
- upgrade Diff file