public void winchUp(XboxController controller) { double y = deadZoneInput(controller.getY(GenericHID.Hand.kLeft), .1); if(y > .1) speedController1.set(y); else speedController1.set(0); }
/** * This function is run when the robot is first started up and should be * used for any initialization code. */ public void robotInit() { // PWM's mTestMotor1 = new Talon(0); mTestMotor2 = new Jaguar(1); mServo = new Servo(2); // Digital IO mDigitalOutput = new DigitalOutput(0); mRightEncoder = new Encoder(4, 5); mLeftEncoder = new Encoder(1, 2); mUltrasonic = new Ultrasonic(7, 6); // Analog IO mAnalogGryo = new AnalogGyro(0); mPotentiometer = new AnalogPotentiometer(1); // Solenoid mSolenoid = new Solenoid(0); // Relay mRelay = new Relay(0); // Joysticks mJoystick1 = new Joystick(0); mJoystick2 = new XboxController(1); // SPI mSpiGryo = new ADXRS450_Gyro(); // Utilities mTimer = new Timer(); mPDP = new PowerDistributionPanel(); Preferences.getInstance().putDouble("Motor One Speed", .5); }
public ControllerHandler(int port) { controller = new XboxController(port); }
@Override public void robotInit() { chooser = new SendableChooser<Integer>(); chooser.addDefault("center red", 1); chooser.addObject("center blue", 2); chooser.addObject("boiler red", 3); chooser.addObject("boiler blue", 4); chooser.addObject("ret red", 5); chooser.addObject("ret blue", 6); chooser.addObject("current test", 7); SmartDashboard.putData("Auto choices", chooser); //NETWORK TABLE VARIABLES table = NetworkTable.getTable("dataTable"); //POWER DIST PANEL pdp = new PowerDistributionPanel(); //NAVX navx = new AHRS(SPI.Port.kMXP); // CONTROLLER jsLeft = new Joystick(0); jsRight = new Joystick(1); xbox = new XboxController(5); // MOTORS leftFront = new Talon(pwm5); leftMid = new Talon(pwm3); leftBack = new Talon(pwm1); rightFront = new Talon(pwm4); rightMid = new Talon(pwm2); rightBack = new Talon(pwm0); // ENCODERS encLeftDrive = new Encoder(0,1); encRightDrive = new Encoder(2,3); // COMPRESSOR compressor = new Compressor(); compressor.start(); //SOLENOIDs driveChain = new DoubleSolenoid(0,1); driveChain.set(Value.kReverse); presser = new DoubleSolenoid(2,3); presser.set(Value.kReverse); gearpiston = new DoubleSolenoid(4,5); gearpiston.set(Value.kReverse); //CANTALONS climber = new CANTalon(2); shooter = new CANTalon(4); intake = new CANTalon(9); feeder = new CANTalon(13); // CAMERA //DON'T DELETE THE COMMENTED THREAD-IT IS USED FOR CALIBRATION /* UsbCamera usbCam = new UsbCamera("mscam", 0); usbCam.setVideoMode(VideoMode.PixelFormat.kMJPEG, 160, 120, 20); MjpegServer server1 = new MjpegServer("cam1", 1181); server1.setSource(usbCam); */ UsbCamera camera = CameraServer.getInstance().startAutomaticCapture(); camera.setVideoMode(VideoMode.PixelFormat.kMJPEG, 160, 120, 20); //SMARTDASBOARD driveSetting = "LOW START"; gearSetting = "GEAR CLOSE START"; }
public JoystickPov(XboxController controller, Direction triggerDirection) { this.controller = controller; this.triggerDirection = triggerDirection; }
public OI() { driveJoystick = new XboxController(0); armJoystick = new XboxController(1); // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS clawButton = new JoystickButton(armJoystick, 2); clawButton.whenPressed(new Jaws()); armButton = new JoystickButton(armJoystick, 1); armButton.whenPressed(new ArmUp()); //testButton = new JoystickButton(driveJoystick, 1); //testButton.whenPressed(new TestDriveCount()); gearSwitch = new GearSensorDigitalSwitch(); gearSwitch.whenPressed(new CloseOnTrigger()); // SmartDashboard Buttons SmartDashboard.putData("Autonomous Command", new AutonomousCommand()); SmartDashboard.putData("Mecanum Drive", new MecanumDrive()); SmartDashboard.putData("Arm Up", new ArmUp()); //SmartDashboard.putData("Arm Down", new ArmDown()); SmartDashboard.putData("Jaws Close", new Jaws()); //SmartDashboard.putData("Jaws Open", new JawsOpen()); SmartDashboard.putData("Winch Up", new WinchUp()); SmartDashboard.putData("DriveToPeg", new DriveToPeg()); // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS /* xbox button mapping * A = 1 * B = 2 * X = 3 * Y = 4 * leftStick press = 9 * rightStick press = 10 * backButton = 7 * startButton = 8 * leftBumper = 5 * rightBumper = 6 */ }
public XboxController getDriveJoystick() { return driveJoystick; }
public XboxController getArmJoystick() { return armJoystick; }
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); } }
public OI() { this.joystick = new XboxController(RobotMap.XBOX_CONTROLLER); this.joystick2 = new XboxController(RobotMap.XBOX_CONTROLLER2); this.buttonA2 = new JoystickButton(this.joystick2, 1); this.buttonB2 = new JoystickButton(this.joystick2, 2); this.buttonX2 = new JoystickButton(this.joystick2, 3); this.buttonY2 = new JoystickButton(this.joystick2, 4); this.buttonLeftBumper2 = new JoystickButton(this.joystick2, 5); this.buttonRightBumper2 = new JoystickButton(this.joystick2, 6); this.buttonBack2 = new JoystickButton(this.joystick2, 7); this.buttonStart2 = new JoystickButton(this.joystick2, 8); this.buttonLeftThumb2 = new JoystickButton(this.joystick2, 9); this.buttonRightThumb2 = new JoystickButton(this.joystick2, 10); this.dpadUp2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 0;}}; this.dpadUpRight2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 45;}}; this.dpadRight2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 90;}}; this.dpadDownRight2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 135;}}; this.dpadDown2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 180;}}; this.dpadDownLeft2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 225;}}; this.dpadLeft2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 270;}}; this.dpadUpLeft2 = new Trigger() {@Override public boolean get() {return joystick2.getPOV(0) == 315;}}; // mappings based on this post from CD... // https://www.chiefdelphi.com/forums/attachment.php?attachmentid=20028&d=1455109186 this.buttonA = new JoystickButton(this.joystick, 1); this.buttonB = new JoystickButton(this.joystick, 2); this.buttonX = new JoystickButton(this.joystick, 3); this.buttonY = new JoystickButton(this.joystick, 4); this.buttonLeftBumper = new JoystickButton(this.joystick, 5); this.buttonRightBumper = new JoystickButton(this.joystick, 6); this.buttonBack = new JoystickButton(this.joystick, 7); this.buttonStart = new JoystickButton(this.joystick, 8); this.buttonLeftThumb = new JoystickButton(this.joystick, 9); this.buttonRightThumb = new JoystickButton(this.joystick, 10); this.dpadUp = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 0;}}; this.dpadUpRight = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 45;}}; this.dpadRight = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 90;}}; this.dpadDownRight = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 135;}}; this.dpadDown = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 180;}}; this.dpadDownLeft = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 225;}}; this.dpadLeft = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 270;}}; this.dpadUpLeft = new Trigger() {@Override public boolean get() {return joystick.getPOV(0) == 315;}}; //this.buttonA.whenPressed(new DriveHeadingAndDistance(0, 1)); //this.buttonA.whenPressed(new DriveStraightCommand(5)); // this.buttonA.whenPressed(new DriveStraightCommand(5)); //this.buttonB.whenPressed(new TurnToHeading(180)); this.buttonRightBumper.whileHeld(new DeliverGearCommand()); this.buttonA2.whenPressed(new FeederCommand()); this.buttonB2.toggleWhenPressed(new ShooterCommand()); //this.buttonX2.whenPressed(new PushGear()); }
public XboxController getJoystick() { return joystick; }
public XboxController getJoystick2() { return joystick2; }