Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wpilib] add ADIS16470 methods with no params #6184

Merged
merged 5 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions wpilibc/src/main/native/include/frc/ADIS16470_IMU.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,20 @@ class ADIS16470_IMU : public wpi::Sendable,
/**
* Returns the axis angle (CCW positive).
*
* @param axis The IMUAxis whose angle to return.
* @param axis The IMUAxis whose angle to return. Defaults to user configured
* Yaw.
* @return The axis angle (CCW positive).
*/
units::degree_t GetAngle(IMUAxis axis) const;
units::degree_t GetAngle(IMUAxis axis = IMUAxis::kYaw) const;

/**
* Returns the axis angular rate (CCW positive).
*
* @param axis The IMUAxis whose rate to return.
* @param axis The IMUAxis whose rate to return. Defaults to user configured
* Yaw.
* @return Axis angular rate (CCW positive).
*/
units::degrees_per_second_t GetRate(IMUAxis axis) const;
units::degrees_per_second_t GetRate(IMUAxis axis = IMUAxis::kYaw) const;

/**
* Returns the acceleration in the X axis.
Expand Down
54 changes: 54 additions & 0 deletions wpilibj/src/main/java/edu/wpi/first/wpilibj/ADIS16470_IMU.java
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,33 @@ public synchronized double getAngle(IMUAxis axis) {
return 0.0;
}

/**
* Returns the Yaw axis angle in degrees (CCW positive).
*
* @return The Yaw axis angle in degrees (CCW positive).
*/
public synchronized double getAngle() {
switch (m_yaw_axis) {
case kX:
if (m_simGyroAngleX != null) {
return m_simGyroAngleX.get();
}
return m_integ_angle_x;
case kY:
if (m_simGyroAngleY != null) {
return m_simGyroAngleY.get();
}
return m_integ_angle_y;
case kZ:
if (m_simGyroAngleZ != null) {
return m_simGyroAngleZ.get();
}
return m_integ_angle_z;
default:
}
return 0.0;
spacey-sooty marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Returns the axis angular rate in degrees per second (CCW positive).
*
Expand Down Expand Up @@ -1177,6 +1204,33 @@ public synchronized double getRate(IMUAxis axis) {
return 0.0;
}

/**
* Returns the Yaw axis angular rate in degrees per second (CCW positive).
*
* @return Yaw axis angular rate in degrees per second (CCW positive).
*/
public synchronized double getRate() {
switch (m_yaw_axis) {
case kX:
if (m_simGyroRateX != null) {
return m_simGyroRateX.get();
}
return m_gyro_rate_x;
case kY:
if (m_simGyroRateY != null) {
return m_simGyroRateY.get();
}
return m_gyro_rate_y;
case kZ:
if (m_simGyroRateZ != null) {
return m_simGyroRateZ.get();
}
return m_gyro_rate_z;
default:
}
return 0.0;
spacey-sooty marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Returns which axis, kX, kY, or kZ, is set to the yaw axis.
*
Expand Down