コード例 #1
0
 public void EnhancedEncoderSetDistancePerPulseTest()
 {
     using (Encoder e = new Encoder(0, 1))
     {
         e.SetDistancePerPulse(4, 256);
         Assert.AreEqual(0.04908, e.DistancePerPulse, 0.0001);
     }
 }
コード例 #2
0
 public static void TestRotational()
 {
     using (Encoder left = new Encoder(0, 1), right = new Encoder(2, 3))
     {
         DriveEncoders e = new DriveEncoders(left, right);
         SimData.Encoder[0].Count = 4000;
         SimData.Encoder[1].Count = -4000;
         Assert.AreEqual(1000, e.TurnDistance);
     }
 }
コード例 #3
0
        /// <summary>
        /// Instantiates the Motor COntrollers, Encoders, Gyroscope.
        /// </summary>
        public Drive()
        {
            #region Instantiating
            L1 = new RampMotor<Talon>(Constants.Drive_L1Channel);
            L2 = new RampMotor<Talon>(Constants.Drive_L2Channel);
            L3 = new RampMotor<Talon>(Constants.Drive_L3Channel);
            R1 = new RampMotor<Talon>(Constants.Drive_R1Channel);
            R2 = new RampMotor<Talon>(Constants.Drive_R2Channel);
            R3 = new RampMotor<Talon>(Constants.Drive_R3Channel);

            LShift = new Solenoid(Constants.Drive_LShiftChannel);
            RShift = new Solenoid(Constants.Drive_RShiftChannel);

            LEncode = new Encoder(Constants.Drive_LEncoderAChannel, Constants.Drive_LEncoderBChannel);
            REncode = new Encoder(Constants.Drive_REncoderAChannel, Constants.Drive_REncoderBChannel);

            LSpeedFilter = new InputFilter(0);
            RSpeedFilter = new InputFilter(0);

            gyro = new Gyro(Constants.Drive_GyroChannel);
            #endregion

            //Invert the Right Side Motors and Encoder
            R1.Inverted = true;
            R2.Inverted = true;
            R3.Inverted = true;

            REncode.ReverseDirection = true;

            L1.MaxChange = Constants.Drive_MaxPowerChange;
            L2.MaxChange = Constants.Drive_MaxPowerChange;
            L3.MaxChange = Constants.Drive_MaxPowerChange;
            R1.MaxChange = Constants.Drive_MaxPowerChange;
            R2.MaxChange = Constants.Drive_MaxPowerChange;
            R3.MaxChange = Constants.Drive_MaxPowerChange;

            gyro.Reset();

            LShift.Set(false);
            RShift.Set(false);

            //Secondary Motors are set to the same max acceleration as the primary motors by default, until we get these numbers tuned.
            shiftingMotorValue = Constants.Drive_MaxPowerChange;
        }
コード例 #4
0
 private static void AddEncoder(string key, Encoder encoder)
 {
     EncoderKeys.Add(key);
     Encoders.Add(key, encoder);
 }
コード例 #5
0
 /// <summary>
 /// Removes the <see cref="Encoder"/> from this glitch filter
 /// </summary>
 /// <param name="encoder">The <see cref="Encoder"/> to remove.</param>
 public void Remove(Encoder encoder)
 {
     Remove(encoder.m_aSource);
     Remove(encoder.m_bSource);
 }
コード例 #6
0
 /// <summary>
 /// Assigns the <see cref="Encoder"/> to this glitch filter
 /// </summary>
 /// <param name="encoder">The <see cref="Encoder"/> to add.</param>
 public void Add(Encoder encoder)
 {
     Add(encoder.m_aSource);
     Add(encoder.m_bSource);
 }
コード例 #7
0
 /// <summary>
 /// Encapsulates a Left and Right Encoder, with the right encoder reversed.
 /// </summary>
 /// <param name="left">Left Encoder</param>
 /// <param name="right">Right Encoder</param>
 public DriveEncoders(Encoder left, Encoder right)
 {
     Left = left;
     Right = right;
     Right.SetReverseDirection(true);
 }
コード例 #8
0
        private static void InitializeElevator()
        {
            ElevatorEncoder = new Encoder(8, 9, false, EncodingType.K1X);
            ElevatorEncoder.DistancePerPulse = 1;

            TopLimitSwitch = new DigitalInput(7);
            BottomLimitSwitch = new DigitalInput(4);

            var setpoints = new List<Setpoint>
            {
                new Setpoint(2, 0),
                new Setpoint(4, 325),
                new Setpoint(3, 750),
                new Setpoint(5, 1475),
                new Setpoint(8, 1200),
                new Setpoint(9, 2800)
            };

            Setpoints = new SetpointMapWrapper(setpoints);
        }