edu.wpi.first.wpilibj.MotorSafety的实例源码

项目:thirdcoast    文件TalonConfiguration.java   
/**
 * Configure a Talon with stored parameters.
 *
 * @param talon the Talon to registerWith
 */
public void configure(@NotNull CANTalon talon) {
  talon.setSafetyEnabled(false);
  talon.setProfile(0);
  talon.setExpiration(MotorSafety.DEFAULT_SAFETY_EXPIRATION);
  Encoder enc = encoder != null ? encoder : Encoder.DEFAULT;
  enc.configure(talon);

  talon.enableBrakeMode(brakeInNeutral != null ? brakeInNeutral : true);
  talon.reverSEOutput(outputReversed != null ? outputReversed : false);

  if (veLocityMeasurementPeriod != null) {
    talon.SetVeLocityMeasurementPeriod(veLocityMeasurementPeriod);
  } else {
    talon.SetVeLocityMeasurementPeriod(VeLocityMeasurementPeriod.Period_100Ms);
  }

  if (veLocityMeasurementwindow != null) {
    talon.SetVeLocityMeasurementwindow(veLocityMeasurementwindow);
  } else {
    talon.SetVeLocityMeasurementwindow(64);
  }

  LimitSwitch fls = forwardLimitSwitch != null ? forwardLimitSwitch : LimitSwitch.DEFAULT;
  LimitSwitch rls = reverseLimitSwitch != null ? reverseLimitSwitch : LimitSwitch.DEFAULT;
  talon.enableLimitSwitch(fls.isEnabled(),rls.isEnabled());
  if (fls.isEnabled()) {
    talon.ConfigFwdLimitSwitchnormallyOpen(fls.isnormallyopen());
  }
  if (rls.isEnabled()) {
    talon.ConfigRevLimitSwitchnormallyOpen(rls.isnormallyopen());
  }

  SoftLimit sl = forwardSoftLimit != null ? forwardSoftLimit : SoftLimit.DEFAULT;
  talon.enableForwardSoftLimit(sl.isEnabled());
  if (sl.isEnabled()) {
    talon.setForwardSoftLimit(sl.getPosition());
  }
  sl = reverseSoftLimit != null ? reverseSoftLimit : SoftLimit.DEFAULT;
  talon.enableReverseSoftLimit(sl.isEnabled());
  if (sl.isEnabled()) {
    talon.setReverseSoftLimit(sl.getPosition());
  }
  if (currentLimit != null && currentLimit > 0) {
    talon.setCurrentLimit(currentLimit);
    talon.EnableCurrentLimit(true);
  } else {
    talon.EnableCurrentLimit(false);
  }
  talon.setVoltageRampRate(voltageRampRate != null ? voltageRampRate : 0);
  addTalonId(talon.getdeviceid());
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...