コード例 #1
0
        /// <summary>Flight Computer constructor.</summary>
        /// <param name="s">A signal processor (most probably a <see cref="ModuleSPU"/> instance.)</param>
        public FlightComputer(ISignalProcessor s)
        {
            SignalProcessor  = s;
            Vessel           = s.Vessel;
            SanctionedPilots = new List <Action <FlightCtrlState> >();
            LastTarget       = TargetCommand.WithTarget(null);

            var attitude = AttitudeCommand.Off();

            _activeCommands[attitude.Priority] = attitude;

            //Use http://www.ni.com/white-paper/3782/en/ to fine-tune
            PIDController = new PIDController(PIDKp, PIDKi, PIDKd, 1.0, -1.0, true);
            PIDController.SetVessel(Vessel);

            GameEvents.onVesselChange.Add(OnVesselChange);
            GameEvents.onVesselSwitching.Add(OnVesselSwitching);
            GameEvents.onGameSceneSwitchRequested.Add(OnSceneSwitchRequested);

            RoverComputer = new RoverComputer(this, RoverPIDKp, RoverPIDKi, RoverPIDKd);
            RoverComputer.SetVessel(Vessel);

            // Add RT listeners from KSP Autopilot
            StockAutopilotCommand.UIreference = GameObject.FindObjectOfType <VesselAutopilotUI>();
            for (var index = 0; index < StockAutopilotCommand.UIreference.modeButtons.Length; index++)
            {
                var buttonIndex = index; // prevent compiler optimisation from assigning static final index value
                StockAutopilotCommand.UIreference.modeButtons[index].onClick.AddListener(delegate { StockAutopilotCommand.AutopilotButtonClick(buttonIndex, this); });
                // bad idea to use RemoveAllListeners() since no easy way to re-add the original stock listener to onClick
            }
        }
コード例 #2
0
ファイル: FlightComputer.cs プロジェクト: ec429/RemoteTech
        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 attitude = AttitudeCommand.Off();
            mActiveCommands[attitude.Priority] = attitude;

            GameEvents.onVesselChange.Add(OnVesselChange);

            mRoverComputer = new RoverComputer();
            mRoverComputer.SetVessel(Vessel);
        }
コード例 #3
0
        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 attitude = AttitudeCommand.Off();

            mActiveCommands[attitude.Priority] = attitude;

            GameEvents.onVesselChange.Add(OnVesselChange);

            mRoverComputer = new RoverComputer();
            mRoverComputer.SetVessel(Vessel);
        }
コード例 #4
0
        /// <summary>Flight Computer constructor.</summary>
        /// <param name="s">A signal processor (most probably a <see cref="ModuleSPU"/> instance.)</param>
        public FlightComputer(ISignalProcessor s)
        {
            SignalProcessor  = s;
            Vessel           = s.Vessel;
            SanctionedPilots = new List <Action <FlightCtrlState> >();
            pid = new PIDControllerV3(Vector3d.zero, Vector3d.zero, Vector3d.zero, 1, -1);
            setPIDParameters();
            lastAct    = Vector3d.zero;
            LastTarget = TargetCommand.WithTarget(null);

            var attitude = AttitudeCommand.Off();

            _activeCommands[attitude.Priority] = attitude;

            GameEvents.onVesselChange.Add(OnVesselChange);
            GameEvents.onVesselSwitching.Add(OnVesselSwitching);
            GameEvents.onGameSceneSwitchRequested.Add(OnSceneSwitchRequested);

            RoverComputer = new RoverComputer();
            RoverComputer.SetVessel(Vessel);
        }
コード例 #5
0
        /// <summary>Flight Computer constructor.</summary>
        /// <param name="s">A signal processor (most probably a <see cref="ModuleSPU"/> instance.)</param>
        public FlightComputer(ISignalProcessor s)
        {
            SignalProcessor = s;
            Vessel = s.Vessel;
            SanctionedPilots = new List<Action<FlightCtrlState>>();
            pid = new PIDControllerV3(Vector3d.zero, Vector3d.zero, Vector3d.zero, 1, -1);
            setPIDParameters();
            lastAct = Vector3d.zero;
            LastTarget = TargetCommand.WithTarget(null);

            var attitude = AttitudeCommand.Off();
            _activeCommands[attitude.Priority] = attitude;

            GameEvents.onVesselChange.Add(OnVesselChange);
            GameEvents.onVesselSwitching.Add(OnVesselSwitching);
            GameEvents.onGameSceneSwitchRequested.Add(OnSceneSwitchRequested);

            RoverComputer = new RoverComputer();
            RoverComputer.SetVessel(Vessel);
        }