|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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)
Last edited by danebouchie : 18-02-2014 at 20:29. |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
||||||
|
||||||
|
Re: Data Range on Joystick.getRawAxis
Quote:
|
|
#4
|
||||
|
||||
|
Re: Data Range on Joystick.getRawAxis
Quote:
Code:
public double getRawAxis(final int axis) {
return m_ds.getStickAxis(m_port, axis);
}
Code:
private DriverStation m_ds; 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;
}
|
|
#5
|
||||
|
||||
|
Re: Data Range on Joystick.getRawAxis
Interesting. I wonder if positive joystick values are expanded (more sensitive) than negative ones looking at this code.
|
|
#6
|
|||||
|
|||||
|
Re: Data Range on Joystick.getRawAxis
Quote:
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|