Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Data Range on Joystick.getRawAxis (http://www.chiefdelphi.com/forums/showthread.php?t=126788)

danebouchie 18-02-2014 20:24

Data Range on Joystick.getRawAxis
 
I couldn't find what the range goes to. Is it mesaured in angles (0-360), radians (0-2pi) or -1 to 1? (Java)

NWChen 18-02-2014 20:36

Re: Data Range on Joystick.getRawAxis
 
getRawAxis() returns a double in the range -1.0 to 1.0. As a default (joystick centered) the method returns 0.0.

For more information look at the WPILib API courtesy of 2168.

Joe Ross 19-02-2014 04:36

Re: Data Range on Joystick.getRawAxis
 
Quote:

Originally Posted by Signet (Post 1345598)
getRawAxis() returns a double in the range -1.0 to 1.0. As a default (joystick centered) the method returns 0.0.

For more information look at the WPILib API courtesy of 2168.

I'm curious where you found that information in the javadocs. I couldn't find it.

NWChen 19-02-2014 08:58

Re: Data Range on Joystick.getRawAxis
 
Quote:

Originally Posted by Joe Ross (Post 1345859)
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;
}


gluxon 19-02-2014 09:03

Re: Data Range on Joystick.getRawAxis
 
Quote:

Originally Posted by Signet (Post 1345918)
The method summary of getRawAxis() in Joystick links to this source code:
Code:

      double result;
      if (value < 0) {
          result = ((double) value) / 128.0;
      } else {
          result = ((double) value) / 127.0;
      }
}


Interesting. I wonder if positive joystick values are expanded (more sensitive) than negative ones looking at this code.

apalrd 19-02-2014 09:54

Re: Data Range on Joystick.getRawAxis
 
Quote:

Originally Posted by gluxon (Post 1345923)
Interesting. I wonder if positive joystick values are expanded (more sensitive) than negative ones looking at this code.

Not really.

The JS is sent as a signed int (two's compliment) in the UDP packet.

A signed int has a range of -128 to +127. This is because there is no 'negative zero', so there is 1 'extra' count on the negative side since zero is considered a positive number.


All times are GMT -5. The time now is 02:34.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi