Ejemplo n.º 1
0
        public MainWindow(PIDController _followDirectionPidControllerAngularSpeed, PIDController _followDirectionPidControllerLinearSpeed, string soundsBasePath = null)
        {
            followDirectionPidControllerAngularSpeed = _followDirectionPidControllerAngularSpeed;
            followDirectionPidControllerLinearSpeed = _followDirectionPidControllerLinearSpeed;

            soundsBasePathDefault = soundsBasePath;

            InitializeComponent();

            CreateMapWindow();

            soundsBasePathLabel.Content = "Sound files folder: " + soundsBasePathDefault;

            PopulatePlaySoundCombo();

            this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// copies all members to a target
        /// </summary>
        /// <param name="target"></param>
        public virtual void CopyTo(IDssSerializable target)
        {
            // throw new NotImplementedException("class PIDController does not have to implement IDssSerializable - do not call CopyTo()");

            PIDController typedTarget = target as PIDController;

            if (typedTarget == null)
            {
                throw new ArgumentException("PIDController::CopyTo({0}) requires type {0}", this.GetType().FullName);
            }

            typedTarget.Kp = this.Kp;
            typedTarget.Ki = this.Ki;
            typedTarget.Kd = this.Kd;
            typedTarget.MaxIntegralError     = this.MaxIntegralError;
            typedTarget.MaxUpdateIntervalSec = this.MaxUpdateIntervalSec;
            typedTarget.MaxPidValue          = this.MaxPidValue;
            typedTarget.MinPidValue          = this.MinPidValue;
            typedTarget.Name                     = this.Name;
            typedTarget.PreviousError            = this.PreviousError;
            typedTarget.CurrentError             = this.CurrentError;
            typedTarget.DerivativeErrorPerSecond = this.DerivativeErrorPerSecond;
            typedTarget.IntegralError            = this.IntegralError;
        }
        public void Init()
        {
            Dropping = false;

            IsTurning = false;
            LastTurnStarted = DateTime.MinValue;
            LastTurnCompleted = DateTime.MinValue;

            if (WheelsEncoderState == null)
            {
                WheelsEncoderState = new WheelsEncoderState();
            }

            if (collisionState == null)
            {
                collisionState = new CollisionState();
            }

            if (gpsState == null)
            {
                gpsState = new GpsState();
            }

            if (MostRecentAnalogValues == null)
            {
                MostRecentAnalogValues = new proxibrick.AnalogDataDssSerializable() { TimeStamp = DateTime.MinValue };
            }

            MostRecentLaserTimeStamp = DateTime.Now;

            if (VoiceCommandState == null)
            {
                VoiceCommandState = new VoiceCommandState();
            }

            int MAX_HUMANS_TO_TRACK = 7;    // FrameProcessor preallocates 7

            HumanInteractionStates = new HumanInteractionState[MAX_HUMANS_TO_TRACK];

            for (int i = 0; i < HumanInteractionStates.Length; i++)
            {
                HumanInteractionStates[i] = new HumanInteractionState();
            }

            if (followDirectionPidControllerAngularSpeed == null)
            {
                followDirectionPidControllerAngularSpeed = new PIDController()
                    {
                        Name = "AngularSpeed",
                        MaxIntegralError = 180.0d,          // degrees; anything more causes controller reset (error too large)
                        MaxUpdateIntervalSec = 10.0d,       // ms; anything more causes controller reset (interval too long)
                        MaxPidValue = 100.0d,               // pid factor upper limit
                        MinPidValue = 0.0d,                 // pid factor lower limit

                        Kp = PIDController.ProportionalGainDefault,             // Proportional constant, 3.0
                        Ki = PIDController.IntegralGainDefault,                 // Integral constant, 0.1
                        Kd = PIDController.DerivativeGainDefault                // Derivative constant, 0.5
                    };
            }

            if (followDirectionPidControllerLinearSpeed == null)
            {
                followDirectionPidControllerLinearSpeed = new PIDController()
                    {
                        Name = "LinearSpeed",
                        MaxIntegralError = 2000.0d,         // mm/sec; anything more causes controller reset (error too large)
                        MaxUpdateIntervalSec = 10.0d,       // ms; anything more causes controller reset (interval too long)
                        MaxPidValue = 1000.0d,              // pid factor upper limit
                        MinPidValue = 0.0d,                 // pid factor lower limit

                        Kp = PIDController.ProportionalGainDefault,             // Proportional constant, 3.0
                        Ki = PIDController.IntegralGainDefault,                 // Integral constant, 0.1
                        Kd = PIDController.DerivativeGainDefault                // Derivative constant, 0.5
                    };
            }

            if (PowerScale == 0.0d)
            {
                PowerScale = 0.5d;
            }
        }