當前位置: 首頁>>代碼示例>>Java>>正文


Java GenericHID類代碼示例

本文整理匯總了Java中edu.wpi.first.wpilibj.GenericHID的典型用法代碼示例。如果您正苦於以下問題:Java GenericHID類的具體用法?Java GenericHID怎麽用?Java GenericHID使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GenericHID類屬於edu.wpi.first.wpilibj包,在下文中一共展示了GenericHID類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DirectionalButton

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
public DirectionalButton(Direction direction, GenericHID joystick)
{
	neededAngle = 1;
	this.direction = direction;
	this.joystick = joystick;

	switch (direction)
	{
	case UP:
		neededAngle = 0;
		break;
	case DOWN:
		neededAngle = 180;
		break;
	case LEFT:
		neededAngle = 270;
		break;
	case RIGHT:
		neededAngle = 90;
		break;
	}
}
 
開發者ID:BytingBulldogs3539,項目名稱:BBLIB,代碼行數:23,代碼來源:DirectionalButton.java

示例2: execute

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
protected void execute() {
    //here we already have to access the io object. 
    //read the up/down and left/right from io.
    //then pass those values to the mecanum drive function.
    
    SmartDashboard.putNumber("[MC] X", oi.getXbox().getX(GenericHID.Hand.kLeft));
    SmartDashboard.putNumber("[MC] Y", oi.getXbox().getY(GenericHID.Hand.kLeft));
    SmartDashboard.putNumber("[MC] Theta", oi.getXbox().getThrottle());
    X = oi.getXbox().getX(GenericHID.Hand.kLeft);
    if ( Math.abs(X) <= 0.25) {
        X = 0.0;
    } else {
    }
    Y = oi.getXbox().getY(GenericHID.Hand.kLeft);
    if (Math.abs(Y) <= 0.25) {
        Y = 0.0;
    }
    throttle = oi.getXbox().getThrottle();
    if (Math.abs(throttle) <= 0.25) {
        throttle = 0.0;          
    }       

    driveTrain.mecanumDrive(X, Y, throttle, gyro.getAngle());//- (RobotTemplate.gyroOff * Timer.getFPGATimestamp())))
    //driveTrain.mecanumDrive(oi.getXbox().getX(GenericHID.Hand.kLeft), oi.getXbox().getY(GenericHID.Hand.kLeft), oi.getXbox().getTwist(), gyro.getAngle());
}
 
開發者ID:frc3946,項目名稱:MecanumDrivetrain,代碼行數:26,代碼來源:MecanumDrive.java

示例3: execute

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
protected void execute()
{
    if (OI.primaryXboxController.getBumper(GenericHID.Hand.kLeft))
    {
        if (!runShooter)
        {
            shooter.runShooter(shooterSpeed);
            runShooter = true;
        }
        
        else
        {
            shooter.runShooter(0);
            runShooter = false;
        }            
    }
}
 
開發者ID:BadRobots1014,項目名稱:BadRobot2013,代碼行數:18,代碼來源:ShootWithController.java

示例4: winchUp

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
public void winchUp(XboxController controller) {
  	double y = deadZoneInput(controller.getY(GenericHID.Hand.kLeft), .1);   	
  			
if(y > .1)
	speedController1.set(y);
else
	speedController1.set(0);
  }
 
開發者ID:FRC-6413,項目名稱:steamworks-java,代碼行數:9,代碼來源:Winch.java

示例5: shouldUseFieldOrientedDrive

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
private boolean shouldUseFieldOrientedDrive() {
  double absXL = Math.abs(joystick.getX(GenericHID.Hand.kLeft));
  absXL = absXL < DEADZONE ? 0 : absXL;
  double absXR = Math.abs(joystick.getX(GenericHID.Hand.kRight));
  absXR = absXR < DEADZONE ? 0 : absXR;
  double abxYL = Math.abs(joystick.getY(GenericHID.Hand.kLeft));
  abxYL = abxYL < DEADZONE ? 0 : abxYL;
  double absYR = Math.abs(joystick.getY(GenericHID.Hand.kRight));
  absYR = absYR < DEADZONE ? 0 : absYR;
  return absXL > absXR || abxYL > absYR;
}
 
開發者ID:FRC-1294,項目名稱:frc2017,代碼行數:12,代碼來源:TeleopDriveCommand.java

示例6: allInputsInDeadZone

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
private boolean allInputsInDeadZone() {
  return Math.abs(getJoystickZ()) <  TRIGGER_DEADZONE &&
          Math.abs(joystick.getX(GenericHID.Hand.kLeft)) < DEADZONE &&
          Math.abs(joystick.getY(GenericHID.Hand.kLeft)) < DEADZONE &&
          Math.abs(joystick.getX(GenericHID.Hand.kRight)) < DEADZONE &&
          Math.abs(joystick.getY(GenericHID.Hand.kRight)) < DEADZONE;

}
 
開發者ID:FRC-1294,項目名稱:frc2017,代碼行數:9,代碼來源:TeleopDriveCommand.java

示例7: tankDrive

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
public void tankDrive(
        GenericHID leftStick, int leftAxis, GenericHID rightStick, int rightAxis,
        boolean inverted, boolean squaredInput)
{
    tankDrive(
            leftStick.getRawAxis(leftAxis), rightStick.getRawAxis(rightAxis),
            inverted, squaredInput);
}
 
開發者ID:trc492,項目名稱:Frc2016FirstStronghold,代碼行數:9,代碼來源:HalRobotDrive.java

示例8: arcadeDrive

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
public void arcadeDrive(
        GenericHID driveStick, int driveAxis, GenericHID turnStick, int turnAxis,
        boolean inverted, boolean squaredInput)
{
    arcadeDrive(
            driveStick.getRawAxis(driveAxis), turnStick.getRawAxis(turnAxis),
            inverted, squaredInput);
}
 
開發者ID:trc492,項目名稱:Frc2016FirstStronghold,代碼行數:9,代碼來源:HalRobotDrive.java

示例9: OI

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
/**
 * Receive a joystick and then map controls to it.
 *
 * @param joysticks The joysticks used for buttons
 */
public OI(GenericHID... joysticks) {
    // button map
    liftUpButton = new JoystickButton(joysticks[0], 5);
    liftDownButton = new JoystickButton(joysticks[0], 3);

    forkInButton = new JoystickButton(joysticks[0], 1);
    forkOutButton = new JoystickButton(joysticks[0], 2);

    extGrabButton = new JoystickButton(joysticks[0], 6);
    extThrowButton = new JoystickButton(joysticks[0], 4);

    reverseButton = new JoystickButton(joysticks[0], 12);

    // button controls
    liftUpButton.whileHeld(new Lift(1));
    liftDownButton.whileHeld(new Lift(-1));

    liftUpButton.whenReleased(new Lift(0));
    liftDownButton.whenReleased(new Lift(0));

    forkInButton.whileHeld(new Fork(1));
    forkOutButton.whileHeld(new Fork(-0.666));

    forkInButton.whenReleased(new Fork(0));
    forkOutButton.whenReleased(new Fork(0));

    extGrabButton.whileHeld(new ExtArm(1));
    extThrowButton.whileHeld(new ExtArm(-1));

    extGrabButton.whenReleased(new ExtArm(0));
    extThrowButton.whenReleased(new ExtArm(0));

    reverseButton.whenPressed(new ReverseDrive());
}
 
開發者ID:CircuitRunners,項目名稱:frc_2015_recyclerush,代碼行數:40,代碼來源:OI.java

示例10: tick

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
@Override
public void tick() {
    Joystick joy = UDPreference.joystick;
    if (UDPreference.JOYSTICK_LAYOUT.toLowerCase().equals("xbox_stick")) {
        UDPreference.drive.mecanumDrive_Cartesian(joy.getX(GenericHID.Hand.kLeft), joy.getY(GenericHID.Hand.kLeft), joy.getX(GenericHID.Hand.kRight), 0);
    }
}
 
開發者ID:Open-RIO,項目名稱:UniversalDrive,代碼行數:8,代碼來源:DriveMecanum.java

示例11: tick

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
@Override
public void tick() {
    Joystick joy = UDPreference.joystick;
    if (UDPreference.JOYSTICK_LAYOUT.toLowerCase().equals("xbox_stick")) {
        UDPreference.drive.tankDrive(joy.getY(GenericHID.Hand.kLeft), joy.getY(GenericHID.Hand.kRight), UDPreference.DRIVE_SQUAREDINPUTS);
    }
}
 
開發者ID:Open-RIO,項目名稱:UniversalDrive,代碼行數:8,代碼來源:DriveTank.java

示例12: execute

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
public void execute(XboxController controller) {
    double xleft = controller.getX(GenericHID.Hand.kLeft);
    double yleft = controller.getY(GenericHID.Hand.kLeft);
    double xright = controller.getX(GenericHID.Hand.kRight);
    
    drive.mecanumDrive_Cartesian(joystickSensitivity(xleft), joystickSensitivity(yleft), joystickSensitivity(xright),0);
}
 
開發者ID:owatonnarobotics,項目名稱:2014RobotCode,代碼行數:8,代碼來源:Drive.java

示例13: isFinished

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
protected boolean isFinished() 
{
    if((Timer.getFPGATimestamp()-startTime) > shooterRunTime)
        return true;
    //for debug
    if(OI.primaryXboxController.getBumper(GenericHID.Hand.kLeft) || 
            OI.primaryXboxController.getRawButton(1))
        return true;

    return false;
}
 
開發者ID:BadRobots1014,項目名稱:BadRobot2013,代碼行數:12,代碼來源:Shoot.java

示例14: getThrottle

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
public double getThrottle() {
  return -xboxController.getY(GenericHID.Hand.kLeft);
}
 
開發者ID:ligerbots,項目名稱:Steamworks2017Robot,代碼行數:4,代碼來源:OperatorInterface.java

示例15: getTurn

import edu.wpi.first.wpilibj.GenericHID; //導入依賴的package包/類
public double getTurn() {
  return -xboxController.getX(GenericHID.Hand.kRight);
}
 
開發者ID:ligerbots,項目名稱:Steamworks2017Robot,代碼行數:4,代碼來源:OperatorInterface.java


注:本文中的edu.wpi.first.wpilibj.GenericHID類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。