本文整理汇总了Java中edu.wpi.first.wpilibj.TalonSRX类的典型用法代码示例。如果您正苦于以下问题:Java TalonSRX类的具体用法?Java TalonSRX怎么用?Java TalonSRX使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TalonSRX类属于edu.wpi.first.wpilibj包,在下文中一共展示了TalonSRX类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: robotInit
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
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);
}
示例2: robotInit
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
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);
}
示例3: robotInit
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
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);
}
示例4: robotInit
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
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();
}
示例5: ClawArm
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
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.");
}
示例6: robotInit
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
/**
* 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");
}
示例7: DriveMotor
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
public DriveMotor(int frontChannel, int backChannel) {
front = new TalonSRX(frontChannel);
back = new TalonSRX(backChannel);
}
示例8: Drive
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
public Drive() {
leftDrive = new TalonSRX(RobotMap.DriveLeftMotor);
rightDrive = new TalonSRX(RobotMap.DriveRightMotor);
gyro = new AnalogGyro(RobotMap.DriveGyro);
}
示例9: RightDrive
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
public RightDrive() {
rightDrive = new TalonSRX(1);
}
示例10: LeftDrive
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
public LeftDrive() {
leftDrive = new TalonSRX(0);
}
示例11: SpeedControllerSubsystem
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
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;
}
}
示例12: init
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
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
}
示例13: TurtleTalonSRXPWM
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
public TurtleTalonSRXPWM(int port, boolean isReversed) {
v = new TalonSRX(port);
this.isReversed = isReversed;
}
示例14: init
import edu.wpi.first.wpilibj.TalonSRX; //导入依赖的package包/类
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);
}