当前位置: 首页>>代码示例>>Java>>正文


Java CANTalon.setFeedbackDevice方法代码示例

本文整理汇总了Java中com.ctre.CANTalon.setFeedbackDevice方法的典型用法代码示例。如果您正苦于以下问题:Java CANTalon.setFeedbackDevice方法的具体用法?Java CANTalon.setFeedbackDevice怎么用?Java CANTalon.setFeedbackDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ctre.CANTalon的用法示例。


在下文中一共展示了CANTalon.setFeedbackDevice方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initTalonConfig

import com.ctre.CANTalon; //导入方法依赖的package包/类
public void initTalonConfig() {

	    talons = new CANTalon[] {
	    		new CANTalon(TALONS_FRONT_LEFT), new CANTalon(TALONS_FRONT_RIGHT),
	            new CANTalon(TALONS_REAR_LEFT), new CANTalon(TALONS_REAR_RIGHT)};
	    
	    talons[MotorType.kFrontLeft.value].setInverted(true);
	    talons[MotorType.kFrontRight.value].setInverted(false);
	    talons[MotorType.kRearLeft.value].setInverted(true);
	    talons[MotorType.kRearRight.value].setInverted(false);
	    
	    for (CANTalon t: talons) {
            t.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
            t.enableBrakeMode(false);
            t.setFeedbackDevice(FeedbackDevice.QuadEncoder);
            t.configEncoderCodesPerRev(ENC_CODES_PER_REV);
            t.setEncPosition(0);
            t.set(0);
        }
	    robotDrive = new RobotDrive(talons[MotorType.kFrontLeft.value], talons[MotorType.kRearLeft.value], 
	    							talons[MotorType.kFrontRight.value], talons[MotorType.kRearRight.value]);
	    robotDrive.setSafetyEnabled(false);
	}
 
开发者ID:frc2879,项目名称:2017-newcomen,代码行数:24,代码来源:Drivetrain.java

示例2: Shooter

import com.ctre.CANTalon; //导入方法依赖的package包/类
public Shooter() {
	super();
	shooterFeeder = new CANTalon(8);
    LiveWindow.addActuator("Shooter", "Feeder", shooterFeeder);
    shooterFeeder.enableBrakeMode(false);
    
    shooterShootMotor = new CANTalon(7);
    LiveWindow.addActuator("Shooter", "ShootMotor", shooterShootMotor);
    shooterShootMotor.enableBrakeMode(false);
       /* choose the sensor */
    shooterShootMotor.setFeedbackDevice(FeedbackDevice.QuadEncoder);
    shooterShootMotor.reverseSensor(true);
    shooterShootMotor.configEncoderCodesPerRev(PulsesPerRevolution); // if using FeedbackDevice.QuadEncoder

       /* set the peak and nominal outputs, 12V means full */
    shooterShootMotor.configNominalOutputVoltage(+0.0f, -0.0f);
    shooterShootMotor.configPeakOutputVoltage(+12.0f, -12.0f);
       
       /* set closed loop gains in slot0 */
    shooterShootMotor.setProfile(0);
    shooterShootMotor.setF(pidF);
       shooterShootMotor.setP(pidP);	
       
       //only change I and D to smooth out control
       shooterShootMotor.setI(0); 
       shooterShootMotor.setD(0);
    
    shooterAgitator = new CANTalon(10);
    LiveWindow.addActuator("Shooter", "Agitator", shooterAgitator);
    shooterAgitator.enableBrakeMode(false);
}
 
开发者ID:FRC2832,项目名称:Robot_2017,代码行数:32,代码来源:Shooter.java

示例3: configureMaster

import com.ctre.CANTalon; //导入方法依赖的package包/类
private void configureMaster(CANTalon talon) {
  logger.info("init master: " + talon.getDeviceID());
  talon.changeControlMode(CANTalon.TalonControlMode.Voltage);
  talon.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
  talon.configEncoderCodesPerRev(RobotMap.QUAD_ENCODER_TICKS_PER_REV);
  talon.configNominalOutputVoltage(+0.0f, -0.0f);
  talon.configPeakOutputVoltage(+12.0f, -12.0f);
  talon.setProfile(0);
  talon.setF(0);
  talon.setP(0.5);
  talon.setI(0.0001);
  talon.setD(1.0);
  talon.setPosition(0);
  talon.enableBrakeMode(true);
}
 
开发者ID:ligerbots,项目名称:Steamworks2017Robot,代码行数:16,代码来源:DriveTrain.java

示例4: Shooter

import com.ctre.CANTalon; //导入方法依赖的package包/类
public Shooter() {
    motor = new CANTalon(LEAD_SHOOTER_PORT);
    motor.setInverted(true);
    CANTalon follower = new CANTalon(FOLLOWER_SHOOTER_PORT);
    agitatorMotor = new Talon(AGITATOR_PORT);
    motor.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
    motor.changeControlMode(CANTalon.TalonControlMode.Speed);
    follower.changeControlMode(CANTalon.TalonControlMode.Follower);
    follower.set(LEAD_SHOOTER_PORT);
    motor.setF(0);
    motor.setP(.88);
    motor.setI(0);
    motor.setD(0);
}
 
开发者ID:FRC-2928,项目名称:VikingRobot,代码行数:15,代码来源:Shooter.java

示例5: Drivebase

import com.ctre.CANTalon; //导入方法依赖的package包/类
public Drivebase() {
    super();

    left = new CANTalon(FRONT_LEFT_MOTOR_DEVICE_NUMBER);
    leftSlave = new CANTalon(BACK_LEFT_MOTOR_DEVICE_NUMBER);
    leftSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
    leftSlave.set(FRONT_LEFT_MOTOR_DEVICE_NUMBER);

    right = new CANTalon(FRONT_RIGHT_MOTOR_DEVICE_NUMBER);
    rightSlave =  new CANTalon(BACK_RIGHT_MOTOR_DEVICE_NUMBER);
    rightSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
    rightSlave.set(FRONT_RIGHT_MOTOR_DEVICE_NUMBER);

    left.setInverted(true);
    right.setInverted(true);
    leftSlave.setInverted(true);
    rightSlave.setInverted(true);

    left.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
    right.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
    left.configEncoderCodesPerRev(TICS_PER_REVOLUTION);
    right.configEncoderCodesPerRev(TICS_PER_REVOLUTION);
    left.reverseSensor(true);
    right.reverseSensor(true);

    // PID Stuff
    left.setPID(0.1, 0, 0, 0.025, 0, 1, 0);
    right.setPID(0.1, 0, 0, 0.025, 0, 1, 0);

    left.configNominalOutputVoltage(+0, -0);
    right.configPeakOutputVoltage(+12, -12);
    left.setProfile(0);
    right.setProfile(0);

    robotDrive = new RobotDrive(left, right);
}
 
开发者ID:FRC-2928,项目名称:VikingRobot,代码行数:37,代码来源:Drivebase.java

示例6: configure

import com.ctre.CANTalon; //导入方法依赖的package包/类
public void configure(CANTalon talon) {
  talon.setFeedbackDevice(getDevice());
  talon.reverseSensor(reversed);
  logger.info(
      "{}: encoder {} {} reversed", talon.getDescription(), getDevice(), reversed ? "" : "not");
  if (unitScalingEnabled) {
    talon.configEncoderCodesPerRev(ticksPerRevolution);
    logger.info(
        "{}: configured {} encoder codes per revolution",
        talon.getDescription(),
        ticksPerRevolution);
  }
  checkEncoder(talon);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:15,代码来源:Encoder.java

示例7: configureTalons

import com.ctre.CANTalon; //导入方法依赖的package包/类
void configureTalons(boolean calibrateSliderEncoder) {
	configureDriveTalons();
	if (Constants.kRobotName == RobotName.STEIK) {
		//Climber setup
		CANTalon climber = HardwareAdapter.ClimberHardware.getInstance().climberTalon;
		climber.reset();
		climber.setFeedbackDevice(CANTalon.FeedbackDevice.CtreMagEncoder_Relative);
		climber.setPosition(0);	
		climber.configMaxOutputVoltage(Constants.kClimberMaxVoltage);
		climber.configPeakOutputVoltage(Constants.kClimberMaxVoltage, 0); // Should never be used
		climber.ConfigRevLimitSwitchNormallyOpen(false); // Prevent the motor from spinning backwards
		climber.ConfigFwdLimitSwitchNormallyOpen(true);
		climber.enable();
		
		CANTalon slider = HardwareAdapter.SliderHardware.getInstance().sliderTalon;
		// Reset and turn on the Talon 
		slider.reset();
		slider.clearStickyFaults();
		slider.setStatusFrameRateMs(CANTalon.StatusFrameRate.General, 5);
		slider.enable();
		slider.enableControl();
		slider.configMaxOutputVoltage(Constants.kSliderMaxVoltage);
		slider.configPeakOutputVoltage(Constants.kSliderPeakOutputVoltage, -Constants.kSliderPeakOutputVoltage);
		if (calibrateSliderEncoder) {
			// Set up the Talon to read from a relative CTRE mag encoder sensor
			slider.setFeedbackDevice(CANTalon.FeedbackDevice.CtreMagEncoder_Relative);
			// Calibrate the encoder
			double current_pot_pos = HardwareAdapter.SliderHardware.getInstance().sliderPotentiometer.getValue();
			double distance_to_center = current_pot_pos - Constants.kPotentiometerCenterPos;
			double position_in_rev = (distance_to_center / 4096.0) * 10.0;
			if (Constants.kCalibrateSliderWithPotentiometer) {
				slider.setPosition(-position_in_rev);
			} else {
				slider.setPosition(0);
			}
		}
	}
}
 
开发者ID:team8,项目名称:FRC-2017-Public,代码行数:39,代码来源:HardwareUpdater.java

示例8: Shooter

import com.ctre.CANTalon; //导入方法依赖的package包/类
/**
 * Create the instance of Shooter.
 */
public Shooter() {
  logger.info("Initialize");

  if (RobotMap.IS_ROADKILL) {
    return;
  }
  // account for missing Talons
  if (Robot.deviceFinder.isTalonAvailable(RobotMap.CT_ID_SHOOTER_MASTER)) {
    masterId = RobotMap.CT_ID_SHOOTER_MASTER;
    slaveId = RobotMap.CT_ID_SHOOTER_SLAVE;
  } else {
    logger.warn("Master talon is missing");
    masterId = RobotMap.CT_ID_SHOOTER_SLAVE;
    // in case it comes back
    slaveId = RobotMap.CT_ID_SHOOTER_MASTER;
  }
  
  shooterMaster = new CANTalon(masterId);
  // basic setup
  shooterMaster.changeControlMode(CANTalon.TalonControlMode.Speed);
  shooterMaster.enableBrakeMode(false); // probably bad for 775pros
  shooterMaster.setFeedbackDevice(CANTalon.FeedbackDevice.CtreMagEncoder_Relative);
  shooterMaster.reverseSensor(false);
  // the Talon needs peak and nominal output values
  shooterMaster.configNominalOutputVoltage(+0.0f, -0.0f);
  shooterMaster.configPeakOutputVoltage(+12.0f, -12.0f);
  // configure PID
  shooterMaster.setProfile(0);
  shooterMaster.setF(0);
  shooterMaster.setP(0.12);
  shooterMaster.setI(0.00012);
  shooterMaster.setD(0.5);
  // add to LiveWindow for easy testing
  LiveWindow.addActuator("Shooter", "Master", shooterMaster);

  shooterSlave = new CANTalon(slaveId);
  shooterSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
  shooterSlave.enableBrakeMode(false);
  shooterSlave.set(masterId);
  LiveWindow.addActuator("Shooter", "Slave", shooterSlave);

  Thread shooterWatchdog = new Thread(this::shooterWatchdogThread);
  // allow JVM to exit
  shooterWatchdog.setDaemon(true);
  // in the debugger, we'd like to know what this is
  shooterWatchdog.setName("Shooter Watchdog Thread");
  shooterWatchdog.start();
  
  SmartDashboard.putData(new InstantCommand("ForceOverrideShooterFault") {
    @Override
    public void execute() {
      shooterFault = false;
    }
  });
}
 
开发者ID:ligerbots,项目名称:Steamworks2017Robot,代码行数:59,代码来源:Shooter.java

示例9: perform

import com.ctre.CANTalon; //导入方法依赖的package包/类
@Override
public void perform() {
  String[] types = {
    "Analog",
    "Analog Potentiometer",
    "CTRE Magnetic Absolute",
    "CTRE Magnetic Relative",
    "Falling Edge",
    "Rising Edge",
    "Pulse Width",
    "Quadrature"
  };
  terminal.writer().println();
  for (int i = 0; i < types.length; i++) {
    terminal.writer().printf("%2d - %s ms%n", i + 1, types[i]);
  }
  boolean done = false;
  while (!done) {
    String line;
    try {
      line = reader.readLine(prompt()).trim();
    } catch (EndOfFileException | UserInterruptException e) {
      break;
    }

    if (line.isEmpty()) {
      logger.info("no value entered");
      break;
    }

    int choice;
    try {
      choice = Integer.valueOf(line);
    } catch (NumberFormatException nfe) {
      terminal.writer().println("please enter an integer");
      continue;
    }
    CANTalon.FeedbackDevice device;
    done = true;
    switch (choice) {
      case 1:
        device = FeedbackDevice.AnalogEncoder;
        break;
      case 2:
        device = FeedbackDevice.AnalogPot;
        break;
      case 3:
        device = FeedbackDevice.CtreMagEncoder_Absolute;
        break;
      case 4:
        device = FeedbackDevice.CtreMagEncoder_Relative;
        break;
      case 5:
        device = FeedbackDevice.EncFalling;
        break;
      case 6:
        device = FeedbackDevice.EncRising;
        break;
      case 7:
        device = FeedbackDevice.PulseWidth;
        break;
      case 8:
        device = FeedbackDevice.QuadEncoder;
        break;
      default:
        continue;
    }
    talonSet.talonConfigurationBuilder().encoder(device);
    for (CANTalon talon : talonSet.selected()) {
      talon.setFeedbackDevice(device);
      logger.info("set {} for {} to {}", name(), talon.getDescription(), device);
    }
  }
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:75,代码来源:SelectTypeCommand.java


注:本文中的com.ctre.CANTalon.setFeedbackDevice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。