public override bool Execute(FlightComputer f, FlightCtrlState fcs) { if (RemainingDelta > 0) { var forward = Node.GetBurnVector(f.Vessel.orbit).normalized; var up = (f.SignalProcessor.Body.position - f.SignalProcessor.Position).normalized; var orientation = Quaternion.LookRotation(forward, up); FlightCore.HoldOrientation(fcs, f, orientation); double thrustToMass = (FlightCore.GetTotalThrust(f.Vessel) / f.Vessel.GetTotalMass()); if (thrustToMass == 0.0) { EngineActivated = false; return(false); } EngineActivated = true; fcs.mainThrottle = 1.0f; RemainingTime = RemainingDelta / thrustToMass; RemainingDelta -= thrustToMass * TimeWarp.deltaTime; return(false); } f.Enqueue(AttitudeCommand.Off(), true, true, true); return(true); }
private void Submit() { if (!mFlightComputer.InputAllowed) { return; } var newCommand = AttitudeCommand.WithAltitude(Altitude); mFlightComputer.Enqueue(newCommand); }
private void Confirm() { ICommand newCommand; switch (mMode) { default: // Off mAttitude = 0; newCommand = AttitudeCommand.Off(); break; case 1: // Killrot mAttitude = 0; newCommand = AttitudeCommand.KillRot(); break; case 2: // Node mAttitude = 0; newCommand = AttitudeCommand.ManeuverNode(); break; case 3: // Target Parallel mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.TargetParallel); break; case 4: // Orbital reference mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Orbit); break; case 5: // Surface reference mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Surface); break; case 6: // Target Velocity mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.TargetVelocity); break; case 7: // Custom Surface Heading mAttitude = 0; newCommand = AttitudeCommand.WithSurface(Pitch, Heading, Roll); break; } mFlightComputer.Enqueue(newCommand); }
public FlightComputer(ISignalProcessor s) { SignalProcessor = s; Vessel = s.Vessel; SanctionedPilots = new List <Action <FlightCtrlState> >(); var target = TargetCommand.WithTarget(FlightGlobals.fetch.VesselTarget); mActiveCommands[target.Priority] = target; var attitude = AttitudeCommand.Off(); mActiveCommands[attitude.Priority] = attitude; }
private void Confirm() { DelayedCommand newCommand; switch (mMode) { default: // Off mAttitude = 0; newCommand = AttitudeCommand.Off(); break; case 1: // Killrot mAttitude = 0; newCommand = AttitudeCommand.KillRot(); break; case 2: // Node mAttitude = 0; newCommand = AttitudeCommand.ManeuverNode(); break; case 3: // Pitch, heading, roll mAttitude = 0; newCommand = AttitudeCommand.WithSurface( Pitch, Heading, mRollEnabled ? Roll : Single.NaN); break; case 4: // Orbital reference mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Orbit); break; case 5: // Surface reference mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Surface); break; case 6: // Target reference mAttitude = (mAttitude == 0) ? 1 : mAttitude; newCommand = AttitudeCommand.WithAttitude(Attitude, ReferenceFrame.Target); break; } mFlightComputer.Enqueue(newCommand); }
public FlightComputer(ISignalProcessor s) { SignalProcessor = s; Vessel = s.Vessel; SanctionedPilots = new List <Action <FlightCtrlState> >(); pid = new PIDControllerV2(0, 0, 0, 1, -1); initPIDParameters(); lastAct = Vector3d.zero; var target = TargetCommand.WithTarget(FlightGlobals.fetch.VesselTarget); mActiveCommands[target.Priority] = target; var attitude = AttitudeCommand.Off(); mActiveCommands[attitude.Priority] = attitude; }