项目:BBLIB
文件:DirectionalButton.java
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;
}
}
项目:MecanumDrivetrain
文件:MecanumDrive.java
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());
}
项目:BadRobot2013
文件:ShootWithController.java
protected void execute()
{
if (OI.primaryXBoxController.getBumper(GenericHID.Hand.kLeft))
{
if (!runShooter)
{
shooter.runShooter(shooterSpeed);
runShooter = true;
}
else
{
shooter.runShooter(0);
runShooter = false;
}
}
}
项目:steamworks-java
文件:Winch.java
public void winchUp(XBoxController controller) {
double y = deadZoneInput(controller.getY(GenericHID.Hand.kLeft),.1);
if(y > .1)
speedController1.set(y);
else
speedController1.set(0);
}
项目:frc2017
文件:TeleopDriveCommand.java
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;
}
项目:frc2017
文件:TeleopDriveCommand.java
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;
}
public void tankDrive(
GenericHID leftStick,int leftAxis,GenericHID rightStick,int rightAxis,boolean inverted,boolean squaredInput)
{
tankDrive(
leftStick.getRawAxis(leftAxis),rightStick.getRawAxis(rightAxis),inverted,squaredInput);
}
@Override
public void tankDrive(
GenericHID leftStick,boolean inverted)
{
tankDrive(
leftStick.getRawAxis(leftAxis),false);
}
public void tankDrive(
GenericHID leftStick,boolean squaredInput)
{
tankDrive(
leftStick,Joystick.AxisType.kY.value,rightStick,squaredInput);
}
@Override
public void tankDrive(GenericHID leftStick,boolean inverted)
{
tankDrive(
leftStick,false);
}
@Override
public void tankDrive(GenericHID leftStick,GenericHID rightStick)
{
tankDrive(
leftStick,false,false);
}
public void arcadeDrive(
GenericHID driveStick,int driveAxis,GenericHID turnStick,int turnAxis,boolean squaredInput)
{
arcadeDrive(
driveStick.getRawAxis(driveAxis),turnStick.getRawAxis(turnAxis),squaredInput);
}
@Override
public void arcadeDrive(
GenericHID driveStick,boolean inverted)
{
arcadeDrive(
driveStick.getRawAxis(driveAxis),false);
}
@Override
public void arcadeDrive(
GenericHID driveStick,int turnAxis)
{
arcadeDrive(
driveStick.getRawAxis(driveAxis),false);
}
public void arcadeDrive(GenericHID stick,boolean squaredInput)
{
arcadeDrive(
stick.getRawAxis(Joystick.AxisType.kY.value),stick.getRawAxis(Joystick.AxisType.kX.value),squaredInput);
}
@Override
public void arcadeDrive(GenericHID stick,boolean inverted)
{
arcadeDrive(
stick.getRawAxis(Joystick.AxisType.kY.value),false);
}
@Override
public void arcadeDrive(GenericHID stick)
{
arcadeDrive(
stick.getRawAxis(Joystick.AxisType.kY.value),false);
}
/**
* 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());
}
项目:UniversalDrive
文件:DriveMecanum.java
@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);
}
}
项目:UniversalDrive
文件:DriveTank.java
@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);
}
}
项目:2014RobotCode
文件:Drive.java
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);
}
项目:BadRobot2013
文件:Shoot.java
项目:Steamworks2017Robot
文件:OperatorInterface.java
项目:Steamworks2017Robot
文件:OperatorInterface.java
public double getTurn() {
return -xBoxController.getX(GenericHID.Hand.kRight);
}
项目:Steamworks2017Robot
文件:OperatorInterface.java
public boolean isQuickTurn() {
return xBoxController.getStickButton(GenericHID.Hand.kRight);
}
项目:steamworks-java
文件:DriveBase.java
public void mecanumDrive(XBoxController controller) {
double x = deadZoneInput(controller.getX(GenericHID.Hand.kLeft),.3);
double y = deadZoneInput(controller.getY(GenericHID.Hand.kLeft),.1) * .5;
double rotation = deadZoneInput(controller.getX(GenericHID.Hand.kRight),.1) * .7;
if(controller.getTriggerAxis(GenericHID.Hand.kRight) != 0.0) {
double trigger = controller.getTriggerAxis(GenericHID.Hand.kRight);
y = y * (trigger + 1);
rotation = rotation * (1-(trigger*.5));
}
StringBuilder sb = new StringBuilder();
if(controller.getBumper(GenericHID.Hand.kLeft)) {
rFM.changeControlMode(TalonControlMode.PercentVbus);
rRM.changeControlMode(TalonControlMode.PercentVbus);
lFM.changeControlMode(TalonControlMode.PercentVbus);
lRM.changeControlMode(TalonControlMode.PercentVbus);
robotDrive41.mecanumDrive_Cartesian(x,y,rotation,0);
}
else {
y = y * -1;
//sb.append("rawx:" + rotation + ",rawy:" + y);
//double motorOutput = lFM.getoutputVoltage() / lFM.getBusVoltage();
double z = Math.sqrt(rotation * rotation + y * y);
double rad = Math.acos(Math.abs(rotation)/z);
double angle = rad * 180.0 / Math.PI;
double tcoeff = -1 + (angle/90.0)*2.0;
double turn = tcoeff * Math.abs(Math.abs(y) - Math.abs(rotation));
turn = Math.round(turn*100.0)/100.0;
double move = Math.max(Math.abs(y),Math.abs(rotation));
double left = 0;
double right = 0;
if ((rotation >= 0 && y >=0) || (rotation < 0 && y < 0))
{
left = move;
right = turn;
}
else {
right = move;
left = turn;
}
if (y < 0)
{
left = 0 - left;
right = 0 - right;
}
double rightTargetSpeed = right * 1200;
rFM.changeControlMode(TalonControlMode.Speed);
rFM.set(rightTargetSpeed);
//rRM.changeControlMode(TalonControlMode.Follower);
//rRM.set(0);
rRM.changeControlMode(TalonControlMode.Speed);
rRM.set(rightTargetSpeed);
double leftTargetSpeed = left * 1200;
lFM.changeControlMode(TalonControlMode.Speed);
lFM.set(leftTargetSpeed);
//lRM.changeControlMode(TalonControlMode.Follower);
//lRM.set(1);
lRM.changeControlMode(TalonControlMode.Speed);
lRM.set(leftTargetSpeed);
}
}
项目:BBLIB
文件:TriggerButton.java
public TriggerButton(int axis,GenericHID joystick)
{
triggerAxis = axis;
this.joystick = joystick;
}
项目:Robot_2016
文件:Robot.java
private void handleInput(GenericHID g) {
// slow down turning sensitivity by multiplying stick input bhy 0.75
RobotMap.driveTrain.arcadeDrive(
g.getRawAxis(GamepadState.AXIS_LY) * (InterfaceFlip.isFlipped ? 1 : -1),g.getRawAxis(GamepadState.AXIS_RX) * 0.75);
//D-Pad Controls
switch (oi.gamepad.getPOV()) {
//D-pad right
case 90:
if (!povpressed) {
Scheduler.getInstance().add(null); //new MoveTailDown());
}
povpressed = true;
break;
//D-pad left
case 270:
if (!povpressed) {
Scheduler.getInstance().add(null);//new MoveTailUp());
}
povpressed = true;
break;
//D-pad up
case 0:
// Use speed mode if not currently used
if (!povpressed) {
Scheduler.getInstance().add(new MoveaimerUp());
}
povpressed = true;
break;
//D-pad down
case 180:
if (!povpressed) {
Scheduler.getInstance().add(new MoveaimerDown());
}
povpressed = true;
break;
case -1:
if (povpressed == true) {
Scheduler.getInstance().add(new Stopaimer());
}
povpressed = false;
break;
}
//left Trigger Code
if (oi.gamepad.getRawAxis(GamepadState.AXIS_LT) >= .2) {
Scheduler.getInstance().add(new Intake());
leftTriggerpressed = true;
} else {
leftTriggerpressed = false;
}
//right Trigger Code
if (oi.gamepad.getRawAxis(GamepadState.AXIS_RT) >= .2) {
Scheduler.getInstance().add(new SpinShooterWheels());
isspinning = true;
rightTriggerpressed = true;
} else if (rightTriggerpressed){
rightTriggerpressed = false;
isspinning = false;
shooterNotActive = true;
Scheduler.getInstance().add(new StopBallMotors());
}
// if (rightTriggerpressed && shooterNotActive) {
// gameMode = 3;
// Scheduler.getInstance().add(new SpinShooterWheels());
// shooterNotActive = false;
// }
}
项目:frc2017
文件:TeleopDriveCommand.java
@Override
protected void execute() {
// TRIGGER_DEADZONE = SmartDashboard.getNumber("trig",TRIGGER_DEADZONE);
double z; // this will contain the rotation rate (from either the joystick or the PID as appropriate)
double joystickZ = getJoystickZ(); // temp variable to hold the joystick rotation rate
if (shouldBeOpenLoopSteering(joystickZ)) {
// robot should be in open loop steering mode where the joystick triggers control the rotation rate
// if we are in PID steering mode,switch to open loop steering mode
if (driveMode == DriveMode.PID) {
switchToOpenLoopSteering();
}
// use the joystick to control the rotation rate
z = joystickZ / 2;
getPIDController().setSetpoint(Robot.spatialAwarenessSubsystem.getheading());
} else {
// robot should be in pid steering mode where the PIDController controls the rotation rate
// if we are in open loop steering,switch to PID steering
if (driveMode == DriveMode.OpenLoop) {
switchToPidSteering();
}
// otherwise use the PID to control the rotation rate
z = pidZ;
}
if (shouldUseFieldOrientedDrive()) {
// use the left analog stick for field oriented
Robot.driveSubsystem.mecanumDrive(
joystick.getX(GenericHID.Hand.kLeft),joystick.getY(GenericHID.Hand.kLeft),z,Robot.spatialAwarenessSubsystem.getheading());
} else {
// otherwise use the right analog stick for robot oriented
Robot.driveSubsystem.mecanumDrive(
joystick.getX(GenericHID.Hand.kRight),joystick.getY(GenericHID.Hand.kRight),0);
}
}
项目:frc2017
文件:TeleopDriveCommand.java
private double getJoystickZ() {
double leftTriggerValue = joystick.getTriggerAxis(GenericHID.Hand.kLeft);
double rightTriggerValue = joystick.getTriggerAxis(GenericHID.Hand.kRight);
return rightTriggerValue - leftTriggerValue;
}
@Override
public void tankDrive(GenericHID leftStick,int rightAxis)
{
tankDrive(
leftStick.getRawAxis(leftAxis),false);
}
项目:blanket
文件:HumanNumberInputEvent.java
public HumanNumberInputEvent(GenericHID source,double number) {
super(source);
this.number = number;
}
项目:blanket
文件:HumanToggleInputEvent.java
public HumanToggleInputEvent(GenericHID source,boolean toggle) {
super(source);
this.toggle = toggle;
}
项目:blanket
文件:HumanInputEvent.java
public HumanInputEvent(GenericHID source) {
this.source = source;
}
项目:blanket
文件:HumanInputEvent.java
public final GenericHID getSource() {
return source;
}
项目:blanket
文件:Controller.java
public Controller(GenericHID controller) {
this.controller = controller;
}
项目:blanket
文件:Controller.java
public GenericHID get() {
return controller;
}
项目:2015RobotCode
文件:DrivingSys.java
public void drive(GenericHID moveStick,final int moveAxis,GenericHID rotateStick,final int rotateAxis) {
robotDrive.arcadeDrive(moveStick,moveAxis,rotateStick,rotateAxis);
}
项目:CMonster2014
文件:JoystickAxisButton.java
public JoystickAxisButton(GenericHID joystick,int axis,double value) {
this.joystick = joystick;
this.axis = axis;
this.value = value;
}
项目:Veer
文件:OI.java
public Bumper(GenericHID joystick,int TriggerAxis) {
super(joystick,TriggerAxis);
this.TriggerAxis = TriggerAxis;
this.joystick = joystick;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。