Joystick Programming help

How to program the joysticks and controllers this year.

As far as I can tell it’s the same as last year.

Joystick joystick = new Joystick(0);

The parameter, in this case 0, is determined by what that particular controller ID is set to in the Driver Station software. If you have some mysterious issue where it seems like your controller isn’t working, check the ID that it’s set to in Driver Station and the code.

double x = joystick.getRawAxis(0);
double y = joystick.getRawAxis(1);

Use that to get the axis values on a scale from -1 to 1. The parameter is the axis you want to read from. Axis 0 is the x-axis on the left joystick, and 1 is the y-axis on the left joystick.

joystick.getRawButton(0);

That will tell you if a button is pressed or not. If you used this code with an xbox controller, it would tell you if the A button was pressed or not. The parameter is the button number. For xbox, A is 1, B is 2, X is 3, and so on.

You should read the WPILib screensteps documentation which has all the information you need to program your robot.

Search that site for “Joysticks” and you will find what you need.

and what do i use in place of arcadeDrive

The arcadeDrive method still exists! You can use it with any of the drive bases.

e.g.

public class DriveTrain extends Subsystem {
	WPI_TalonSRX frontLeft,frontRight,rearLeft,rearRight;
	SpeedControllerGroup leftDrive,rightDrive;
	public static DifferentialDrive drive;
	
	public DriveTrain() {
		// TODO Auto-generated constructor stub
		frontLeft = new WPI_TalonSRX(RobotMap.Drive.leftFront);
		frontRight = new WPI_TalonSRX(RobotMap.Drive.rightFront);
		rearLeft = new WPI_TalonSRX(RobotMap.Drive.leftBack);
		rearRight = new WPI_TalonSRX(RobotMap.Drive.rightBack);
		leftDrive = new SpeedControllerGroup(frontLeft,rearLeft);
		rightDrive = new SpeedControllerGroup(frontRight,rearRight);
		drive = new DifferentialDrive(leftDrive, rightDrive);
	}

	@Override
	protected void initDefaultCommand() {
		// TODO Auto-generated method stub
		drive.arcadeDrive(OI.driveStick.getRawAxis(0), OI.driveStick.getRawAxis(1));
	}
	

}