TimeProportionedPidController(float windowSize, IOnOff relay, TimeSpan samplingRate,
                                      Func <float> readProcess, Func <float> readOutput, Func <float> readSetPoint,
                                      float proportionalGain, float integralGain, float derivativeGain,
                                      ControllerDirection controllerDirection = ControllerDirection.Direct,
                                      ControllerMode controllerMode           = ControllerMode.Automatic)
        {
            _windowSize = windowSize;
            _relay      = relay;
            if (readProcess == null)
            {
                throw new ArgumentNullException(nameof(readProcess), "Read process must not be null.");
            }
            if (readOutput == null)
            {
                throw new ArgumentNullException(nameof(readOutput), "Read output must not be null.");
            }
            if (readSetPoint == null)
            {
                throw new ArgumentNullException(nameof(readSetPoint), "Read set-point must not be null.");
            }

            SamplingRate = samplingRate;
            SetOutputLimits(0, _windowSize);
            _readProcess        = readProcess;
            _readOutput         = readOutput;
            _writeOutput        = writeOutput;
            _readSetPoint       = readSetPoint;
            ProportionalGain    = proportionalGain;
            IntegralGain        = integralGain;
            DerivativeGain      = derivativeGain;
            ControllerDirection = controllerDirection;
            ControllerMode      = controllerMode;
        }
Example #2
0
        void ConfigFightersInput(ControllerMode mode)
        {
            // State Machine
            Fighter2DGameManager sm = Fighter2DGameManager.current;

            // Single Player
            if (mode == ControllerMode.SINGLE_PLAYER)
            {
                //Fighter1 - Single
                sm.ConfigFighterControllers(1, ControllerMode.SINGLE_PLAYER);

                //Fighter2 - AI
                sm.ConfigFighterControllers(2, ControllerMode.AI_PLAYER);
            }

            // Multiplayer
            else if (mode == ControllerMode.MULTI_PLAYER)
            {
                //Fighter1 - Multi
                sm.ConfigFighterControllers(1, ControllerMode.MULTI_PLAYER);

                //Fighter2 - Multi
                sm.ConfigFighterControllers(2, ControllerMode.MULTI_PLAYER);
            }

            // Expectator
            else if (mode == ControllerMode.AI_PLAYER)
            {
                //Fighter1 - Single
                sm.ConfigFighterControllers(1, ControllerMode.AI_PLAYER);

                //Fighter2 - AI
                sm.ConfigFighterControllers(2, ControllerMode.AI_PLAYER);
            }
        }
Example #3
0
        /// <summary>
        ///     Instantiates a new PID controller class. The <see cref="Run" /> method must be called to trigger computation.
        /// </summary>
        /// <param name="samplingRate">
        ///     The rate at which the algorithm will compute a new output once <see cref="Run" /> is
        ///     called.
        /// </param>
        /// <param name="outputMinimum">The minimum value the output can be written to. The output influences the process value.</param>
        /// <param name="outputMaximum">The maximum value the output can be written to. The output influences the process value.</param>
        /// <param name="readProcess">
        ///     A function to read the process value. The process value is what you are attempting to
        ///     control.
        /// </param>
        /// <param name="readOutput">A function to read the output. The output influences the process value.</param>
        /// <param name="writeOutput">A function to write to the output. The output influences the process value.</param>
        /// <param name="readSetPoint">A function to read the target set-point for the process.</param>
        /// <param name="proportionalGain">The proportional gain to use.</param>
        /// <param name="integralGain">The integral gain to use.</param>
        /// <param name="derivativeGain">The derivative gain to use.</param>
        /// <param name="controllerDirection">The direction to control the output if you want the process to increase in value..</param>
        /// <param name="controllerMode">The mode to start out the PID controller in.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <see cref="readProcess" /> or <see cref="readOutput" /> or <see cref="writeOutput" /> or
        ///     <see cref="readSetPoint" /> are null.
        /// </exception>
        public PidController(TimeSpan samplingRate, float outputMinimum, float outputMaximum, Func <float> readProcess,
                             Func <float> readOutput,
                             Action <float> writeOutput, Func <float> readSetPoint, float proportionalGain, float integralGain,
                             float derivativeGain, ControllerDirection controllerDirection, ControllerMode controllerMode)
        {
            if (readProcess == null)
            {
                throw new ArgumentNullException(nameof(readProcess), "Read process must not be null.");
            }
            if (readOutput == null)
            {
                throw new ArgumentNullException(nameof(readOutput), "Read output must not be null.");
            }
            if (readSetPoint == null)
            {
                throw new ArgumentNullException(nameof(readSetPoint), "Read set-point must not be null.");
            }
            if (writeOutput == null)
            {
                throw new ArgumentNullException(nameof(writeOutput), "Write output must not be null.");
            }

            SamplingRate = samplingRate;
            SetOutputLimits(outputMinimum, outputMaximum);
            _readProcess        = readProcess;
            _readOutput         = readOutput;
            _writeOutput        = writeOutput;
            _readSetPoint       = readSetPoint;
            ProportionalGain    = proportionalGain;
            IntegralGain        = integralGain;
            DerivativeGain      = derivativeGain;
            ControllerDirection = controllerDirection;
            ControllerMode      = controllerMode;
        }
Example #4
0
    public void SetMode(ControllerMode mode)
    {
        Mode = mode;
        if (mode != ControllerMode.Menu && MainMenuInstance != null)
        {
            Destroy(MainMenuInstance);
        }

        switch (mode)
        {
        case ControllerMode.Build:
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
            break;

        case ControllerMode.Menu:
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
            break;

        case ControllerMode.Play:
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
            break;
        }
    }
 /// <summary>
 ///
 /// </summary>
 /// <param name="windowSizeMillis">millis</param>
 /// <param name="pin"></param>
 /// <param name="samplingRate"></param>
 /// <param name="readProcess"></param>
 /// <param name="readOutput"></param>
 /// <param name="readSetPoint"></param>
 /// <param name="proportionalGain"></param>
 /// <param name="integralGain"></param>
 /// <param name="derivativeGain"></param>
 /// <param name="controllerDirection"></param>
 /// <param name="controllerMode"></param>
 public TimeProportionedPidController(string name,
                                      ulong windowSizeMillis, WisePin pin, TimeSpan samplingRate,
                                      Func <int> stopSimulatedProcess,
                                      Func <int> readProcess, Func <ulong> readOutput, Action <ulong> writeOutput, Func <int> readSetPoint,
                                      float proportionalGain, float integralGain, float derivativeGain,
                                      ControllerMode controllerMode = ControllerMode.Automatic) : base(name, samplingRate, (float)0.0, (float)100.0,
                                                                                                       readProcess, readOutput, writeOutput, readSetPoint,
                                                                                                       proportionalGain, integralGain, derivativeGain,
                                                                                                       pin.Direction == Const.Direction.Increasing ? ControllerDirection.Direct : ControllerDirection.Reverse,
                                                                                                       controllerMode)
 {
     _windowSize = windowSizeMillis * TimeSpan.TicksPerMillisecond;
     base.SetOutputLimits(0, _windowSize);
     _pin = pin;
     if (readProcess == null)
     {
         throw new ArgumentNullException(nameof(readProcess), "Read process must not be null.");
     }
     if (readOutput == null)
     {
         throw new ArgumentNullException(nameof(readOutput), "Read output must not be null.");
     }
     _stopSimulatedProcess = stopSimulatedProcess;
     debugger.init();
 }
Example #6
0
        void DisplayHowToScreen(ControllerMode mode)
        {
            //Hide all screens
            DeactivateAllScreens();

            // Hide all Arrows
            DeactivateAllArrows();

            // Single Player
            if (mode == ControllerMode.SINGLE_PLAYER)
            {
                canvasSingle.SetActive(true);
            }

            // Multiplayer
            else if (mode == ControllerMode.MULTI_PLAYER)
            {
                canvasMulti.SetActive(true);
            }

            else if (mode == ControllerMode.AI_PLAYER)
            {
                canvasAuto.SetActive(true);
            }
        }
Example #7
0
    public static void ChangeController(ControllerMode controllerMode)
    {
        mode           = controllerMode;
        inputThreshold = mode == ControllerMode.mobile ? 0f : 0.25f; //This is to eliminate joysticks that have inaccurate/worn down analogue sticks. TODO: Automatically measure the idle readings and base the threshold off of that.

        modeAsString = mode.ToString();

        horizontalString      = "Horizontal_" + modeAsString;
        verticalString        = "Vertical_" + modeAsString;
        inventoryString       = "Inventory_" + modeAsString;
        inventorySelectString = "InventorySelect_" + modeAsString;
        useString             = "Use_" + modeAsString;
        actionString          = "Action_" + modeAsString;
        menuString            = "Menu_" + modeAsString;
        mouseXString          = "MouseX_" + modeAsString;
        mouseYString          = "MouseY_" + modeAsString;
        sprintString          = "Sprint_" + modeAsString;

        StandaloneInputModule currentModule = GameObject.Find("EventSystem").GetComponent <StandaloneInputModule>();

        currentModule.horizontalAxis = horizontalString;
        currentModule.verticalAxis   = verticalString;

        if (OnControlChange != null)
        {
            OnControlChange();
        }
    }
Example #8
0
 // Use this for initialization
 void Start()
 {
     animator = GetComponent <Animator> ();
     agent    = GetComponent <NavMeshAgent> ();
     body     = GetComponent <Rigidbody> ();
     cc       = GetComponent <CharacterController> ();
     if (mode == ControllerMode.Auto)
     {
         if (agent != null)
         {
             mode = ControllerMode.NavmeshAgent;
         }
         else if (body != null)
         {
             mode = ControllerMode.Rigidbody;
         }
         else if (cc != null)
         {
             mode = ControllerMode.CharacterController;
         }
         else
         {
             mode = ControllerMode.None;
         }
     }
 }
Example #9
0
        void DisplayOptionsScreen(ControllerMode mode)
        {
            //Hide all screens
            DeactivateAllScreens();

            // Hide all Arrows
            DeactivateAllArrows();

            // Single Player
            if (mode == ControllerMode.SINGLE_PLAYER)
            {
                optionSingle.SetActive(true);

                //Arrows
                arrowRight.SetActive(true);
            }

            // Multiplayer
            else if (mode == ControllerMode.MULTI_PLAYER)
            {
                optionMulti.SetActive(true);

                //Arrows
                arrowRight.SetActive(true);
                arrowLeft.SetActive(true);
            }

            else if (mode == ControllerMode.AI_PLAYER)
            {
                optionAuto.SetActive(true);

                //Arrows
                arrowLeft.SetActive(true);
            }
        }
Example #10
0
        /// <summary>
        /// Sends a new mode to PLC.
        /// </summary>
        /// <param name="newControllerMode">The new mode.</param>
        public void SendMode(ControllerMode newControllerMode)
        {
            //ControllerMode = newControllerMode;
            //            var modeTag = new Tag(PlcCIfPath + "." + NamingConventions.CommonInterfaceControllerMode, string.Empty, "INT");
            var modeTag = new Tag(PlcControllerPath + "." + NamingConventions.CommonInterface + "." + NamingConventions.CommonInterfaceControllerMode, Scope, "INT");

            _tagController.WriteTag(modeTag, (int)newControllerMode);
        }
Example #11
0
    bool IsMobile()
    {
#if UNITY_IOS || UNITY_ANDROID
        mode = ControllerMode.mobile;
        return(true);
#elif UNITY_STANDALONE
        return(false);
#endif
    }
Example #12
0
 private void ControllerButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
 {
     if (_controllerMode == ControllerMode.rotate)
     {
         _controllerMode = ControllerMode.zoom;
     }
     else
     {
         _controllerMode = ControllerMode.rotate;
     }
 }
Example #13
0
        /// <summary>
        /// Initializes the controller given the initialization mode and pin numbering scheme
        /// </summary>
        /// <param name="mode">The mode.</param>
        /// <returns>True when successful.</returns>
        /// <exception cref="PlatformNotSupportedException">
        /// This library does not support the platform
        /// </exception>
        /// <exception cref="InvalidOperationException">Library was already Initialized</exception>
        /// <exception cref="ArgumentException">The init mode is invalid</exception>
        private bool Initialize(ControllerMode mode)
        {
            if (Runtime.OS != Swan.OperatingSystem.Unix)
            {
                throw new PlatformNotSupportedException("This library does not support the platform");
            }

            lock (SyncRoot)
            {
                if (IsInitialized)
                {
                    throw new InvalidOperationException($"Cannot call {nameof(Initialize)} more than once.");
                }

                Environment.SetEnvironmentVariable(WiringPiCodesEnvironmentVariable, "1", EnvironmentVariableTarget.Process);
                int setpuResult;

                switch (mode)
                {
                case ControllerMode.DirectWithWiringPiPins:
                {
                    setpuResult = WiringPi.WiringPiSetup();
                    break;
                }

                case ControllerMode.DirectWithBcmPins:
                {
                    setpuResult = WiringPi.WiringPiSetupGpio();
                    break;
                }

                case ControllerMode.DirectWithHeaderPins:
                {
                    setpuResult = WiringPi.WiringPiSetupPhys();
                    break;
                }

                case ControllerMode.FileStreamWithHardwarePins:
                {
                    setpuResult = WiringPi.WiringPiSetupSys();
                    break;
                }

                default:
                {
                    throw new ArgumentException($"'{mode}' is not a valid initialization mode.");
                }
                }

                Mode = setpuResult == 0 ? mode : ControllerMode.NotInitialized;
                return(IsInitialized);
            }
        }
Example #14
0
 public void Reset()
 {
     CurrentMode = ControllerMode.StandyBy;
     foreach (var i in m_AnimatorStates)
     {
         if (i.animator != null)
         {
             i.animator.Play(i.idleName);
         }
     }
     m_ForceFieldController?.Reset();
     m_HighlightController?.Reset();
 }
Example #15
0
 public void SetGeneralMode()
 {
     try
     {
         var commandOut = BuildCommand(genMode);
         serialPort.Write(commandOut, 0, commandOut.Length);
         Thread.Sleep(600);
         controllerMode = ControllerMode.GenMode;
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #16
0
 public void SetCommunicationMode()
 {
     try
     {
         var commandOut = BuildCommand(comMode);
         serialPort.Write(commandOut, 0, commandOut.Length);
         System.Threading.Thread.Sleep(50);
         controllerMode = ControllerMode.CommMode;
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #17
0
        public void TurnManualModeOn()
        {
            this.CoffeeState    = CoffeeState.None;
            this.ControllerMode = ControllerMode.Manual;
            Led.Write(true);

            if (Relay == null)
            {
                Relay = new OutputPort(Pins.GPIO_PIN_D9, true);
            }

            ModeUptime = new TimeSpan();
            this.TurnOffCoffeeTimer.Dispose();
            this.TurnOffCoffeeTimer = null;
        }
Example #18
0
        public VSPController(ControllerMode controller_mode, ControllerType controller_type) : base()
        {
            BorderStyle = BorderStyle.Fixed3D;
            //Size = new System.Drawing.Size(340,164);

            c_VspView          = new vspView(c_ScrollBar, controller_mode, controller_type);
            c_VspView.Size     = new System.Drawing.Size(320, Height - 4);
            c_VspView.Location = new System.Drawing.Point(0, 0);

            c_ScrollBar.Size          = new System.Drawing.Size(16, Height - 4);
            c_ScrollBar.Location      = new System.Drawing.Point(320, 0);
            c_ScrollBar.ValueChanged += new EventHandler(c_VspView.OnScroll);

            Controls.Add(c_VspView);
            Controls.Add(c_ScrollBar);
        }
Example #19
0
        public VSPController(ControllerMode controller_mode, ControllerType controller_type)
            : base()
        {
            BorderStyle = BorderStyle.Fixed3D;
            //Size = new System.Drawing.Size(340,164);

            c_VspView = new vspView(c_ScrollBar,controller_mode,controller_type);
            c_VspView.Size = new System.Drawing.Size(Global.VSP_SIZE_PIXELS,Height-4);
            c_VspView.Location = new System.Drawing.Point(0,0);

            c_ScrollBar.Size = new System.Drawing.Size(16,Height-4);
            c_ScrollBar.Location = new System.Drawing.Point(Global.VSP_SIZE_PIXELS,0);
            c_ScrollBar.ValueChanged += new EventHandler(c_VspView.OnScroll);

            Controls.Add(c_VspView);
            Controls.Add(c_ScrollBar);
        }
Example #20
0
 //----------------------------------------------------------------------------------------------
 private void FigureOutWorldMoveMode()
 {
     float detectionThreshold = 9.8f; // this is probably too low -- we'll figure it out via trial and error
     DisplayMessage("Accelertion = " + GvrController.Accel.y.ToString());
     // flick detection.
     if (GvrController.Accel.y  > detectionThreshold)
     {
         // flip the movemode
         if (m_worldMode == ControllerMode.MovePlayer)
         {
             m_worldMode = ControllerMode.MoveObject;
         }
         else
         {
             m_worldMode = ControllerMode.MovePlayer;
         }
     }
 }
Example #21
0
        public void SetAIControllerMode(ControllerMode controllerMode)
        {
            aiControllerMode = controllerMode;
            switch (controllerMode)
            {
            case ControllerMode.None:
                AISpeed = AIController.SpeedLevel.None;
                Actor.Sensor.AIPerceptionLevel = AIRadar.PerceptionLevel.None;
                break;

            case ControllerMode.Explore:
                AISpeed = AIController.SpeedLevel.Walking;
                Actor.Sensor.AIPerceptionLevel = AIRadar.PerceptionLevel.High;
                break;

            case ControllerMode.Loot:
                AISpeed = AIController.SpeedLevel.Jogging;
                Actor.Sensor.AIPerceptionLevel = AIRadar.PerceptionLevel.High;
                break;

            case ControllerMode.Combat:
                AISpeed = AIController.SpeedLevel.Jogging;
                Actor.Sensor.AIPerceptionLevel = AIRadar.PerceptionLevel.High;
                break;

            case ControllerMode.Flee:
                AISpeed = AIController.SpeedLevel.Running;
                Actor.Sensor.AIPerceptionLevel = AIRadar.PerceptionLevel.High;
                break;

            case ControllerMode.Hunt:
                AISpeed = AIController.SpeedLevel.Running;
                Actor.Sensor.AIPerceptionLevel = AIRadar.PerceptionLevel.High;
                break;

            case ControllerMode.DeathCircle:
                AISpeed = AIController.SpeedLevel.Running;
                Actor.Sensor.AIPerceptionLevel = AIRadar.PerceptionLevel.High;
                break;

            default:
                break;
            }
        }
        public PSE_USB(Machine machine, ControllerMode mode = ControllerMode.Host) : base(machine)
        {
            this.mode = mode;

            addressToDeviceCache = new TwoWayDictionary <byte, IUSBDevice>();

            fifoFromDeviceToHost         = new Queue <byte> [NumberOfEndpoints];
            fifoFromHostToDevice         = new Queue <byte> [NumberOfEndpoints];
            receiveDeviceAddress         = new IValueRegisterField[NumberOfEndpoints];
            transmitDeviceAddress        = new IValueRegisterField[NumberOfEndpoints];
            requestInTransaction         = new IFlagRegisterField[NumberOfEndpoints];
            transmitTargetEndpointNumber = new IValueRegisterField[NumberOfEndpoints];
            receiveTargetEndpointNumber  = new IValueRegisterField[NumberOfEndpoints];

            for (var i = 0; i < NumberOfEndpoints; i++)
            {
                fifoFromDeviceToHost[i] = new Queue <byte>();
                fifoFromHostToDevice[i] = new Queue <byte>();
            }

            MainIRQ = new GPIO();
            DmaIRQ  = new GPIO();

            byteRegisters       = new ByteRegisterCollection(this);
            wordRegisters       = new WordRegisterCollection(this);
            doubleWordRegisters = new DoubleWordRegisterCollection(this);

            var gate = new GPIOGate(MainIRQ);

            usbInterruptsManager = new InterruptManager <UsbInterrupt>(this, gate.GetGPIO(), "main");
            txInterruptsManager  = new InterruptManager <TxInterrupt>(this, gate.GetGPIO(), "main");
            rxInterruptsManager  = new InterruptManager <RxInterrupt>(this, gate.GetGPIO(), "main");

            DefineCommonRegisters();
            DefineIndexedRegisters();
            DefineFifoRegisters();
            DefineControlAndStatusRegisters();
            DefineNonIndexedEndpointControlAndStatusRegisters();
            DefineMultipointControlAndStatusRegisters();

            ResetInterrupts();
        }
Example #23
0
        private static Mock <IController> Controller(
            Mock <IAlarm> activeAlarm,
            IEnumerable <Tag> actualValues,
            IEnumerable <IController> children,
            IEnumerable <ICommand> commands,
            IEnumerable <Tag> configurations,
            ControllerMode controllerMode,
            string currentState,
            string currentSubState,
            bool enableForcing,
            int id,
            bool isEnabled,
            bool isSimulation,
            string name,
            string fullname,
            IEnumerable <Tag> parameters,
            string type)
        {
            var controller = new Mock <IController>();

            if (activeAlarm != null)
            {
                controller.Setup(c => c.ActiveAlarm).Returns(activeAlarm.Object);
            }
            controller.Setup(c => c.ActualValues).Returns(actualValues);
            controller.Setup(c => c.Childs).Returns(children);
            controller.Setup(c => c.Commands).Returns(commands);
            controller.Setup(c => c.Configurations).Returns(configurations);
            controller.Setup(c => c.ControllerMode).Returns(controllerMode);
            controller.Setup(c => c.CurrentState).Returns(currentState);
            controller.Setup(c => c.CurrentSubState).Returns(currentSubState);
            controller.Setup(c => c.EnableForcing).Returns(enableForcing);
            controller.Setup(c => c.Id).Returns(id);
            controller.Setup(c => c.IsEnabled).Returns(isEnabled);
            controller.Setup(c => c.IsSimulation).Returns(isSimulation);
            controller.Setup(c => c.Name).Returns(name);
            controller.Setup(c => c.FullName).Returns(fullname);
            controller.Setup(c => c.Parameters).Returns(parameters);
            controller.Setup(c => c.Type).Returns(type);
            return(controller);
        }
Example #24
0
 private static Mock <IController> ChildController(
     Mock <IAlarm> activeAlarm          = null,
     IEnumerable <Tag> actualValues     = null,
     IEnumerable <IController> children = null,
     IEnumerable <ICommand> commands    = null,
     IEnumerable <Tag> configurations   = null,
     ControllerMode controllerMode      = ControllerMode.Manual,
     string currentState    = "Ready",
     string currentSubState = "Sub-Ready",
     bool enableForcing     = false,
     int id                       = 2,
     bool isEnabled               = false,
     bool isSimulation            = false,
     string name                  = "Child",
     string fullname              = "Child",
     IEnumerable <Tag> parameters = null,
     string type                  = "ChildType")
 {
     return(Controller(activeAlarm, actualValues, children, commands, configurations, controllerMode, currentState,
                       currentSubState, enableForcing, id, isEnabled, isSimulation, name, fullname, parameters, type));
 }
        public void ConfigFighterControllers(int playerID, ControllerMode mode)
        {
            // Get Controller Components

            SideScrollerController controller1 = fighter1.GetComponent <SideScrollerController>();
            SideScrollerController controller2 = fighter2.GetComponent <SideScrollerController>();

            if (controller1 == null || controller2 == null)
            {
                Debug.LogAssertion(" No Controlers Found ");
                return;
            }

            //Config AI Players
            if (mode == ControllerMode.AI_PLAYER)
            {
                if (playerID == 1)
                {
                    controller1.SetCharacterControllerAsAI(standardProfile);
                }
                if (playerID == 2)
                {
                    controller2.SetCharacterControllerAsAI(standardProfile);
                }

                return;
            }

            // Config Local Players
            if (playerID == 1)
            {
                controller1.currentMode = mode;
            }
            if (playerID == 2)
            {
                controller2.currentMode = mode;
            }
            return;
        }
Example #26
0
        /// <summary>
        ///     Instantiates a new PID controller class. The <see cref="Run" /> method must be called to trigger computation.
        /// </summary>
        /// <param name="samplingRate">
        ///     The rate at which the algorithm will compute a new output once <see cref="Run" /> is
        ///     called.
        /// </param>
        /// <param name="outputMinimum">The minimum value the output can be written to. The output influences the process value.</param>
        /// <param name="outputMaximum">The maximum value the output can be written to. The output influences the process value.</param>
        /// <param name="readProcess">
        ///     A function to read the process value. The process value is what you are attempting to
        ///     control.
        /// </param>
        /// <param name="readOutput">A function to read the output. The output influences the process value.</param>
        /// <param name="writeOutput">A function to write to the output. The output influences the process value.</param>
        /// <param name="readSetPoint">A function to read the target set-point for the process.</param>
        /// <param name="proportionalGain">The proportional gain to use.</param>
        /// <param name="integralGain">The integral gain to use.</param>
        /// <param name="derivativeGain">The derivative gain to use.</param>
        /// <param name="controllerDirection">The direction to control the output if you want the process to increase in value..</param>
        /// <param name="controllerMode">The mode to start out the PID controller in.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <see cref="readProcess" /> or <see cref="readOutput" /> or <see cref="writeOutput" /> or
        ///     <see cref="readSetPoint" /> are null.
        /// </exception>
        public PidController(string name, TimeSpan samplingRate, float outputMinimum, float outputMaximum,
                             Func <int> readProcess, Func <ulong> readOutput, Action <ulong> writeOutput, Func <int> readSetPoint,
                             float proportionalGain, float integralGain, float derivativeGain,
                             ControllerDirection controllerDirection, ControllerMode controllerMode)
        {
            if (readProcess == null)
            {
                throw new ArgumentNullException(nameof(readProcess), "Read process must not be null.");
            }
            if (readOutput == null)
            {
                throw new ArgumentNullException(nameof(readOutput), "Read output must not be null.");
            }
            if (readSetPoint == null)
            {
                throw new ArgumentNullException(nameof(readSetPoint), "Read set-point must not be null.");
            }
            if (writeOutput == null)
            {
                throw new ArgumentNullException(nameof(writeOutput), "Write output must not be null.");
            }

            _name        = name;
            SamplingRate = samplingRate;
            SetOutputLimits(outputMinimum, outputMaximum);
            _readProcess        = readProcess;
            _readOutput         = readOutput;
            _writeOutput        = writeOutput;
            _readSetPoint       = readSetPoint;
            ProportionalGain    = proportionalGain;
            IntegralGain        = integralGain;
            DerivativeGain      = derivativeGain;
            ControllerDirection = controllerDirection;
            ControllerMode      = controllerMode;

            _computeTimer = new Timer(callback => Compute(), null, Timeout.Infinite, Timeout.Infinite);
        }
Example #27
0
    public async void PlayAnimation()
    {
        if (CurrentMode == ControllerMode.Play)
        {
            Reset();
        }
        CurrentMode = ControllerMode.Play;

        for (int i = 0; i < m_AnimatorStates.Length; i++)
        {
            var state = m_AnimatorStates[i];
            if (state == null ||
                state.animator == null ||
                state.stateName == null)
            {
                continue;
            }

            state.animator.Play(state.stateName);
            var info         = state.animator.GetCurrentAnimatorStateInfo(0);
            int milliseconds = (int)info.length * 1000 - 500;
            await Task.Delay(milliseconds);
        }
    }
Example #28
0
    protected override void Awake()
    {
        base.Awake();

        List <ControllerMode> tempControllerModes = new List <ControllerMode>(controllerModesRecords.Select(modeRecord => modeRecord.GetControllerMode()));

        // starting controller mode is that with highest VirtualCamera priority
        ControllerMode firstControllerMode = tempControllerModes.Aggregate(tempControllerModes.First(), (controllerModeWithHighestPriority, controllerModeRecord) =>
        {
            if (controllerModeRecord.VirtualCamera.Priority > controllerModeWithHighestPriority.VirtualCamera.Priority)
            {
                return(controllerModeRecord);
            }
            else
            {
                return(controllerModeWithHighestPriority);
            }
        });

        tempControllerModes.Remove(firstControllerMode);
        tempControllerModes.Insert(0, firstControllerMode);

        ControllerModes = new Queue <ControllerMode>(tempControllerModes);
    }
Example #29
0
 void XboneController()
 {
     controllerMode = mode = ControllerMode.xbone;
 }
Example #30
0
 void Xbox360Controller()
 {
     controllerMode = mode = ControllerMode.xbox;
 }
Example #31
0
 void Ps4Controller()
 {
     controllerMode = mode = ControllerMode.ps4;
 }
Example #32
0
 public void SetControllerMode(ControllerMode controller_mode)
 {
     c_VspView.ControllerMode = controller_mode;
 }