本文整理汇总了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);
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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");
}
示例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);*/
}
示例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();
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}