[wpilib] Make ADIS IMU classes unit-safe (#3860)

The gyro rate getters were removed since that data isn't available.
This commit is contained in:
Tyler Veness
2022-01-03 20:00:53 -08:00
committed by GitHub
parent 947f589916
commit a2510aaa0e
12 changed files with 381 additions and 666 deletions

View File

@@ -19,7 +19,6 @@ import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.networktables.NTSendable;
import edu.wpi.first.networktables.NTSendableBuilder;
import edu.wpi.first.wpilibj.interfaces.Gyro;
// CHECKSTYLE.OFF: TypeName
// CHECKSTYLE.OFF: MemberName
@@ -50,7 +49,7 @@ import edu.wpi.first.wpilibj.interfaces.Gyro;
"PMD.EmptyIfStmt",
"PMD.EmptyStatementNotInLoop"
})
public class ADIS16448_IMU implements Gyro, NTSendable {
public class ADIS16448_IMU implements AutoCloseable, NTSendable {
/** ADIS16448 Register Map Declaration */
private static final int FLASH_CNT = 0x00; // Flash memory write count
@@ -94,6 +93,27 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
private static final int PROD_ID = 0x56; // Product identifier
private static final int SERIAL_NUM = 0x58; // Lot-specific serial number
public enum CalibrationTime {
_32ms(0),
_64ms(1),
_128ms(2),
_256ms(3),
_512ms(4),
_1s(5),
_2s(6),
_4s(7),
_8s(8),
_16s(9),
_32s(10),
_64s(11);
private int value;
private CalibrationTime(int value) {
this.value = value;
}
}
public enum IMUAxis {
kX,
kY,
@@ -149,7 +169,7 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
/* State variables */
private volatile boolean m_thread_active = false;
private int m_calibration_time = 0;
private CalibrationTime m_calibration_time = CalibrationTime._512ms;
private volatile boolean m_first_run = true;
private volatile boolean m_thread_idle = false;
private boolean m_auto_configured = false;
@@ -168,9 +188,6 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
private SimDouble m_simGyroAngleX;
private SimDouble m_simGyroAngleY;
private SimDouble m_simGyroAngleZ;
private SimDouble m_simGyroRateX;
private SimDouble m_simGyroRateY;
private SimDouble m_simGyroRateZ;
private SimDouble m_simAccelX;
private SimDouble m_simAccelY;
private SimDouble m_simAccelZ;
@@ -226,7 +243,7 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
}
public ADIS16448_IMU() {
this(IMUAxis.kZ, SPI.Port.kMXP, 4);
this(IMUAxis.kZ, SPI.Port.kMXP, CalibrationTime._512ms);
}
/**
@@ -234,7 +251,7 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
* @param port The SPI Port the gyro is plugged into
* @param cal_time Calibration time
*/
public ADIS16448_IMU(final IMUAxis yaw_axis, SPI.Port port, int cal_time) {
public ADIS16448_IMU(final IMUAxis yaw_axis, SPI.Port port, CalibrationTime cal_time) {
m_yaw_axis = yaw_axis;
m_spi_port = port;
@@ -245,9 +262,6 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
m_simGyroAngleX = m_simDevice.createDouble("gyro_angle_x", SimDevice.Direction.kInput, 0.0);
m_simGyroAngleY = m_simDevice.createDouble("gyro_angle_y", SimDevice.Direction.kInput, 0.0);
m_simGyroAngleZ = m_simDevice.createDouble("gyro_angle_z", SimDevice.Direction.kInput, 0.0);
m_simGyroRateX = m_simDevice.createDouble("gyro_rate_x", SimDevice.Direction.kInput, 0.0);
m_simGyroRateY = m_simDevice.createDouble("gyro_rate_y", SimDevice.Direction.kInput, 0.0);
m_simGyroRateZ = m_simDevice.createDouble("gyro_rate_z", SimDevice.Direction.kInput, 0.0);
m_simAccelX = m_simDevice.createDouble("accel_x", SimDevice.Direction.kInput, 0.0);
m_simAccelY = m_simDevice.createDouble("accel_y", SimDevice.Direction.kInput, 0.0);
m_simAccelZ = m_simDevice.createDouble("accel_z", SimDevice.Direction.kInput, 0.0);
@@ -287,7 +301,7 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
"ADIS16448 IMU Detected. Starting initial calibration delay.", false);
// Wait for whatever time the user set as the start-up delay
try {
Thread.sleep((long) (m_calibration_time * 1.2 * 1000));
Thread.sleep((long) (m_calibration_time.value * 1.2 * 1000));
} catch (InterruptedException e) {
}
// Execute calibration routine
@@ -498,12 +512,12 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
* @param new_cal_time New calibration time
* @return 1 if the new calibration time is the same as the current one else 0
*/
public int configCalTime(int new_cal_time) {
public int configCalTime(CalibrationTime new_cal_time) {
if (m_calibration_time == new_cal_time) {
return 1;
} else {
m_calibration_time = new_cal_time;
m_avg_size = m_calibration_time * 819;
m_avg_size = m_calibration_time.value * 819;
initOffsetBuffer(m_avg_size);
return 0;
}
@@ -526,8 +540,11 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
}
}
/** {@inheritDoc} */
@Override
/**
* Calibrate the gyro. It's important to make sure that the robot is not moving while the
* calibration is in progress, this is typically done when the robot is first turned on while it's
* sitting at rest before the match starts.
*/
public void calibrate() {
synchronized (this) {
int gyroAverageSize = Math.min(m_accum_count, m_avg_size);
@@ -919,7 +936,7 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
return compAngle;
}
/** */
/** @return Yaw axis angle in degrees (CCW positive) */
public synchronized double getAngle() {
switch (m_yaw_axis) {
case kX:
@@ -933,26 +950,12 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
}
}
/** */
public synchronized double getRate() {
switch (m_yaw_axis) {
case kX:
return getGyroRateX();
case kY:
return getGyroRateY();
case kZ:
return getGyroRateZ();
default:
return 0.0;
}
}
/** @return Yaw Axis */
public IMUAxis getYawAxis() {
return m_yaw_axis;
}
/** @return accumulated gyro angle in the X axis */
/** @return accumulated gyro angle in the X axis in degrees */
public synchronized double getGyroAngleX() {
if (m_simGyroAngleX != null) {
return m_simGyroAngleX.get();
@@ -960,7 +963,7 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
return m_integ_gyro_x;
}
/** @return accumulated gyro angle in the Y axis */
/** @return accumulated gyro angle in the Y axis in degrees */
public synchronized double getGyroAngleY() {
if (m_simGyroAngleY != null) {
return m_simGyroAngleY.get();
@@ -968,7 +971,7 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
return m_integ_gyro_y;
}
/** @return accumulated gyro angle in the Z axis */
/** @return accumulated gyro angle in the Z axis in degrees */
public synchronized double getGyroAngleZ() {
if (m_simGyroAngleZ != null) {
return m_simGyroAngleZ.get();
@@ -976,95 +979,75 @@ public class ADIS16448_IMU implements Gyro, NTSendable {
return m_integ_gyro_z;
}
/** @return current gyro angle in the X axis */
public synchronized double getGyroRateX() {
if (m_simGyroRateX != null) {
return m_simGyroRateX.get();
}
return m_gyro_x;
}
/** @return current gyro angle in the Y axis */
public synchronized double getGyroRateY() {
if (m_simGyroRateY != null) {
return m_simGyroRateY.get();
}
return m_gyro_y;
}
/** @return current gyro angle in the Z axis */
public synchronized double getGyroRateZ() {
if (m_simGyroRateZ != null) {
return m_simGyroRateZ.get();
}
return m_gyro_z;
}
/** @return urrent acceleration in the X axis */
/** @return urrent acceleration in the X axis in meters per second squared */
public synchronized double getAccelX() {
if (m_simAccelX != null) {
return m_simAccelX.get();
}
return m_accel_x;
return m_accel_x * 9.81;
}
/** @return current acceleration in the Y axis */
/** @return current acceleration in the Y axis in meters per second squared */
public synchronized double getAccelY() {
if (m_simAccelY != null) {
return m_simAccelY.get();
}
return m_accel_y;
return m_accel_y * 9.81;
}
/** @return current acceleration in the Z axis */
/** @return current acceleration in the Z axis in meters per second squared */
public synchronized double getAccelZ() {
if (m_simAccelZ != null) {
return m_simAccelZ.get();
}
return m_accel_z;
return m_accel_z * 9.81;
}
/** @return Mag instant X */
public synchronized double getMagInstantX() {
return m_mag_x;
/** @return Magnetic field strength in the X axis in Tesla */
public synchronized double getMagneticFieldX() {
// mG to T
return m_mag_x * 1e-7;
}
/** @return Mag instant Y */
public synchronized double getMagInstantY() {
return m_mag_y;
/** @return Magnetic field strength in the Y axis in Tesla */
public synchronized double getMagneticFieldY() {
// mG to T
return m_mag_y * 1e-7;
}
/** @return Mag instant Z */
public synchronized double getMagInstantZ() {
return m_mag_z;
/** @return Magnetic field strength in the Z axis in Tesla */
public synchronized double getMagneticFieldZ() {
// mG to T
return m_mag_z * 1e-7;
}
/** @return X axis complementary angle */
/** @return X axis complementary angle in degrees */
public synchronized double getXComplementaryAngle() {
return m_compAngleX;
}
/** @return Y axis complementary angle */
/** @return Y axis complementary angle in degrees */
public synchronized double getYComplementaryAngle() {
return m_compAngleY;
}
/** @return X axis filtered acceleration angle */
/** @return X axis filtered acceleration angle in degrees */
public synchronized double getXFilteredAccelAngle() {
return m_accelAngleX;
}
/** @return Y axis filtered acceleration angle */
/** @return Y axis filtered acceleration angle in degrees */
public synchronized double getYFilteredAccelAngle() {
return m_accelAngleY;
}
/** @return Barometric Pressure */
/** @return Barometric Pressure in PSI */
public synchronized double getBarometricPressure() {
return m_baro;
// mbar to PSI
return m_baro * 0.0145;
}
/** @return Temperature */
/** @return Temperature in degrees Celsius */
public synchronized double getTemperature() {
return m_temp;
}

View File

@@ -18,7 +18,6 @@ import edu.wpi.first.hal.SimDevice;
import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.networktables.NTSendable;
import edu.wpi.first.networktables.NTSendableBuilder;
import edu.wpi.first.wpilibj.interfaces.Gyro;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -51,7 +50,7 @@ import java.nio.ByteOrder;
"PMD.EmptyIfStmt",
"PMD.EmptyStatementNotInLoop"
})
public class ADIS16470_IMU implements Gyro, NTSendable {
public class ADIS16470_IMU implements AutoCloseable, NTSendable {
/* ADIS16470 Register Map Declaration */
private static final int FLASH_CNT = 0x00; // Flash memory write count
private static final int DIAG_STAT = 0x02; // Diagnostic and operational status
@@ -179,13 +178,7 @@ public class ADIS16470_IMU implements Gyro, NTSendable {
FLASH_CNT
};
public enum IMUAxis {
kX,
kY,
kZ
}
public enum ADIS16470CalibrationTime {
public enum CalibrationTime {
_32ms(0),
_64ms(1),
_128ms(2),
@@ -201,11 +194,17 @@ public class ADIS16470_IMU implements Gyro, NTSendable {
private int value;
private ADIS16470CalibrationTime(int value) {
private CalibrationTime(int value) {
this.value = value;
}
}
public enum IMUAxis {
kX,
kY,
kZ
}
// Static Constants
private static final double delta_angle_sf = 2160.0 / 2147483648.0; /* 2160 / (2^31) */
private static final double rad_to_deg = 57.2957795;
@@ -256,9 +255,6 @@ public class ADIS16470_IMU implements Gyro, NTSendable {
private SimDouble m_simGyroAngleX;
private SimDouble m_simGyroAngleY;
private SimDouble m_simGyroAngleZ;
private SimDouble m_simGyroRateX;
private SimDouble m_simGyroRateY;
private SimDouble m_simGyroRateZ;
private SimDouble m_simAccelX;
private SimDouble m_simAccelY;
private SimDouble m_simAccelZ;
@@ -277,7 +273,7 @@ public class ADIS16470_IMU implements Gyro, NTSendable {
}
public ADIS16470_IMU() {
this(IMUAxis.kZ, SPI.Port.kOnboardCS0, ADIS16470CalibrationTime._4s);
this(IMUAxis.kZ, SPI.Port.kOnboardCS0, CalibrationTime._4s);
}
/**
@@ -285,7 +281,7 @@ public class ADIS16470_IMU implements Gyro, NTSendable {
* @param port The SPI Port the gyro is plugged into
* @param cal_time Calibration time
*/
public ADIS16470_IMU(IMUAxis yaw_axis, SPI.Port port, ADIS16470CalibrationTime cal_time) {
public ADIS16470_IMU(IMUAxis yaw_axis, SPI.Port port, CalibrationTime cal_time) {
m_yaw_axis = yaw_axis;
m_calibration_time = cal_time.value;
m_spi_port = port;
@@ -297,9 +293,6 @@ public class ADIS16470_IMU implements Gyro, NTSendable {
m_simGyroAngleX = m_simDevice.createDouble("gyro_angle_x", SimDevice.Direction.kInput, 0.0);
m_simGyroAngleY = m_simDevice.createDouble("gyro_angle_y", SimDevice.Direction.kInput, 0.0);
m_simGyroAngleZ = m_simDevice.createDouble("gyro_angle_z", SimDevice.Direction.kInput, 0.0);
m_simGyroRateX = m_simDevice.createDouble("gyro_rate_x", SimDevice.Direction.kInput, 0.0);
m_simGyroRateY = m_simDevice.createDouble("gyro_rate_y", SimDevice.Direction.kInput, 0.0);
m_simGyroRateZ = m_simDevice.createDouble("gyro_rate_z", SimDevice.Direction.kInput, 0.0);
m_simAccelX = m_simDevice.createDouble("accel_x", SimDevice.Direction.kInput, 0.0);
m_simAccelY = m_simDevice.createDouble("accel_y", SimDevice.Direction.kInput, 0.0);
m_simAccelZ = m_simDevice.createDouble("accel_z", SimDevice.Direction.kInput, 0.0);
@@ -533,7 +526,7 @@ public class ADIS16470_IMU implements Gyro, NTSendable {
* @param new_cal_time New calibration time
* @return 1 if the new calibration time is the same as the current one else 0
*/
public int configCalTime(ADIS16470CalibrationTime new_cal_time) {
public int configCalTime(CalibrationTime new_cal_time) {
if (m_calibration_time == new_cal_time.value) {
return 1;
}
@@ -570,8 +563,11 @@ public class ADIS16470_IMU implements Gyro, NTSendable {
return 0;
}
/** {@inheritDoc} */
@Override
/**
* Calibrate the gyro. It's important to make sure that the robot is not moving while the
* calibration is in progress, this is typically done when the robot is first turned on while it's
* sitting at rest before the match starts.
*/
public void calibrate() {
if (!switchToStandardSPI()) {
DriverStation.reportError("Failed to configure/reconfigure standard SPI.", false);
@@ -916,7 +912,7 @@ public class ADIS16470_IMU implements Gyro, NTSendable {
return compAngle;
}
/** {@inheritDoc} */
/** @return Yaw axis angle in degrees (CCW positive) */
public synchronized double getAngle() {
switch (m_yaw_axis) {
case kX:
@@ -938,61 +934,24 @@ public class ADIS16470_IMU implements Gyro, NTSendable {
return m_integ_angle;
}
/** {@inheritDoc} */
public synchronized double getRate() {
switch (m_yaw_axis) {
case kX:
return getGyroRateX();
case kY:
return getGyroRateY();
case kZ:
return getGyroRateZ();
}
return 0.0;
}
/** @return Yaw Axis */
public IMUAxis getYawAxis() {
return m_yaw_axis;
}
/** @return current gyro angle in the X direction */
public synchronized double getGyroRateX() {
if (m_simGyroRateX != null) {
return m_simGyroRateX.get();
}
return m_gyro_x;
}
/** @return current gyro angle in the Y axis */
public synchronized double getGyroRateY() {
if (m_simGyroRateY != null) {
return m_simGyroRateY.get();
}
return m_gyro_y;
}
/** @return current gyro angle in the Z axis */
public synchronized double getGyroRateZ() {
if (m_simGyroRateZ != null) {
return m_simGyroRateZ.get();
}
return m_gyro_z;
}
/** @return current acceleration in the X axis */
public synchronized double getAccelInstantX() {
return m_accel_x;
public synchronized double getAccelX() {
return m_accel_x * 9.81;
}
/** @return current acceleration in the Y axis */
public synchronized double getAccelInstantY() {
return m_accel_y;
public synchronized double getAccelY() {
return m_accel_y * 9.81;
}
/** @return current acceleration in the Z axis */
public synchronized double getAccelInstantZ() {
return m_accel_z;
public synchronized double getAccelZ() {
return m_accel_z * 9.81;
}
/** @return X axis complementary angle */

View File

@@ -13,9 +13,6 @@ public class ADIS16448_IMUSim {
private final SimDouble m_simGyroAngleX;
private final SimDouble m_simGyroAngleY;
private final SimDouble m_simGyroAngleZ;
private final SimDouble m_simGyroRateX;
private final SimDouble m_simGyroRateY;
private final SimDouble m_simGyroRateZ;
private final SimDouble m_simAccelX;
private final SimDouble m_simAccelY;
private final SimDouble m_simAccelZ;
@@ -30,16 +27,13 @@ public class ADIS16448_IMUSim {
m_simGyroAngleX = wrappedSimDevice.getDouble("gyro_angle_x");
m_simGyroAngleY = wrappedSimDevice.getDouble("gyro_angle_y");
m_simGyroAngleZ = wrappedSimDevice.getDouble("gyro_angle_z");
m_simGyroRateX = wrappedSimDevice.getDouble("gyro_rate_x");
m_simGyroRateY = wrappedSimDevice.getDouble("gyro_rate_y");
m_simGyroRateZ = wrappedSimDevice.getDouble("gyro_rate_z");
m_simAccelX = wrappedSimDevice.getDouble("accel_x");
m_simAccelY = wrappedSimDevice.getDouble("accel_y");
m_simAccelZ = wrappedSimDevice.getDouble("accel_z");
}
/**
* Sets the X axis angle (CCW positive).
* Sets the X axis angle in degrees (CCW positive).
*
* @param angleDegrees The angle.
*/
@@ -48,7 +42,7 @@ public class ADIS16448_IMUSim {
}
/**
* Sets the Y axis angle (CCW positive).
* Sets the Y axis angle in degrees (CCW positive).
*
* @param angleDegrees The angle.
*/
@@ -57,7 +51,7 @@ public class ADIS16448_IMUSim {
}
/**
* Sets the Z axis angle (CCW positive).
* Sets the Z axis angle in degrees (CCW positive).
*
* @param angleDegrees The angle.
*/
@@ -66,56 +60,29 @@ public class ADIS16448_IMUSim {
}
/**
* Sets the X axis angular rate (CCW positive).
* Sets the X axis acceleration in meters per second squared.
*
* @param rateDegreesPerSecond The angular rate.
* @param accelMetersPerSecondSquared The acceleration.
*/
public void setGyroRateX(double rateDegreesPerSecond) {
m_simGyroRateX.set(rateDegreesPerSecond);
public void setAccelX(double accelMetersPerSecondSquared) {
m_simAccelX.set(accelMetersPerSecondSquared);
}
/**
* Sets the Y axis angular rate (CCW positive).
* Sets the Y axis acceleration in meters per second squared.
*
* @param rateDegreesPerSecond The angular rate.
* @param accelMetersPerSecondSquared The acceleration.
*/
public void setGyroRateY(double rateDegreesPerSecond) {
m_simGyroRateY.set(rateDegreesPerSecond);
public void setAccelY(double accelMetersPerSecondSquared) {
m_simAccelY.set(accelMetersPerSecondSquared);
}
/**
* Sets the Z axis angular rate (CCW positive).
* Sets the Z axis acceleration in meters per second squared.
*
* @param rateDegreesPerSecond The angular rate.
* @param accelMetersPerSecondSquared The acceleration.
*/
public void setGyroRateZ(double rateDegreesPerSecond) {
m_simGyroRateZ.set(rateDegreesPerSecond);
}
/**
* Sets the X axis acceleration.
*
* @param accelMetersPerSecond The acceleration.
*/
public void setAccelX(double accelMetersPerSecond) {
m_simAccelX.set(accelMetersPerSecond / 9.81);
}
/**
* Sets the Y axis acceleration.
*
* @param accelMetersPerSecond The acceleration.
*/
public void setAccelY(double accelMetersPerSecond) {
m_simAccelY.set(accelMetersPerSecond / 9.81);
}
/**
* Sets the Z axis acceleration.
*
* @param accelMetersPerSecond The acceleration.
*/
public void setAccelZ(double accelMetersPerSecond) {
m_simAccelZ.set(accelMetersPerSecond / 9.81);
public void setAccelZ(double accelMetersPerSecondSquared) {
m_simAccelZ.set(accelMetersPerSecondSquared);
}
}

View File

@@ -13,9 +13,6 @@ public class ADIS16470_IMUSim {
private final SimDouble m_simGyroAngleX;
private final SimDouble m_simGyroAngleY;
private final SimDouble m_simGyroAngleZ;
private final SimDouble m_simGyroRateX;
private final SimDouble m_simGyroRateY;
private final SimDouble m_simGyroRateZ;
private final SimDouble m_simAccelX;
private final SimDouble m_simAccelY;
private final SimDouble m_simAccelZ;
@@ -30,16 +27,13 @@ public class ADIS16470_IMUSim {
m_simGyroAngleX = wrappedSimDevice.getDouble("gyro_angle_x");
m_simGyroAngleY = wrappedSimDevice.getDouble("gyro_angle_y");
m_simGyroAngleZ = wrappedSimDevice.getDouble("gyro_angle_z");
m_simGyroRateX = wrappedSimDevice.getDouble("gyro_rate_x");
m_simGyroRateY = wrappedSimDevice.getDouble("gyro_rate_y");
m_simGyroRateZ = wrappedSimDevice.getDouble("gyro_rate_z");
m_simAccelX = wrappedSimDevice.getDouble("accel_x");
m_simAccelY = wrappedSimDevice.getDouble("accel_y");
m_simAccelZ = wrappedSimDevice.getDouble("accel_z");
}
/**
* Sets the X axis angle (CCW positive).
* Sets the X axis angle in degrees (CCW positive).
*
* @param angleDegrees The angle.
*/
@@ -48,7 +42,7 @@ public class ADIS16470_IMUSim {
}
/**
* Sets the Y axis angle (CCW positive).
* Sets the Y axis angle in degrees (CCW positive).
*
* @param angleDegrees The angle.
*/
@@ -57,7 +51,7 @@ public class ADIS16470_IMUSim {
}
/**
* Sets the Z axis angle (CCW positive).
* Sets the Z axis angle in degrees (CCW positive).
*
* @param angleDegrees The angle.
*/
@@ -66,56 +60,29 @@ public class ADIS16470_IMUSim {
}
/**
* Sets the X axis angular rate (CCW positive).
* Sets the X axis acceleration in meters per second squared.
*
* @param rateDegreesPerSecond The angular rate.
* @param accelMetersPerSecondSquared The acceleration.
*/
public void setGyroRateX(double rateDegreesPerSecond) {
m_simGyroRateX.set(rateDegreesPerSecond);
public void setAccelX(double accelMetersPerSecondSquared) {
m_simAccelX.set(accelMetersPerSecondSquared);
}
/**
* Sets the Y axis angular rate (CCW positive).
* Sets the Y axis acceleration in meters per second squared.
*
* @param rateDegreesPerSecond The angular rate.
* @param accelMetersPerSecondSquared The acceleration.
*/
public void setGyroRateY(double rateDegreesPerSecond) {
m_simGyroRateY.set(rateDegreesPerSecond);
public void setAccelY(double accelMetersPerSecondSquared) {
m_simAccelY.set(accelMetersPerSecondSquared);
}
/**
* Sets the Z axis angular rate (CCW positive).
* Sets the Z axis acceleration in meters per second squared.
*
* @param rateDegreesPerSecond The angular rate.
* @param accelMetersPerSecondSquared The acceleration.
*/
public void setGyroRateZ(double rateDegreesPerSecond) {
m_simGyroRateZ.set(rateDegreesPerSecond);
}
/**
* Sets the X axis acceleration.
*
* @param accelMetersPerSecond The acceleration.
*/
public void setAccelX(double accelMetersPerSecond) {
m_simAccelX.set(accelMetersPerSecond / 9.81);
}
/**
* Sets the Y axis acceleration.
*
* @param accelMetersPerSecond The acceleration.
*/
public void setAccelY(double accelMetersPerSecond) {
m_simAccelY.set(accelMetersPerSecond / 9.81);
}
/**
* Sets the Z axis acceleration.
*
* @param accelMetersPerSecond The acceleration.
*/
public void setAccelZ(double accelMetersPerSecond) {
m_simAccelZ.set(accelMetersPerSecond / 9.81);
public void setAccelZ(double accelMetersPerSecondSquared) {
m_simAccelZ.set(accelMetersPerSecondSquared);
}
}