Exemplo n.º 1
0
        public override Int32 Begin()
        {
#if DEBUG
            Debug.Print(ToString() + " [BEGIN]");
#endif
            /* Setup Left and Right followers */
            RightSlave.SetControlMode(CTRE.TalonSrx.ControlMode.kFollower);
            RightSlave.Set(RIGHT_TALONSRX_ID);

            LeftSlave.SetControlMode(CTRE.TalonSrx.ControlMode.kFollower);
            LeftSlave.Set(LEFT_TALONSRX_ID);

            /* Configure the Left TalonSRX */
            Left.SetInverted(LEFT_INVT);
            Left.ConfigLimitMode(CTRE.TalonSrx.LimitMode.kLimitMode_SrxDisableSwitchInputs);
            Left.ConfigFwdLimitSwitchNormallyOpen(true);
            Left.ConfigRevLimitSwitchNormallyOpen(true);
            LeftSlave.ConfigLimitMode(CTRE.TalonSrx.LimitMode.kLimitMode_SrxDisableSwitchInputs);
            LeftSlave.ConfigFwdLimitSwitchNormallyOpen(true);
            LeftSlave.ConfigRevLimitSwitchNormallyOpen(true);

            /* Configure the Right TalonSRX */
            Right.SetInverted(!LEFT_INVT);
            Right.ConfigLimitMode(CTRE.TalonSrx.LimitMode.kLimitMode_SrxDisableSwitchInputs);
            Right.ConfigFwdLimitSwitchNormallyOpen(true);
            Right.ConfigRevLimitSwitchNormallyOpen(true);
            RightSlave.ConfigLimitMode(CTRE.TalonSrx.LimitMode.kLimitMode_SrxDisableSwitchInputs);
            RightSlave.ConfigFwdLimitSwitchNormallyOpen(true);
            RightSlave.ConfigRevLimitSwitchNormallyOpen(true);

            if (USE_SPEED_MODE)
            {
                /* Setup Left and Right leaders with PID */
                Right.SetFeedbackDevice(CTRE.TalonSrx.FeedbackDevice.QuadEncoder);
                Right.SetSensorDirection(false);
                Right.ConfigEncoderCodesPerRev(RIGHT_EncTPR);

                Right.SetControlMode(CTRE.TalonSrx.ControlMode.kSpeed);
                Right.SetPID(0, RIGHT_P, RIGHT_I, RIGHT_D);
                Right.SetF(0, RIGHT_F);

                Left.SetFeedbackDevice(CTRE.TalonSrx.FeedbackDevice.QuadEncoder);
                Left.SetSensorDirection(false);
                Left.ConfigEncoderCodesPerRev(LEFT_EncTPR);

                Left.SetControlMode(CTRE.TalonSrx.ControlMode.kSpeed);
                Left.SetPID(0, LEFT_P, LEFT_I, LEFT_D);
                Left.SetF(0, LEFT_F);
            }

            /* Enable the TalonSRXs */
            Right.Enable();
            RightSlave.Enable();
            Left.Enable();
            LeftSlave.Enable();
            return(0);
        }
Exemplo n.º 2
0
        public override Int32 Begin()
        {
#if DEBUG
            Debug.Print(ToString() + " [BEGIN]");
#endif
            // TODO: Set and check config for winch and dog.
            Winch.ConfigLimitMode(CTRE.TalonSrx.LimitMode.kLimitMode_SwitchInputsOnly);
            Dog.ConfigLimitMode(CTRE.TalonSrx.LimitMode.kLimitMode_SwitchInputsOnly);

            Winch.ConfigFwdLimitSwitchNormallyOpen(true);
            Winch.ConfigRevLimitSwitchNormallyOpen(false);

            Dog.ConfigFwdLimitSwitchNormallyOpen(false);
            Dog.ConfigRevLimitSwitchNormallyOpen(false);

            Winch.Enable();
            Dog.Enable();
            return(0);
        }