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


Java CANTalon.set方法代码示例

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


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

示例1: Chassis

import com.ctre.CANTalon; //导入方法依赖的package包/类
public Chassis() {
    leftMaster = new CANTalon(RobotMap.LEFT_MASTER);
    leftSlave = new CANTalon(RobotMap.LEFT_SLAVE);
    leftSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
    leftSlave.set(leftMaster.getDeviceID());

    rightMaster = new CANTalon(RobotMap.RIGHT_MASTER);
    rightSlave = new CANTalon(RobotMap.RIGHT_SLAVE);
    rightSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
    rightSlave.set(rightMaster.getDeviceID());

    rightMaster.enableBrakeMode(true);
    rightSlave.enableBrakeMode(true);
    leftMaster.enableBrakeMode(true);
    leftSlave.enableBrakeMode(true);
    System.out.println("Chassis sub system init");

    threadInit(() -> {
        SmartDashboard.putNumber("left speed:", leftMaster.get());
        SmartDashboard.putNumber("right speed:", rightMaster.get());
    });
}
 
开发者ID:FRCteam6414,项目名称:FRC6414program,代码行数:23,代码来源:Chassis.java

示例2: execute

import com.ctre.CANTalon; //导入方法依赖的package包/类
protected void execute() {
 	
 	double t_delta;
 	
 	if(onTime)
 		nextDouble = scanner.nextDouble();
 	
 	t_delta = nextDouble - timer.get();
 	
 	if (t_delta <= 0) {
 		for(CANTalon t : Robot.drivetrain.getTalons()) {
	t.set(scanner.nextDouble());
}
 	
 		onTime = true;
 	} else {
 		onTime = false;
 	}
 	
 }
 
开发者ID:frc2879,项目名称:2017-newcomen,代码行数:21,代码来源:PlayMacro.java

示例3: 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

示例4: init

import com.ctre.CANTalon; //导入方法依赖的package包/类
public static void init() {
      // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
  	compressor = new Compressor();
  	
      driveTrainLeftFront = new CANTalon(1);
      LiveWindow.addActuator("DriveTrain", "LeftFront", driveTrainLeftFront);
      driveTrainRightFront = new CANTalon(3);
      LiveWindow.addActuator("DriveTrain", "RightFront", driveTrainRightFront);
      driveTrainLeftRear = new CANTalon(2);
      driveTrainLeftRear.changeControlMode(TalonControlMode.Follower);
      driveTrainLeftRear.set(driveTrainLeftFront.getDeviceID());
      LiveWindow.addActuator("DriveTrain", "LeftRear", driveTrainLeftRear);
      driveTrainRightRear = new CANTalon(4);
      driveTrainRightRear.changeControlMode(TalonControlMode.Follower);
      driveTrainRightRear.set(driveTrainRightFront.getDeviceID());
      driveTrainRightRear.reverseOutput(false);
      LiveWindow.addActuator("DriveTrain", "RightRear", driveTrainRightRear);
      
      driveTrainLeftFront.setInverted(true);
      driveTrainRightFront.setInverted(true);
      driveTrainLeftRear.setInverted(true);
      driveTrainRightRear.setInverted(true);
      
      driveTrainRobotDrive41 = new RobotDrive(driveTrainRightFront, driveTrainLeftFront);
driveTrainRobotDrive41.setSafetyEnabled(true);
driveTrainRobotDrive41.setExpiration(0.1);
driveTrainRobotDrive41.setSensitivity(0.5);
driveTrainRobotDrive41.setMaxOutput(1.0);
      
      climbMotor = new CANTalon(5);
      LiveWindow.addActuator("Climbing", "Motor", climbMotor);
      
      lightsLightEnable = new Relay(0);
      LiveWindow.addActuator("Lights", "LightEnable", lightsLightEnable);
      
      gearIntakeRamp = new DoubleSolenoid(1, 0);
      LiveWindow.addActuator("GearIntake", "IntakeRamp", gearIntakeRamp);

      // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
  }
 
开发者ID:FRC2832,项目名称:Robot_2017,代码行数:41,代码来源:RobotMap.java

示例5: 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

示例6: 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

示例7: Lift

import com.ctre.CANTalon; //导入方法依赖的package包/类
public Lift() {
    super("Lift");
    //SmartDashboard.putData(this);
    
    liftTalon = new CANTalon(TALONS_LIFT);
    
    liftTalon.enableBrakeMode(true);
    liftTalon.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
    liftTalon.set(0);
}
 
开发者ID:frc2879,项目名称:2017-newcomen,代码行数:11,代码来源:Lift.java

示例8: updateCANTalonSRX

import com.ctre.CANTalon; //导入方法依赖的package包/类
/**
 * Helper method for processing a CANTalonOutput for an SRX
 */
private void updateCANTalonSRX(CANTalon talon, CANTalonOutput output) {
	talon.changeControlMode(output.getControlMode());
	if(output.getControlMode().isPID() || output.getControlMode() == TalonControlMode.MotionMagic) {
		talon.setPID(output.gains.P, output.gains.I, output.gains.D, output.gains.F, output.gains.izone, output.gains.rampRate, output.profile);
	}
	if (output.getControlMode() == CANTalon.TalonControlMode.MotionMagic) {
		talon.setMotionMagicAcceleration(output.accel);
		talon.setMotionMagicCruiseVelocity(output.cruiseVel);
	}
	talon.set(output.getSetpoint());
}
 
开发者ID:team8,项目名称:FRC-2017-Public,代码行数:15,代码来源:HardwareUpdater.java

示例9: 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

示例10: configureSlave

import com.ctre.CANTalon; //导入方法依赖的package包/类
private void configureSlave(CANTalon talon, int masterId) {
  logger.info("init slave: " + talon.getDeviceID() + " to master " + masterId);
  talon.changeControlMode(CANTalon.TalonControlMode.Follower);
  talon.set(masterId);
  talon.enableBrakeMode(true);
}
 
开发者ID:ligerbots,项目名称:Steamworks2017Robot,代码行数:7,代码来源:DriveTrain.java

示例11: BallShooter

import com.ctre.CANTalon; //导入方法依赖的package包/类
public BallShooter() {
	motor = new CANTalon(RobotMap.BALL_SHOOTER_MOTOR);
	motor.set(0);
	//motor.setControlMode();
}
 
开发者ID:cyborgs3335,项目名称:STEAMworks,代码行数:6,代码来源:BallShooter.java

示例12: Intake

import com.ctre.CANTalon; //导入方法依赖的package包/类
public Intake() {
	motor = new CANTalon(RobotMap.INTAKE_MOTOR);
	motor.set(0);
	//motor.setControlMode();
}
 
开发者ID:cyborgs3335,项目名称:STEAMworks,代码行数:6,代码来源:Intake.java

示例13: DriveTrain

import com.ctre.CANTalon; //导入方法依赖的package包/类
public DriveTrain() {
    super();
    frontLeft = new CANTalon(RobotMap.DRIVE_TRAIN_FRONT_LEFT);
    frontRight = new CANTalon(RobotMap.DRIVE_TRAIN_FRONT_RIGHT);
    backLeft = new CANTalon(RobotMap.DRIVE_TRAIN_BACK_LEFT);
    backRight = new CANTalon(RobotMap.DRIVE_TRAIN_BACK_RIGHT);

    frontLeft.set(0);
    frontRight.set(0);
    backLeft.set(0);
    backRight.set(0);
    
    double voltageRampRate = 150;//20;
    frontLeft.setVoltageRampRate(voltageRampRate);
    frontRight.setVoltageRampRate(voltageRampRate);
    backLeft.setVoltageRampRate(voltageRampRate);
    backRight.setVoltageRampRate(voltageRampRate);
    
    //backRight.setCurrentLimit(0);

    setBrake(false);

    drive = new RobotDrive(frontLeft, backLeft, frontRight, backRight);

    // Scale encoder pulses to distance in inches
    double wheelDiameter = 4.0; // inches
    double encoderToShaftRatio = 3; // 3X gear reduction
    double pulsesPerRevolution = 256;
    double stage3Ratio = 50.0 / 34.0;
    double distancePerPulse = Math.PI * wheelDiameter / (encoderToShaftRatio * pulsesPerRevolution);
    distancePerPulse /= stage3Ratio;

    leftEncoder = new Encoder(RobotMap.DRIVE_TRAIN_ENCODER_LEFT_A, RobotMap.DRIVE_TRAIN_ENCODER_LEFT_B,
    		true, EncodingType.k4X);
    leftEncoder.reset();
    leftEncoder.setDistancePerPulse(distancePerPulse);
    rightEncoder = new Encoder(RobotMap.DRIVE_TRAIN_ENCODER_RIGHT_A, RobotMap.DRIVE_TRAIN_ENCODER_RIGHT_B,
    		true, EncodingType.k4X);
    rightEncoder.reset();
    rightEncoder.setDistancePerPulse(distancePerPulse);
}
 
开发者ID:cyborgs3335,项目名称:STEAMworks,代码行数:42,代码来源:DriveTrain.java

示例14: setTalons

import com.ctre.CANTalon; //导入方法依赖的package包/类
protected void setTalons(double setpoint) {
  for (CANTalon talon : talonSet.selected()) {
    talon.set(setpoint);
  }
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:6,代码来源:RunCommand.java

示例15: Climber

import com.ctre.CANTalon; //导入方法依赖的package包/类
public Climber(){
	motor = new CANTalon(RobotMap.CLIMBER_MOTOR1);
	CANTalon motor2 = new CANTalon(RobotMap.CLIMBER_MOTOR2);
	motor2.changeControlMode(TalonControlMode.Follower);
	motor2.set(RobotMap.CLIMBER_MOTOR1);
}
 
开发者ID:FRC4131,项目名称:FIRSTSteamworks2017,代码行数:7,代码来源:Climber.java


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