当前位置: 首页>>代码示例>>Java>>正文


Java Joystick类代码示例

本文整理汇总了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));
		
	}
 
开发者ID:2141-Spartonics,项目名称:Spartonics-Code,代码行数:26,代码来源:OI.java

示例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());
}
 
开发者ID:Team2667,项目名称:SteamWorks,代码行数:24,代码来源:OI.java

示例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
}
 
开发者ID:FRC2832,项目名称:Practice_Robot_Code,代码行数:22,代码来源:OI.java

示例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));
	}
}
 
开发者ID:FRC6706,项目名称:FRC6706_JAVA2017,代码行数:23,代码来源:DriveTrainSubsystem.java

示例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);
    }
 
开发者ID:vyrotek,项目名称:frc-robot,代码行数:22,代码来源:Controller.java

示例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
}
 
开发者ID:ElectricGeorge,项目名称:GearBot,代码行数:23,代码来源:OI.java

示例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);
}
 
开发者ID:TeamAutomatons,项目名称:Steamwork_2017,代码行数:20,代码来源:Robot.java

示例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));
    
}
 
开发者ID:Team395,项目名称:El-Jefe-2017,代码行数:24,代码来源:OI.java

示例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();
		}
	});
}
 
开发者ID:MontclairRobotics,项目名称:Sprocket,代码行数:19,代码来源:ToggleButton.java

示例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);
}
 
开发者ID:ArcticWarriors,项目名称:snobot-2017,代码行数:23,代码来源:Robot.java

示例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);
}
 
开发者ID:Team1923,项目名称:Stronghold_2016,代码行数:22,代码来源:XboxController.java

示例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();
    }
}
 
开发者ID:Spartronics4915,项目名称:2016-Stronghold,代码行数:26,代码来源:ArcadeDrive.java

示例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();
}
 
开发者ID:Spartronics4915,项目名称:2016-Stronghold,代码行数:20,代码来源:IntakeLauncher.java

示例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;
}
 
开发者ID:first95,项目名称:FRC2016,代码行数:17,代码来源:ButtonTracker.java

示例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;
	}
}
 
开发者ID:MTHSRoboticsClub,项目名称:FRC-2017,代码行数:22,代码来源:CANDriveAssembly.java


注:本文中的edu.wpi.first.wpilibj.Joystick类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。