sot / kadi

Chandra commands and events
https://sot.github.io/kadi
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

Fix bug when getting states starting just before NSM #260

Closed taldcroft closed 1 year ago

taldcroft commented 1 year ago

Description

When getting states (with no defined continuity) starting from just before a normal sun mode transition there was an exception due to the current attitude state quaternions being None. This PR fixes the issue ala #199 by dropping the NSM command and letting the next defined maneuver take over.

Fixes #258

Interface impacts

Testing

Unit tests

Independent check of unit tests by Jean

Functional tests

No functional testing. Unit test added.

jeanconn commented 1 year ago

Was I incorrect about the issue being a NSM transition (this one caused by safe mode command event) when already in NSM? I thought the general case of reasonable command history and continuity around NSM was fine.

taldcroft commented 1 year ago

The problem is doing a NSM transition when the current attitude state is not yet defined (all None). So any time between the last maneuver (or NSM) and the NSM. The Maneuver transition has special handling for the case of an undefined initial attitude, and now with this PR the NSM transition also has such handling.

Here is the bug for the first NSM associated with the IU reset.

In [5]: date = CxoTime('2022:293:16:27:49.000') # NSM time for IU reset
In [6]: get_continuity(date + 6.99 * u.day)  # lookback is 7 days
... crash
jeanconn commented 1 year ago

You've lost me a little bit on 'So any time between the last maneuver (or NSM) and the NSM.' I didn't think a "last maneuver" set the current attitude to None. But I see your point that I had originally missed about about "undefined initial attitude" also being a problem for doing a NSM transition (while establishing continuity). So I see this bug for the cases of undefined initial attitude or NSM before a NSM transition.

taldcroft commented 1 year ago

I didn't think a "last maneuver" set the current attitude to None

State propagation begins with the attitude set to None. So every time you start state propagation (i.e. computing states) with no continuity then attitude is None until a maneuver happens (consisting of both target update command and AOMANVR).

So if you start state propagation and there is no maneuver (as defined above) before the NSM command then this bug happens. It doesn't matter what happened before the start of state propagation because those commands are not part of the processing.