View Single Post
  #2   Spotlight this post!  
Unread 04-08-2012, 13:58
Djur's Avatar
Djur Djur is offline
WPILib
AKA: Sam Carlberg
no team
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Massachusetts
Posts: 182
Djur will become famous soon enough
Re: How do I program a joystick deadband?

About your first question:

Code:
public double getJoystickValue(Joystick joystick) {
    if(Math.abs(joystick.getValue() < 0.1) return 0;
    else return joystick.getValue();
}
This checks the value of the given joystick and returns a double based on your threshold. You'll have to create the Joystick objects yourself; I am unfamiliar with Xbox controllers.

As for your second question about using two joysticks, the RobotDrive classes have an arcadeDrive method that has two arguments: the speed you go forward (the value of the throttle joystick) and the speed you turn at (the value of the turning joystick).
__________________
WPILib dev (RobotBuilder, SmartDashboard, GRIP)
Reply With Quote