View Single Post
  #4   Spotlight this post!  
Unread 19-02-2014, 08:58
NWChen's Avatar
NWChen NWChen is offline
Alum
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: New York City
Posts: 205
NWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to behold
Re: Data Range on Joystick.getRawAxis

Quote:
Originally Posted by Joe Ross View Post
I'm curious where you found that information in the javadocs. I couldn't find it.
The method summary of getRawAxis() in Joystick links to this source code:
Code:
public double getRawAxis(final int axis) {
    return m_ds.getStickAxis(m_port, axis);
}
getStickAxis() is a method of DriverStation:
Code:
private DriverStation m_ds;
and in the DriverStation class the getStickAxis() method used with m_ds earlier is as follows:
Code:
public double getStickAxis(int stick, int axis) {
       if (axis < 1 || axis > kJoystickAxes) {
           return 0.0;
       }
   
           int value;
           switch (stick) {
                    ...
           default:
               return 0.0;
       }
   
       double result;
       if (value < 0) {
           result = ((double) value) / 128.0;
       } else {
           result = ((double) value) / 127.0;
       }
   
       // wpi_assert(result <= 1.0 && result >= -1.0);
       if (result > 1.0) {
           result = 1.0;
       } else if (result < -1.0) {
           result = -1.0;
       }
    return result;
}