Java 类edu.wpi.first.wpilibj.TalonSRX 实例源码

项目:FlashLib    文件:ExampleMecanumDrive.java   
protected void robotInit() {
//We need to create the speed controllers for our drive system.
//In this example, we have a mecanum drive, so we create 4 speed 
//controller objects from WPILib. We will use the TalonSRX speed controllers.

TalonSRX frontRight = new TalonSRX(0);
TalonSRX rearRight = new TalonSRX(1);
TalonSRX frontLeft = new TalonSRX(2);
TalonSRX rearLeft = new TalonSRX(3);

//Since FlashLib wasn't specifically built for FRC, 
//MecanumDrive cannot receive WPILib speed controller objects.
//We need to create a FlashSpeedController object to wrap the speed 
//controllers. We will use FRCSpeedControllers. This class can receive
//several speed controller objects. 
//We will create 4 wrappers: one for each controller

FRCSpeedControllers frontRightWrapper = new FRCSpeedControllers(frontRight);
FRCSpeedControllers rearRightWrapper = new FRCSpeedControllers(rearRight);
FRCSpeedControllers frontLeftWrapper = new FRCSpeedControllers(frontLeft);
FRCSpeedControllers rearLeftWrapper = new FRCSpeedControllers(rearLeft);

//Now we can create the MecanumDrive object and pass it or speed controller
//wrappers.
driveTrain = new MecanumDrive(frontRightWrapper, rearRightWrapper, frontLeftWrapper, rearLeftWrapper);

//Creating our controller for channel 0 of the DriverStation.
controller = new XboxController(0);
  }
项目:FlashLib    文件:ExampleOmniDrive.java   
protected void robotInit() {
//We need to create the speed controllers for our drive system.
//In this example, we have an omni drive with 4 motors:
//one on the right side and one on the left side (moving the robot along the Y axis)
//one on the front of the robot and one on the rear of the robot (moving the robot along the X axis)
//so we create 4 speed controller objects from WPILib. We will use the TalonSRX speed controllers.

TalonSRX front = new TalonSRX(0);
TalonSRX rear = new TalonSRX(1);
TalonSRX left = new TalonSRX(2);
TalonSRX right = new TalonSRX(3);

//Since FlashLib wasn't specifically built for FRC, 
//FlashDrive cannot receive WPILib speed controller objects.
//We need to create a FlashSpeedController object to wrap the speed 
//controllers. We will use FRCSpeedControllers. 
//We will create 4 wrappers: one for each side

FRCSpeedControllers frontWrapper = new FRCSpeedControllers(front);
FRCSpeedControllers rearWrapper = new FRCSpeedControllers(rear);
FRCSpeedControllers rightWrapper = new FRCSpeedControllers(right);
FRCSpeedControllers leftWrapper = new FRCSpeedControllers(left);

//Now we can create the FlashDrive object and pass it or speed controller
//wrappers.
driveTrain = new FlashDrive(rightWrapper, leftWrapper, frontWrapper, rearWrapper);

//Creating our controller for channel 0 of the DriverStation.
controller = new XboxController(0);
  }
项目:FlashLib    文件:ExampleTankDrive.java   
protected void robotInit() {
//We need to create the speed controllers for our drive system.
//In this example, we have a 4x4 tank drive, so we create 4 speed 
//controller objects from WPILib. We will use the TalonSRX speed controllers.

TalonSRX frontRight = new TalonSRX(0);
TalonSRX rearRight = new TalonSRX(1);
TalonSRX frontLeft = new TalonSRX(2);
TalonSRX rearLeft = new TalonSRX(3);

//Since FlashLib wasn't specifically built for FRC, 
//FlashDrive cannot receive WPILib speed controller objects.
//We need to create a FlashSpeedController object to wrap the speed 
//controllers. We will use FRCSpeedControllers. This class can receive
//several speed controller objects. 
//We will create 2 wrappers: one for the left side, another for the right side

FRCSpeedControllers rightControllers = new FRCSpeedControllers(frontRight, rearRight);
FRCSpeedControllers leftControllers = new FRCSpeedControllers(frontLeft, rearLeft);

//Now we can create the FlashDrive object and pass it or speed controller
//wrappers.
driveTrain = new FlashDrive(rightControllers, leftControllers);

//Creating our controller for channel 0 of the DriverStation.
controller = new XboxController(0);
  }
项目:swerve-code    文件:Robot.java   
public void robotInit() {
    this.mod1Spin = new TalonSRX(Constants.MOD1SPIN);
    this.mod1Drive = new TalonSRX(Constants.MOD1DRIVE);
    this.spinEncoder1 = new Encoder(0, 0); //Needs real values
    this.driveEncoder1 = new Encoder(0, 0); //Needs real values

    this.mod2Spin = new TalonSRX(Constants.MOD2SPIN);
    this.mod2Drive = new TalonSRX(Constants.MOD2DRIVE);
    this.spinEncoder2 = new Encoder(0, 0); //Needs real values
    this.driveEncoder2 = new Encoder(0, 0); //Needs real values

    this.mod3Spin = new TalonSRX(Constants.MOD3SPIN);
    this.mod3Drive = new TalonSRX(Constants.MOD3DRIVE);
    this.spinEncoder3 = new Encoder(0, 0); //Needs real values
    this.driveEncoder3 = new Encoder(0, 0); //Needs real values

    this.mod4Spin = new TalonSRX(Constants.MOD4SPIN);
    this.mod4Drive = new TalonSRX(Constants.MOD4DRIVE);
    this.spinEncoder4 = new Encoder(0, 0); //Needs real values
    this.driveEncoder4 = new Encoder(0, 0); //Needs real values

    this.xboxDrive = new Joystick(Constants.XBOXDRIVEPORT);

    this.frontLeft = new SwerveModule("frontLeft", mod1Drive, mod1Spin, spinEncoder1, driveEncoder1); // needs completion0
    this.backLeft = new SwerveModule("backLeft", mod2Drive, mod2Spin, spinEncoder2, driveEncoder2);
    this.frontRight = new SwerveModule("frontRight", mod3Drive, mod3Spin, spinEncoder3, driveEncoder3);
    this.backRight = new SwerveModule("backRight", mod4Drive, mod4Spin, spinEncoder4, driveEncoder4);

    this.swerveDrive = new SwerveDrive(this.frontLeft, this.backLeft, this.frontRight, this.backRight, 25, 25);

    crab = new CrabDrive(swerveDrive, xboxDrive, "crabDrive", 1);
    spin = new SpinDrive(swerveDrive, xboxDrive, "spinDrive", 2);
    unicorn = new UnicornDrive(swerveDrive, xboxDrive, "unicornDrive", 3);
    drive = new DriveBase(crab, spin, unicorn, "driveBase", 0);
    drive.init();
}
项目:Stronghold2016-340    文件:ClawArm.java   
public ClawArm() {
    System.out.println("Claw arm constructor method called");
    armMotor = new TalonSRX(RobotMap.ClawArmMotor);

    clawPiston = new Solenoid(RobotMap.ClawPiston);

    armAngleSensor = new AnalogPotentiometer(RobotMap.ClawArmAngleSensor,270);
    bottomSwitch = new DigitalInput(RobotMap.ClawBottomSwitch);
    topSwitch = new DigitalInput(RobotMap.ClawTopSwitch);
    System.out.println("Claw arm constructor method complete.");
}
项目:RobotControl    文件:Robot.java   
/**
 * This is the initialization for all robot code
 */
public void robotInit()
{
    robotDrive = new RobotDrive(0,1);
    driveStick = new Joystick(0);

    liftServo = new TalonSRX(3);
    liftStick = new Joystick(3);

    server = CameraServer.getInstance();
       server.setQuality(50);
       server.startAutomaticCapture("cam0");
}
项目:FRC-Robotics-2016-Team-2262    文件:DriveMotor.java   
public DriveMotor(int frontChannel, int backChannel) {
    front = new TalonSRX(frontChannel);
    back = new TalonSRX(backChannel);

}
项目:Stronghold2016-340    文件:Drive.java   
public Drive() {
    leftDrive = new TalonSRX(RobotMap.DriveLeftMotor);
    rightDrive = new TalonSRX(RobotMap.DriveRightMotor);

    gyro = new AnalogGyro(RobotMap.DriveGyro);
}
项目:Stronghold2016-340    文件:RightDrive.java   
public RightDrive() {
    rightDrive = new TalonSRX(1);
}
项目:Stronghold2016-340    文件:LeftDrive.java   
public LeftDrive() {
    leftDrive = new TalonSRX(0);
}
项目:r2016    文件:SpeedControllerSubsystem.java   
public SpeedControllerSubsystem(SpeedControllerSubsystemType type, final int channel) {
    switch(type) {
    case CAN_JAGUAR:
        this._controller = new CANJaguar(channel);
        break;

    case CAN_TALON:
        this._controller = new CANTalon(channel);
        break;

    case JAGUAR:
        this._controller = new Jaguar(channel);
        break;

    case SD540:
        this._controller = new SD540(channel);
        break;

    case SPARK:
        this._controller = new Spark(channel);
        break;

    case TALON:
        this._controller = new Talon(channel);
        break;

    case TALON_SRX:
        this._controller = new TalonSRX(channel);
        break;

    case VICTOR:
        this._controller = new Victor(channel);
        break;

    case VICTOR_SP:
        this._controller = new VictorSP(channel);
        break;

    default:
        break;
    }
}
项目:RecycledRushDriveTrain    文件:RobotMap.java   
public static void init() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    driveTrainleftFrontTalon0 = new TalonSRX(0);
    LiveWindow.addActuator("DriveTrain", "leftFrontTalon0", (TalonSRX) driveTrainleftFrontTalon0);

    driveTrainleftBackTalon1 = new TalonSRX(1);
    LiveWindow.addActuator("DriveTrain", "leftBackTalon1", (TalonSRX) driveTrainleftBackTalon1);

    driveTrainrightFrontTalon2 = new TalonSRX(2);
    LiveWindow.addActuator("DriveTrain", "rightFrontTalon2", (TalonSRX) driveTrainrightFrontTalon2);

    driveTrainrightBackTalon3 = new TalonSRX(3);
    LiveWindow.addActuator("DriveTrain", "rightBackTalon3", (TalonSRX) driveTrainrightBackTalon3);

    driveTrainRobotDrive = new RobotDrive(driveTrainleftFrontTalon0, driveTrainleftBackTalon1,
          driveTrainrightFrontTalon2, driveTrainrightBackTalon3);

    driveTrainRobotDrive.setSafetyEnabled(true);
    driveTrainRobotDrive.setExpiration(0.1);
    driveTrainRobotDrive.setSensitivity(0.5);
    driveTrainRobotDrive.setMaxOutput(1.0);

    driveTraingyro = new Gyro(0);
    LiveWindow.addSensor("DriveTrain", "gyro", driveTraingyro);
    driveTraingyro.setSensitivity(0.007);
    driveTrainleftFrontEncoder = new Encoder(17, 18, false, EncodingType.k4X);
    LiveWindow.addSensor("DriveTrain", "leftFrontEncoder", driveTrainleftFrontEncoder);
    driveTrainleftFrontEncoder.setDistancePerPulse(1.0);
    driveTrainleftFrontEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);
    driveTrainleftBackEncoder = new Encoder(19, 20, false, EncodingType.k4X);
    LiveWindow.addSensor("DriveTrain", "leftBackEncoder", driveTrainleftBackEncoder);
    driveTrainleftBackEncoder.setDistancePerPulse(1.0);
    driveTrainleftBackEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);
    driveTrainrightFrontEncoder = new Encoder(21, 22, false, EncodingType.k4X);
    LiveWindow.addSensor("DriveTrain", "rightFrontEncoder", driveTrainrightFrontEncoder);
    driveTrainrightFrontEncoder.setDistancePerPulse(1.0);
    driveTrainrightFrontEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);
    driveTrainrightBackEncoder = new Encoder(23, 24, false, EncodingType.k4X);
    LiveWindow.addSensor("DriveTrain", "rightBackEncoder", driveTrainrightBackEncoder);
    driveTrainrightBackEncoder.setDistancePerPulse(1.0);
    driveTrainrightBackEncoder.setPIDSourceParameter(PIDSourceParameter.kRate);

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
项目:turtleshell    文件:TurtleTalonSRXPWM.java   
public TurtleTalonSRXPWM(int port, boolean isReversed) {
    v = new TalonSRX(port);
    this.isReversed = isReversed;
}
项目:2015-Beaker-Competition    文件:RobotMap.java   
public static void init() {

        driveTrainPWM0 = new TalonSRX(0);
        LiveWindow.addActuator("DriveTrain", "PWM0", (TalonSRX) driveTrainPWM0);

        driveTrainPWM9 = new TalonSRX(9);
        LiveWindow.addActuator("DriveTrain", "PWM9", (TalonSRX) driveTrainPWM9);

        driveTrainRobotDrive = new RobotDrive(driveTrainPWM0, driveTrainPWM9);

        driveTrainRobotDrive.setSafetyEnabled(true);
        driveTrainRobotDrive.setExpiration(0.1);
        driveTrainRobotDrive.setSensitivity(0.5);
        driveTrainRobotDrive.setMaxOutput(1.0);

        intakePWM4 = new TalonSRX(4);
        LiveWindow.addActuator("Intake", "PWM4", (TalonSRX) intakePWM4);

        intakePWM5 = new TalonSRX(5);
        LiveWindow.addActuator("Intake", "PWM5", (TalonSRX) intakePWM5);

        elevatorPWM3 = new TalonSRX(3);
        LiveWindow.addActuator("Elevator", "PWM3", (TalonSRX) elevatorPWM3);

        elevatorPWM6 = new TalonSRX(6);
        LiveWindow.addActuator("Elevator", "PWM6", (TalonSRX) elevatorPWM6);

        armPWM2 = new TalonSRX(2);
        LiveWindow.addActuator("Arm", "PWM2", (TalonSRX) armPWM2);

    }