Java Code Examples for com.ctre.phoenix.motorcontrol.can.TalonSRX#overrideSoftLimitsEnable()

The following examples show how to use com.ctre.phoenix.motorcontrol.can.TalonSRX#overrideSoftLimitsEnable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TalonSRXFactory.java    From FRC-2019-Public with MIT License 4 votes vote down vote up
public static TalonSRX createTalon(int id, Configuration config) {
    TalonSRX talon = new LazyTalonSRX(id);
    talon.set(ControlMode.PercentOutput, 0.0);

    talon.changeMotionControlFramePeriod(config.MOTION_CONTROL_FRAME_PERIOD_MS);
    talon.clearMotionProfileHasUnderrun(kTimeoutMs);
    talon.clearMotionProfileTrajectories();

    talon.clearStickyFaults(kTimeoutMs);

    talon.configForwardLimitSwitchSource(LimitSwitchSource.FeedbackConnector,
            LimitSwitchNormal.Disabled, kTimeoutMs);
    talon.configReverseLimitSwitchSource(LimitSwitchSource.FeedbackConnector,
            LimitSwitchNormal.Disabled, kTimeoutMs);
    talon.overrideLimitSwitchesEnable(config.ENABLE_LIMIT_SWITCH);

    // Turn off re-zeroing by default.
    talon.configSetParameter(
            ParamEnum.eClearPositionOnLimitF, 0, 0, 0, kTimeoutMs);
    talon.configSetParameter(
            ParamEnum.eClearPositionOnLimitR, 0, 0, 0, kTimeoutMs);

    talon.configNominalOutputForward(0, kTimeoutMs);
    talon.configNominalOutputReverse(0, kTimeoutMs);
    talon.configNeutralDeadband(config.NEUTRAL_DEADBAND, kTimeoutMs);

    talon.configPeakOutputForward(1.0, kTimeoutMs);
    talon.configPeakOutputReverse(-1.0, kTimeoutMs);

    talon.setNeutralMode(config.NEUTRAL_MODE);

    talon.configForwardSoftLimitThreshold(config.FORWARD_SOFT_LIMIT, kTimeoutMs);
    talon.configForwardSoftLimitEnable(config.ENABLE_SOFT_LIMIT, kTimeoutMs);

    talon.configReverseSoftLimitThreshold(config.REVERSE_SOFT_LIMIT, kTimeoutMs);
    talon.configReverseSoftLimitEnable(config.ENABLE_SOFT_LIMIT, kTimeoutMs);
    talon.overrideSoftLimitsEnable(config.ENABLE_SOFT_LIMIT);

    talon.setInverted(config.INVERTED);
    talon.setSensorPhase(config.SENSOR_PHASE);

    talon.selectProfileSlot(0, 0);

    talon.configVelocityMeasurementPeriod(config.VELOCITY_MEASUREMENT_PERIOD, kTimeoutMs);
    talon.configVelocityMeasurementWindow(config.VELOCITY_MEASUREMENT_ROLLING_AVERAGE_WINDOW,
            kTimeoutMs);

    talon.configOpenloopRamp(config.OPEN_LOOP_RAMP_RATE, kTimeoutMs);
    talon.configClosedloopRamp(config.CLOSED_LOOP_RAMP_RATE, kTimeoutMs);

    talon.configVoltageCompSaturation(0.0, kTimeoutMs);
    talon.configVoltageMeasurementFilter(32, kTimeoutMs);
    talon.enableVoltageCompensation(false);

    talon.enableCurrentLimit(config.ENABLE_CURRENT_LIMIT);

    talon.setStatusFramePeriod(StatusFrameEnhanced.Status_1_General,
            config.GENERAL_STATUS_FRAME_RATE_MS, kTimeoutMs);
    talon.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0,
            config.FEEDBACK_STATUS_FRAME_RATE_MS, kTimeoutMs);

    talon.setStatusFramePeriod(StatusFrameEnhanced.Status_3_Quadrature,
            config.QUAD_ENCODER_STATUS_FRAME_RATE_MS, kTimeoutMs);
    talon.setStatusFramePeriod(StatusFrameEnhanced.Status_4_AinTempVbat,
            config.ANALOG_TEMP_VBAT_STATUS_FRAME_RATE_MS, kTimeoutMs);
    talon.setStatusFramePeriod(StatusFrameEnhanced.Status_8_PulseWidth,
            config.PULSE_WIDTH_STATUS_FRAME_RATE_MS, kTimeoutMs);

    talon.setControlFramePeriod(ControlFrame.Control_3_General, config.CONTROL_FRAME_PERIOD_MS);

    return talon;
}
 
Example 2
Source File: TalonSRXFactory.java    From FRC-2018-Public with MIT License 4 votes vote down vote up
public static TalonSRX createTalon(int id, Configuration config) {
    TalonSRX talon = new LazyTalonSRX(id);
    talon.set(ControlMode.PercentOutput, 0.0);

    talon.changeMotionControlFramePeriod(config.MOTION_CONTROL_FRAME_PERIOD_MS);
    talon.clearMotionProfileHasUnderrun(kTimeoutMs);
    talon.clearMotionProfileTrajectories();

    talon.clearStickyFaults(kTimeoutMs);

    talon.configForwardLimitSwitchSource(LimitSwitchSource.FeedbackConnector,
            LimitSwitchNormal.NormallyOpen, kTimeoutMs);
    talon.configReverseLimitSwitchSource(LimitSwitchSource.FeedbackConnector,
            LimitSwitchNormal.NormallyOpen, kTimeoutMs);
    talon.overrideLimitSwitchesEnable(config.ENABLE_LIMIT_SWITCH);

    // Turn off re-zeroing by default.
    talon.configSetParameter(
            ParamEnum.eClearPositionOnLimitF, 0, 0, 0, kTimeoutMs);
    talon.configSetParameter(
            ParamEnum.eClearPositionOnLimitR, 0, 0, 0, kTimeoutMs);

    talon.configNominalOutputForward(0, kTimeoutMs);
    talon.configNominalOutputReverse(0, kTimeoutMs);
    talon.configNeutralDeadband(config.NEUTRAL_DEADBAND, kTimeoutMs);

    talon.configPeakOutputForward(1.0, kTimeoutMs);
    talon.configPeakOutputReverse(-1.0, kTimeoutMs);

    talon.setNeutralMode(config.NEUTRAL_MODE);

    talon.configForwardSoftLimitThreshold(config.FORWARD_SOFT_LIMIT, kTimeoutMs);
    talon.configForwardSoftLimitEnable(config.ENABLE_SOFT_LIMIT, kTimeoutMs);

    talon.configReverseSoftLimitThreshold(config.REVERSE_SOFT_LIMIT, kTimeoutMs);
    talon.configReverseSoftLimitEnable(config.ENABLE_SOFT_LIMIT, kTimeoutMs);
    talon.overrideSoftLimitsEnable(config.ENABLE_SOFT_LIMIT);

    talon.setInverted(config.INVERTED);
    talon.setSensorPhase(config.SENSOR_PHASE);

    talon.selectProfileSlot(0, 0);

    talon.configVelocityMeasurementPeriod(config.VELOCITY_MEASUREMENT_PERIOD, kTimeoutMs);
    talon.configVelocityMeasurementWindow(config.VELOCITY_MEASUREMENT_ROLLING_AVERAGE_WINDOW,
            kTimeoutMs);

    talon.configOpenloopRamp(config.OPEN_LOOP_RAMP_RATE, kTimeoutMs);
    talon.configClosedloopRamp(config.CLOSED_LOOP_RAMP_RATE, kTimeoutMs);

    talon.configVoltageCompSaturation(0.0, kTimeoutMs);
    talon.configVoltageMeasurementFilter(32, kTimeoutMs);
    talon.enableVoltageCompensation(false);

    talon.enableCurrentLimit(config.ENABLE_CURRENT_LIMIT);

    talon.setStatusFramePeriod(StatusFrameEnhanced.Status_1_General,
            config.GENERAL_STATUS_FRAME_RATE_MS, kTimeoutMs);
    talon.setStatusFramePeriod(StatusFrameEnhanced.Status_2_Feedback0,
            config.FEEDBACK_STATUS_FRAME_RATE_MS, kTimeoutMs);

    talon.setStatusFramePeriod(StatusFrameEnhanced.Status_3_Quadrature,
            config.QUAD_ENCODER_STATUS_FRAME_RATE_MS, kTimeoutMs);
    talon.setStatusFramePeriod(StatusFrameEnhanced.Status_4_AinTempVbat,
            config.ANALOG_TEMP_VBAT_STATUS_FRAME_RATE_MS, kTimeoutMs);
    talon.setStatusFramePeriod(StatusFrameEnhanced.Status_8_PulseWidth,
            config.PULSE_WIDTH_STATUS_FRAME_RATE_MS, kTimeoutMs);

    talon.setControlFramePeriod(ControlFrame.Control_3_General, config.CONTROL_FRAME_PERIOD_MS);

    return talon;
}