本文整理汇总了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;
}
}
示例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());
}
示例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;
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例14: getThrottle
import edu.wpi.first.wpilibj.GenericHID; //导入依赖的package包/类
public double getThrottle() {
return -xboxController.getY(GenericHID.Hand.kLeft);
}
示例15: getTurn
import edu.wpi.first.wpilibj.GenericHID; //导入依赖的package包/类
public double getTurn() {
return -xboxController.getX(GenericHID.Hand.kRight);
}