當前位置: 首頁>>代碼示例>>Java>>正文


Java Talon類代碼示例

本文整理匯總了Java中edu.wpi.first.wpilibj.Talon的典型用法代碼示例。如果您正苦於以下問題:Java Talon類的具體用法?Java Talon怎麽用?Java Talon使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Talon類屬於edu.wpi.first.wpilibj包,在下文中一共展示了Talon類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
public static void init() {
	driveTrainCIMRearLeft = new CANTalon(2); // rear left motor
	driveTrainCIMFrontLeft = new CANTalon(12); // 
	driveTrainCIMRearRight = new CANTalon(1);
	driveTrainCIMFrontRight = new CANTalon(11);
	driveTrainRobotDrive41 = new RobotDrive(driveTrainCIMRearLeft, driveTrainCIMFrontLeft, 
			driveTrainCIMRearRight, driveTrainCIMFrontRight);
	climberClimber = new CANTalon(3);
    c1 = new Talon(5);
    pDPPowerDistributionPanel1 = new PowerDistributionPanel(0);
    gyro = new ADXRS450_Gyro(Port.kOnboardCS0);
    c2 = new Talon(6);
    ultra = new AnalogInput(0);
    
    LiveWindow.addSensor("PDP", "PowerDistributionPanel 1", pDPPowerDistributionPanel1);
    LiveWindow.addSensor("Ultra", "Ultra", ultra);
   //  LiveWindow.addActuator("Intake", "Intake", intakeIntake);
    LiveWindow.addActuator("Climber", "Climber", climberClimber);
    LiveWindow.addActuator("RearLeft (2)", "Drivetrain", driveTrainCIMRearLeft);
    LiveWindow.addActuator("FrontLeft (12)", "Drivetrain", driveTrainCIMFrontLeft);
    LiveWindow.addActuator("RearRight (1)", "Drivetrain", driveTrainCIMRearRight);
    LiveWindow.addActuator("FrontRight (11)", "Drivetrain", driveTrainCIMFrontRight);
    LiveWindow.addActuator("Drive Train", "Gyro", gyro);
    // LiveWindow.addActuator("Shooter", "Shooter", shooter1);
}
 
開發者ID:Team4914,項目名稱:2017-emmet,代碼行數:26,代碼來源:RobotMap.java

示例2: Arm

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
public Arm() {
super("arm", kP, kI, kD);

motor = new Talon(RobotMap.ArmMap.PWM_MOTOR);
motor.setInverted(RobotMap.ArmMap.INV_MOTOR);

encoder = new Encoder(RobotMap.ArmMap.DIO_ENCODER_A, RobotMap.ArmMap.DIO_ENCODER_B);
encoder.setDistancePerPulse(RobotMap.ArmMap.DISTANCE_PER_PULSE);
encoder.setReverseDirection(RobotMap.ArmMap.INV_ENCODER);

upperLimit = new DigitalInput(RobotMap.ArmMap.DIO_LIMIT_TOP);
bottomLimit = new DigitalInput(RobotMap.ArmMap.DIO_LIMIT_BOTTOM);

setAbsoluteTolerance(0.05);
getPIDController().setContinuous(false);
   }
 
開發者ID:Team236,項目名稱:2016-Robot-Final,代碼行數:17,代碼來源:Arm.java

示例3: Shooter

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
public Shooter() {

		shooterLeftSide = new Talon(RobotMap.Pwm.LeftShooterMotor);
		shooterRightSide = new Talon(RobotMap.Pwm.RightShooterMotor);

		encoderLeft = new Encoder(RobotMap.Digital.ShooterLeftChannelA, RobotMap.Digital.ShooterLeftChannelB);
		encoderRight = new Encoder(RobotMap.Digital.ShooterRightChannelA, RobotMap.Digital.ShooterRightChannelB);

		encoderLeft.setPIDSourceType(PIDSourceType.kRate);
		encoderRight.setPIDSourceType(PIDSourceType.kRate);
		encoderLeft.setDistancePerPulse(distancePerPulse);
		encoderRight.setDistancePerPulse(distancePerPulse);

		// leftPID = new PIDSpeedController(encoderLeft, shooterLeftSide, "Shooter", "Left Wheel");
		// rightPID = new PIDSpeedController(encoderRight, shooterRightSide, "Shooter", "Right Wheel");

	}
 
開發者ID:chopshop-166,項目名稱:frc-2016,代碼行數:18,代碼來源:Shooter.java

示例4: robotInit

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
@Override
public void robotInit() {

       driveLeftA = new CANTalon(2);
       driveLeftB = new CANTalon(1);
       driveRightA = new CANTalon(3);
       driveRightB = new CANTalon(4);

       climberMotorA = new Talon(1);
       climberMotorB = new Talon(2);

       drive = new RobotDrive(driveLeftA, driveLeftB, driveRightA, driveRightB);

       joystick = new Joystick(0);

       SmartDashboard.putNumber("SlowClimber", .5);
       SmartDashboard.putNumber("FastClimber", 1);
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:23,代碼來源:Robot.java

示例5: DriveSubsystem

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
public DriveSubsystem() {
	talonFrontLeft = new CANTalon(Ports.FRONT_LEFT_MOTOR);
	talonFrontRight = new CANTalon(Ports.FRONT_RIGHT_MOTOR);
	talonBackLeft = new Talon(Ports.BACK_LEFT_MOTOR);
	talonBackRight = new Talon(Ports.BACK_RIGHT_MOTOR);
	ultraSanic.setAutomaticMode(true);
	
	talonFrontLeft.setFeedbackDevice(FeedbackDevice.QuadEncoder);
	talonFrontRight.setFeedbackDevice(FeedbackDevice.QuadEncoder);
	talonFrontLeft.configEncoderCodesPerRev(PulsesPerRevolution);
	talonFrontRight.configEncoderCodesPerRev(PulsesPerRevolution);

	try {
		ahrs = new AHRS(Port.kMXP);
	} catch (Exception ex) {
		//System.out.println(ex);
	}
	// SPEED MODE CODE
	// setDriveControlMode(TalonControlMode.Speed);
	drivingStraight = false;
	driveLowerSpeed = false;
	reversed = true;
	enableForwardSoftLimit(false);
	enableReverseSoftLimit(false);
}
 
開發者ID:Team2537,項目名稱:Cogsworth,代碼行數:26,代碼來源:DriveSubsystem.java

示例6: Lift

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
public Lift(int motorChannel, int brakeChannelForward, int brakeChannelReverse, int encoderChannelA,
		int encoderChannelB, int boundaryLimitChannel, String subsystem) {
	motor = new Talon(motorChannel);
	brake = new DoubleSolenoid(RobotMap.solenoid.Pcm24, brakeChannelForward, brakeChannelReverse);
	encoder = new Encoder(encoderChannelA, encoderChannelB);
	boundaryLimit = new DigitalInput(boundaryLimitChannel);

	LiveWindow.addActuator(subsystem, "Motor", motor);
	LiveWindow.addActuator(subsystem, "Brake", brake);
	LiveWindow.addSensor(subsystem, "Encoder", encoder);
	LiveWindow.addSensor(subsystem, "Boundary Limit Switch", boundaryLimit);

	encoder.setPIDSourceType(PIDSourceType.kRate);
	pid = new PIDSpeedController(encoder, motor, subsystem, "Speed Control");
	subsystemName = subsystem;
}
 
開發者ID:chopshop-166,項目名稱:frc-2015,代碼行數:17,代碼來源:Lift.java

示例7: DriveTrain

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
public DriveTrain(OperatorInputs _operatorInputs) {
    this.operatorInputs = _operatorInputs;
    this.leftTalons = new Talon(LEFT_PORT);
    this.rightTalons = new Talon(RIGHT_PORT);
    this.gearShiftLow = new Solenoid(SHIFT_MODULE, SHIFT_PORT_LOW);
    this.gearShiftHigh = new Solenoid(SHIFT_MODULE, SHIFT_PORT_HIGH);
    this.leftEncoder = new Encoder(3, 4);
    this.rightEncoder = new Encoder(5, 6);
    this.timer = new Timer();
    //Start all wheels off
    leftTalons.set(0);
    rightTalons.set(0);
    //Starts in low gear
    gearShiftLow.set(isHighGear);
    gearShiftHigh.set(!isHighGear);
    leftEncoder.setDistancePerPulse(-DISTANCE_PER_PULSE);
    rightEncoder.setDistancePerPulse(DISTANCE_PER_PULSE);

}
 
開發者ID:pewaukeerobotics,項目名稱:ParadigmShift-2014,代碼行數:20,代碼來源:DriveTrain.java

示例8: Launcher

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
/**
 * Constructs a new Launcher, with two Talons for winding, a release relay,
 * and a limit switch for winding regulation based on input from a
 * MaxbotixUltrasonic rangefinder.
 */
public Launcher() {
    super("Launcher");

    winderL = new Talon(RobotMap.WIND_LEFT_PORT);
    winderR = new Talon(RobotMap.WIND_RIGHT_PORT);

    releaseMotor = new Relay(RobotMap.RELAY_PORT);
    
    camera = new AxisCameraM1101();
    rangefinder = new MaxbotixUltrasonic(RobotMap.ULTRASONIC_RANGEFINDER);

    limitSwitch = new DigitalInput(RobotMap.LIMIT_SWITCH);
    counter = new Counter(limitSwitch);

    counterInit(counter);
}
 
開發者ID:bethpage-robotics,項目名稱:Aerial-Assist,代碼行數:22,代碼來源:Launcher.java

示例9: getTalon

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
public Talon getTalon(int which) {
    switch(which)
    {
        case HardwareDefines.FRONT_LEFT_TALON:
            return leftTalon1;
        case HardwareDefines.FRONT_RIGHT_TALON:
            return rightTalon1;
        case HardwareDefines.BACK_LEFT_TALON:
            return leftTalon2;
        case HardwareDefines.BACK_RIGHT_TALON:
            return rightTalon2;
    }
    
    throw new RuntimeException("Error: " + 
                                "trying to get a Talon that doesn't exist");
}
 
開發者ID:alexbrinister,項目名稱:Nashoba-Robotics2014,代碼行數:17,代碼來源:Drive.java

示例10: RobotOutput

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
/**
 * Instantiates a new robot output.
 */
private RobotOutput() {		
	
	this.forces = ChiliFunctions.fillArrayWithZeros(this.forces);
	
	front_left = new Talon(ChiliConstants.front_left_motor);
	rear_left = new Talon(ChiliConstants.rear_left_motor);
	front_right = new Talon(ChiliConstants.front_right_motor);
	rear_right = new Talon(ChiliConstants.rear_right_motor);
	left_lifter = new Jaguar(ChiliConstants.left_lifter_motor);
	right_lifter = new Jaguar(ChiliConstants.right_lifter_motor);
	
	//Sensor object for some cheating.
	//Objecto de sensor. "Trampa" para obtener ciertos valores.
	sensor = SensorInput.getInstance();
	
	/*front_left.setSafetyEnabled(true);
	rear_left.setSafetyEnabled(true);
	front_right.setSafetyEnabled(true);
	rear_right.setSafetyEnabled(true);
	left_lifter.setSafetyEnabled(true);
	right_lifter.setSafetyEnabled(true);*/
}
 
開發者ID:Chilean-Heart,項目名稱:2015-frc-robot,代碼行數:26,代碼來源:RobotOutput.java

示例11: Winch

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
/**
 * A private constructor to prevent multiple instances from being created.
 */
private Winch(){
	winchMotor = new Talon(RobotMap.winchMotor.getInt());
	winchInputSwitch = new DigitalInput(RobotMap.winchLimitSwitch.getInt());
	winchSolenoid = new MomentaryDoubleSolenoid(
			RobotMap.winchExtPort.getInt(),RobotMap.winchRetPort.getInt());
	winchBallSensor = new AnalogChannel(RobotMap.winchBallSensorPort.getInt());
	intakeBallSensor = new AnalogChannel(RobotMap.intakeBallSensorPort.getInt());
	ballPresent = new Debouncer(RobotMap.ballPresentTime.getDouble());
	ballNotPresent = new Debouncer(RobotMap.ballPresentTime.getDouble());
	ballSettled = new Debouncer(RobotMap.ballSettleTime.getDouble());
	ballPresentOnWinch = new Debouncer(RobotMap.ballPresentOnWinchTime.getDouble());
	
	winchPotentiometer =
			new AnalogChannel(RobotMap.potentiometerPort.getInt());
	winchEncoder = new AverageEncoder(
			RobotMap.winchEncoderA.getInt(),
			RobotMap.winchEncoderB.getInt(),
			RobotMap.winchEncoderPulsePerRot,
			RobotMap.winchEncoderDistPerTick,
			RobotMap.winchEncoderReverse,
			RobotMap.winchEncodingType, RobotMap.winchSpeedReturnType,
			RobotMap.winchPosReturnType, RobotMap.winchAvgEncoderVal);
	winchEncoder.start();
}
 
開發者ID:Team2168,項目名稱:2014_Main_Robot,代碼行數:28,代碼來源:Winch.java

示例12: Drive

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
private Drive()
{
    drive = new RobotDrive(new Talon(1),new Talon(2),new Talon(3),new Talon(4));
    drive.setSafetyEnabled(false);

    
    e1 = new Encoder(RobotMap.ENCODER_1_A, RobotMap.ENCODER_1_B, false, CounterBase.EncodingType.k4X);
    e2 = new Encoder(RobotMap.ENCODER_2_A, RobotMap.ENCODER_2_B, false, CounterBase.EncodingType.k4X);
    
    //A calculated constant to convert from encoder ticks to feet on 4 inch diameter wheels
    e1.setDistancePerPulse(0.0349065850388889/12);
    e2.setDistancePerPulse(0.0349065850388889/12);
    startEncoders();
    
    drive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, true);      
    drive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);
    
    sonic = new Ultrasonic(RobotMap.ULTRASONIC_A, RobotMap.ULTRASONIC_B);
    sonic.setAutomaticMode(true);
    sonic.setEnabled(true);
    
    
    shifter = new DoubleSolenoid(RobotMap.SHIFTER_ENGAGE, RobotMap.SHIFTER_DISENGAGE);
}
 
開發者ID:Nashoba-Robotics,項目名稱:NR-2014-CMD,代碼行數:25,代碼來源:Drive.java

示例13: SystemDrive

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
public SystemDrive() {
    super();

    leftTalon = new Talon(2); // Both bots: 2
    rightTalon = new Talon(1); //Both bots: 1
    leftDesiredEncoderDistance = 0;
    rightDesiredEncoderDistance = 0;

    driveDeadband = WiredCats2415.textReader.getValue("driveDeadband");
    driveGain = WiredCats2415.textReader.getValue("driveGain");
    
    lastLeftError = 0;
    lastRightError = 0;
    
    kp = WiredCats2415.textReader.getValue("propConstantDrive");
    ki = WiredCats2415.textReader.getValue("integralConstantDrive");
    kd = WiredCats2415.textReader.getValue("derivativeConstantDrive");
       
    System.out.println("[WiredCats] Initialized System Drive");
}
 
開發者ID:wiredcats,項目名稱:EventBasedWiredCats,代碼行數:21,代碼來源:SystemDrive.java

示例14: ExampleSubsystem

import edu.wpi.first.wpilibj.Talon; //導入依賴的package包/類
public ExampleSubsystem() {
	/*
	 * Here we should prepare our system for use. We will create 
	 * our speed controller.
	 */
	
	//create our speed controller. we will use port 0.
	speedController = new Talon(0);
}
 
開發者ID:Flash3388,項目名稱:FlashLib,代碼行數:10,代碼來源:ExampleSubsystem.java

示例15: Shooter

import edu.wpi.first.wpilibj.Talon; //導入依賴的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


注:本文中的edu.wpi.first.wpilibj.Talon類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。