本文整理汇总了Java中edu.wpi.first.wpilibj.Joystick类的典型用法代码示例。如果您正苦于以下问题:Java Joystick类的具体用法?Java Joystick怎么用?Java Joystick使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Joystick类属于edu.wpi.first.wpilibj包,在下文中一共展示了Joystick类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OI
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public OI() {
driveStick = new Joystick(RobotMap.DRIVE_STICK_NUMBER);
driveButtons = new JoystickButton[13];
auxiliaryStick = new Joystick(RobotMap.AUXILLIARY_STICK_NUMBER);
auxiliaryButtons = new JoystickButton[13];
for(int i = 1; i <= driveButtons.length - 1; i++) {
driveButtons[i] = new JoystickButton(driveStick, i);
}
for(int i=1; i <= auxiliaryButtons.length - 1; i++){
auxiliaryButtons[i] = new JoystickButton(auxiliaryStick, i);
}
//this.getButton(RobotMap.SHOOTER_CONTROL_BUTTON).whileHeld(new ShooterControl());
this.getButton(2).whenPressed(new openIntake());
this.getButton(3).whenPressed(new closeIntake());
this.getButton(4).toggleWhenPressed(new IntakeIn());
this.getButton(5).toggleWhenPressed(new IntakeOut());
this.getButton(5).toggleWhenPressed(new stopIntake());
this.getButton(4).whenPressed(new driveForward(20, .25));
}
示例2: OI
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public OI() {
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
logitech = new Joystick(0);
shooterbutton = new JoystickButton(logitech, 1);
shooterbutton.whileHeld(new shoot());
// SmartDashboard Buttons
SmartDashboard.putData("Autonomous Command", new AutonomousCommand());
SmartDashboard.putData("shoot", new shoot());
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
shootBackwardsButton = new JoystickButton(logitech, 2);
shootBackwardsButton.whileHeld(new ShootReverse());
LiftUPButton = new JoystickButton(logitech, 3);
LiftReservseButton = new JoystickButton(logitech, 4);
LiftUPButton.whileHeld(new LiftUP());
LiftReservseButton.whileHeld(new LiftReverse());
}
示例3: OI
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public OI() {
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
xBoxController = new Joystick(0);
aButton = new JoystickButton(xBoxController, 1);
bButton = new JoystickButton(xBoxController, 2);
xButton = new JoystickButton(xBoxController, 3);
aButton.whenPressed(new RelayOn());
//b button operated by default command only?
bButton.whenPressed(new AllForward());
xButton.whenPressed(new MotorPositionCheck());
// SmartDashboard Buttons
SmartDashboard.putData("Autonomous Command", new AutonomousCommand());
SmartDashboard.putData("RelayOn", new RelayOn());
SmartDashboard.putData("AllForward", new AllForward());
SmartDashboard.putData("MotorPositionCheck", new MotorPositionCheck());
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
示例4: drive
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public void drive(Joystick mStick) {
//drive.arcadeDrive(mStick.getThrottle()*(-0.7), mStick.getX()*(-0.7));
//
if(mStick.getRawButton(7) && mStick.getRawButton(8)){
drive.tankDrive(mStick.getY()*(-1.0), mStick.getThrottle()*(-1.0));
}else if(mStick.getRawButton(8)){
drive.tankDrive(mStick.getY()*(-0.9), mStick.getThrottle()*(-0.9));
}else if(mStick.getRawButton(7)){
drive.tankDrive(mStick.getY()*(-0.8), mStick.getThrottle()*(-0.8));
}else if(mStick.getRawButton(5) && mStick.getRawButton(6)){
drive.tankDrive(mStick.getY()*(-0.4), mStick.getThrottle()*(-0.4));
}
else if(mStick.getRawButton(5)){
drive.tankDrive(mStick.getY()*(-0.6), mStick.getThrottle()*(-0.6));
}
else if(mStick.getRawButton(6)){
drive.tankDrive(mStick.getY()*(-0.5), mStick.getThrottle()*(-0.5));
}
else {
drive.tankDrive(mStick.getY()*(-0.7), mStick.getThrottle()*(-0.7));
}
}
示例5: Controller
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public Controller(int port) {
// Controller
joystick = new Joystick(port);
// Buttons
buttonA = new JoystickButton(joystick, Mappings.BUTTON_A);
buttonB = new JoystickButton(joystick, Mappings.BUTTON_B);
buttonX = new JoystickButton(joystick, Mappings.BUTTON_X);
buttonY = new JoystickButton(joystick, Mappings.BUTTON_Y);
buttonLeftBumper = new JoystickButton(joystick, Mappings.BUTTON_LEFTBUMPER);
buttonRightBumper = new JoystickButton(joystick, Mappings.BUTTON_RIGHTBUMPER);
// Axes
axisLeftX = new JoystickAxis(joystick, Mappings.AXIS_LEFT_X, AXIS_THRESHOLD);
axisLeftY = new JoystickAxis(joystick, Mappings.AXIS_LEFT_Y, AXIS_THRESHOLD);
axisRightX = new JoystickAxis(joystick, Mappings.AXIS_RIGHT_X, AXIS_THRESHOLD);
axisRightY = new JoystickAxis(joystick, Mappings.AXIS_RIGHT_Y, AXIS_THRESHOLD);
axisLeftTrigger = new JoystickAxis(joystick, Mappings.AXIS_LEFT_TRIGGER, AXIS_THRESHOLD);
axisRightTrigger = new JoystickAxis(joystick, Mappings.AXIS_RIGHT_TRIGGER, AXIS_THRESHOLD);
}
示例6: OI
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public OI() {
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
joystick = new Joystick(0);
// SmartDashboard Buttons
SmartDashboard.putData("GearGroup", new GearGroup());
SmartDashboard.putData("OpenLeft", new OpenLeft());
SmartDashboard.putData("OpenRight", new OpenRight());
SmartDashboard.putData("Open", new Open());
SmartDashboard.putData("PinchLeft", new PinchLeft());
SmartDashboard.putData("PinchRight", new PinchRight());
SmartDashboard.putData("Pinch", new Pinch());
SmartDashboard.putData("WaitForGear", new WaitForGear());
SmartDashboard.putData("WaitForUnload", new WaitForUnload());
SmartDashboard.putData("OpenGate", new OpenGate());
SmartDashboard.putData("CloseGate", new CloseGate());
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
}
示例7: Robot
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public Robot() {
stick = new Joystick(0);
driveLeftFront = new Victor(LEFT_FRONT_DRIVE);
driveLeftRear = new Victor(LEFT_REAR_DRIVE);
driveRightFront = new Victor(RIGHT_FRONT_DRIVE);
driveRightRear = new Victor(RIGHT_REAR_DRIVE);
enhancedDriveLeft = new Victor(ENHANCED_LEFT_DRIVE);
enhancedDriveRight = new Victor(ENHANCED_RIGHT_DRIVE);
gearBox = new DoubleSolenoid(GEAR_BOX_PART1, GEAR_BOX_PART2);
climber1 = new Victor(CLIMBER_PART1);
climber2 = new Victor(CLIMBER_PART2);
vexSensorBackLeft = new Ultrasonic(0, 1);
vexSensorBackRight = new Ultrasonic(2, 3);
vexSensorFrontLeft = new Ultrasonic(4, 5);
vexSensorFrontRight = new Ultrasonic(6, 7);
Skylar = new RobotDrive(driveLeftFront, driveLeftRear, driveRightFront, driveRightRear);
OptimusPrime = new RobotDrive(enhancedDriveLeft, enhancedDriveRight);
}
示例8: OI
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public OI(){
joystick = new Joystick(0);
jyButton1 = new JoystickButton(joystick, 1);
xbox = new Joystick(1);
xbButton1 = new JoystickButton(xbox, 1);
xbButton2 = new JoystickButton(xbox, 2);
xbButton3 = new JoystickButton(xbox, 3);
xbButton4 = new JoystickButton(xbox, 4);
xbButton5 = new JoystickButton(xbox, 5);
xbButton6 = new JoystickButton(xbox, 6);
jyButton1.whileHeld(new FineControl());
xbButton1.whileHeld(new Shoot());
xbButton2.toggleWhenPressed(new IntakeToggle());
xbButton3.toggleWhenPressed(new ToggleShooter());
xbButton4.whenPressed(new ClawSet());
xbButton5.whenPressed(new GripControl(0));
xbButton6.whenPressed(new GripControl(1));
}
示例9: ToggleButton
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public ToggleButton(Joystick stick, int id, Togglable togglable) {
super(stick, id);
this.obj = togglable;
this.setPressAction(new ButtonAction() {
@Override
public void onAction() {
obj.enable();
}
});
this.setReleaseAction(new ButtonAction() {
@Override
public void onAction() {
obj.disable();
}
});
}
示例10: robotInit
import edu.wpi.first.wpilibj.Joystick; //导入依赖的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);
}
示例11: XboxController
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public XboxController(final int port) {
super(port); // Extends Joystick...
/* Initialize */
this.port = port;
this.controller = new Joystick(this.port); // Joystick referenced by
// everything
this.dPad = new DirectionalPad(this.controller);
this.lt = new Trigger(this.controller, HAND.LEFT);
this.rt = new Trigger(this.controller, HAND.RIGHT);
this.a = new JoystickButton(this.controller, A_BUTTON_ID);
this.b = new JoystickButton(this.controller, B_BUTTON_ID);
this.x = new JoystickButton(this.controller, X_BUTTON_ID);
this.y = new JoystickButton(this.controller, Y_BUTTON_ID);
this.lb = new JoystickButton(this.controller, LB_BUTTON_ID);
this.rb = new JoystickButton(this.controller, RB_BUTTON_ID);
this.back = new JoystickButton(this.controller, BACK_BUTTON_ID);
this.start = new JoystickButton(this.controller, START_BUTTON_ID);
this.rightClick = new JoystickButton(this.controller, RIGHT_CLICK_ID);
this.leftClick = new JoystickButton(this.controller, LEFT_CLICK_ID);
}
示例12: execute
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
@Override
protected void execute() {
Joystick joystickDrive = Robot.oi.getJoystickDrive();
this.joystickX = joystickDrive.getAxis(Joystick.AxisType.kX) * Robot.driveTrain.turnMultiplier;
this.joystickY = joystickDrive.getAxis(Joystick.AxisType.kY) *-1;
VisionState vs = VisionState.getInstance();
if (vs == null || !vs.wantsControl()) {
// endAutoTurn is harmless when not needed but required
// if the driver changes her mind after initiating auto-targeting..
Robot.driveTrain.endAutoTurn();
this.scaledThrottle = Robot.driveTrain.scaleThrottle(joystickDrive.getAxis(Joystick.AxisType.kThrottle));
if ((Math.abs(this.joystickX) < 0.075) &&
(Math.abs(this.joystickY) < 0.075)) {
Robot.driveTrain.stop();
}
else {
Robot.driveTrain.arcadeDrive(joystickY * scaledThrottle, joystickX * scaledThrottle);
}
} else {
Robot.driveTrain.trackVision();
}
}
示例13: moveLauncherWithJoystick
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
private void moveLauncherWithJoystick() {
double joystickY = Robot.oi.aimStick.getAxis((Joystick.AxisType.kY));
if (Math.abs(joystickY) > MIN_JOYSTICK_MOTION) {
if (isJoystickIdle) {
aimMotor.enableControl();
isJoystickIdle = false;
System.out.println("Enabling Aim Control");
}
readSetPoint();
offsetSetPoint(joystickY * JOYSTICK_SCALE);
} else {
if (!isJoystickIdle) {
aimMotor.disableControl();
isJoystickIdle = true;
System.out.println("Disabling Aim Control");
}
}
// aimMotor.disableControl();
}
示例14: ButtonTracker
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public ButtonTracker(Joystick Joystick, int Channel) {
mChannel = Channel;
mJoystick = Joystick;
if (!usedNumbers.containsKey(Joystick)) {
usedNumbers.put(Joystick, new ButtonTracker[17]);
}
if (usedNumbers.get(Joystick)[Channel] != null) {
// SmartDashboard.putBoolean("ERROR", true);
System.out.println("MORE THAN ONE BUTTON TRACKER PER BUTTON.");
DriverStation.reportError("MORE THAN ONE BUTTON TRACKER PER BUTTON!", false);
}
usedNumbers.get(Joystick)[Channel] = this;
}
示例15: initialize
import edu.wpi.first.wpilibj.Joystick; //导入依赖的package包/类
public static void initialize()
{
if (!initialized) {
mFrontLeft = new CANTalon(LEFT_FRONT_TALON_ID);
mBackLeft = new CANTalon(LEFT_REAR_TALON_ID);
mFrontRight = new CANTalon(RIGHT_FRONT_TALON_ID);
mBackRight = new CANTalon(RIGHT_REAR_TALON_ID);
drive = new RobotDrive(mFrontLeft, mBackLeft, mFrontRight, mBackRight);
drive.setInvertedMotor(RobotDrive.MotorType.kFrontLeft, false);
drive.setInvertedMotor(RobotDrive.MotorType.kFrontRight, false);
drive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, false);
drive.setInvertedMotor(RobotDrive.MotorType.kRearRight, false);
leftStick = new Joystick(LEFT_JOYSTICK_ID);
rightStick = new Joystick(RIGHT_JOYSTICK_ID);
initialized = true;
}
}