//save the flight control state entered at a given time public void push(FlightCtrlState state, double time) { TimedCtrlState savedCopy = new TimedCtrlState(); savedCopy.flightCtrlState = new FlightCtrlState(); savedCopy.flightCtrlState.CopyFrom(state); savedCopy.ActTime = time; states.Enqueue(savedCopy); // this saves the current attitude control values to a sepperate controlstate, that way attitude control is allways accesible without delay pitch = state.pitch; roll = state.roll; yaw = state.yaw; }
//retrieve the flight control state entered at a given time public void pop(FlightCtrlState controls, double time) { if (states.Count == 0 || states.Peek().ActTime > time) { setNeutral(controls); return; //returns neutral if no controls are entered or the entered controls are not within the signal delay } TimedCtrlState popState = states.Peek(); while (states.Peek().ActTime < time) { popState = states.Dequeue(); } controls.CopyFrom(popState.flightCtrlState); if (controls.killRot) // this overrides the delay in attitute control if SAS is activated. Thereby allowing SAS to make control changes without delay { controls.pitch = pitch; controls.roll = roll; controls.yaw = yaw; } }