コード例 #1
0
        public PIDController(double Kp, double Ki, double Kd, double Kf,
            IPIDSource source, IPIDOutput output,
            double period)
        {
            if (source == null)
                throw new ArgumentNullException(nameof(source), "Null PIDSource was given");
            if (output == null)
                throw new ArgumentNullException(nameof(output), "Null PIDOutput was given");

            m_controlLoop = new Notifier(CallCalculate, this);

            m_P = Kp;
            m_I = Ki;
            m_D = Kd;
            m_F = Kf;

            m_ipidInput = source;
            m_ipidOutput = output;
            m_period = period;

            m_controlLoop.StartPeriodic(m_period);

            s_instances++;
            HLUsageReporting.ReportPIDController(s_instances);

            m_toleranceType = ToleranceType.NoTolerance;
        }
コード例 #2
0
 /// <summary>
 /// Creates a new Managed Compressor, which will turn off when the volrage is below the specified level.
 /// </summary>
 /// <param name="voltageThreshold">Voltage to turn off the compressor at</param>
 /// <param name="Period">time to wait between on and off values.</param>
 public ManagedCompressor(double voltageThreshold, double period)
 {
     m_period = period;
     VoltageThreshold = voltageThreshold;
     m_periodic = new Notifier(Update);
     UseTimer = true;
 }
コード例 #3
0
        public override void RobotInit()
        {
            DateTime old = DateTime.Now;

            notifier = new Notifier(() =>
            {
                DateTime current = DateTime.Now;
                var delta = current - old;
                Console.WriteLine(delta);
                old = current;
            });

            notifier.StartPeriodic(0.1);
        }
コード例 #4
0
ファイル: PIDController.cs プロジェクト: mwoden/WPILib
        /// <summary>
        /// Creates a new PID object with the given contants for P, I, D and F.
        /// </summary>
        /// <param name="kp">The proportional coefficient.</param>
        /// <param name="ki">The integral coefficient</param>
        /// <param name="kd">The derivative coefficient</param>
        /// <param name="kf">The feed forward term.</param>
        /// <param name="source">The PIDSource object that is used to get values.</param>
        /// <param name="output">The PIDOutput object that is set to the output percentage.</param>
        /// <param name="period">The loop time for doing calculations.</param>
        public PIDController(double kp, double ki, double kd, double kf,
            IPIDSource source, IPIDOutput output,
            double period)
        {
            if (source == null)
                throw new ArgumentNullException(nameof(source), "Null PIDSource was given");
            if (output == null)
                throw new ArgumentNullException(nameof(output), "Null PIDOutput was given");

            CalculateCallback = Calculate;
            m_controlLoop = new Notifier(CalculateCallback);
            m_setpointTimer = new Timer();
            m_setpointTimer.Start();

            m_P = kp;
            m_I = ki;
            m_D = kd;
            m_F = kf;

            PIDInput = source;
            PIDOutput = output;
            m_period = period;

            m_controlLoop.StartPeriodic(m_period);

            s_instances++;
            HLUsageReporting.ReportPIDController(s_instances);

            m_toleranceType = ToleranceType.NoTolerance;
            m_buf = new Queue<double>();
        }
コード例 #5
0
ファイル: PIDController.cs プロジェクト: mwoden/WPILib
 /// <inheritdoc/>
 public void Dispose()
 {
     m_controlLoop.Stop();
     lock (this)
     {
         PIDOutput = null;
         PIDInput = null;
         m_controlLoop.Dispose();
         m_controlLoop = null;
     }
     Table?.RemoveTableListener(this);
 }