微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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());
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。