mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
[docs] Add missing JavaDocs (#6125)
This commit is contained in:
@@ -11,14 +11,23 @@ import edu.wpi.first.math.geometry.Pose3d;
|
||||
import edu.wpi.first.util.RawFrame;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Represents an AprilTag's metadata. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class AprilTag {
|
||||
/** The tag's ID. */
|
||||
@JsonProperty(value = "ID")
|
||||
public int ID;
|
||||
|
||||
/** The tag's pose. */
|
||||
@JsonProperty(value = "pose")
|
||||
public Pose3d pose;
|
||||
|
||||
/**
|
||||
* Constructs an AprilTag.
|
||||
*
|
||||
* @param ID The tag's ID.
|
||||
* @param pose The tag's pose.
|
||||
*/
|
||||
@SuppressWarnings("ParameterName")
|
||||
@JsonCreator
|
||||
public AprilTag(
|
||||
|
||||
@@ -182,6 +182,7 @@ public class AprilTagDetector implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/** Constructs an AprilTagDetector. */
|
||||
public AprilTagDetector() {
|
||||
m_native = AprilTagJNI.createDetector();
|
||||
}
|
||||
|
||||
@@ -13,21 +13,36 @@ import edu.wpi.first.util.RuntimeLoader;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/** AprilTag JNI. */
|
||||
public class AprilTagJNI {
|
||||
static boolean libraryLoaded = false;
|
||||
|
||||
static RuntimeLoader<AprilTagJNI> loader = null;
|
||||
|
||||
/** Sets whether JNI should be loaded in the static block. */
|
||||
public static class Helper {
|
||||
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
|
||||
|
||||
/**
|
||||
* Returns true if the JNI should be loaded in the static block.
|
||||
*
|
||||
* @return True if the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static boolean getExtractOnStaticLoad() {
|
||||
return extractOnStaticLoad.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the JNI should be loaded in the static block.
|
||||
*
|
||||
* @param load Whether the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static void setExtractOnStaticLoad(boolean load) {
|
||||
extractOnStaticLoad.set(load);
|
||||
}
|
||||
|
||||
/** Utility class. */
|
||||
private Helper() {}
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -194,4 +209,7 @@ public class AprilTagJNI {
|
||||
public static native void generate16h5AprilTagImage(RawFrame frameObj, long frame, int id);
|
||||
|
||||
public static native void generate36h11AprilTagImage(RawFrame frameObj, long frame, int id);
|
||||
|
||||
/** Utility class. */
|
||||
private AprilTagJNI() {}
|
||||
}
|
||||
|
||||
@@ -12,14 +12,16 @@
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Represents an AprilTag's metadata.
|
||||
*/
|
||||
struct WPILIB_DLLEXPORT AprilTag {
|
||||
/// The tag's ID.
|
||||
int ID;
|
||||
|
||||
/// The tag's pose.
|
||||
Pose3d pose;
|
||||
|
||||
/**
|
||||
* Checks equality between this AprilTag and another object.
|
||||
*/
|
||||
bool operator==(const AprilTag&) const = default;
|
||||
|
||||
static bool Generate36h11AprilTagImage(wpi::RawFrame* frame, int id);
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.opencv.core.Mat;
|
||||
* code. The easiest way to use this is to run it in a {@link VisionThread} and use the listener to
|
||||
* take snapshots of the pipeline's outputs.
|
||||
*
|
||||
* @param <P> Vision pipeline type.
|
||||
* @see VisionPipeline
|
||||
* @see VisionThread
|
||||
* @see <a href="package-summary.html">vision</a>
|
||||
|
||||
@@ -9,21 +9,36 @@ import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.opencv.core.Core;
|
||||
|
||||
/** CameraServer CV JNI. */
|
||||
public class CameraServerCvJNI {
|
||||
static boolean libraryLoaded = false;
|
||||
|
||||
static RuntimeLoader<Core> loader = null;
|
||||
|
||||
/** Sets whether JNI should be loaded in the static block. */
|
||||
public static class Helper {
|
||||
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
|
||||
|
||||
/**
|
||||
* Returns true if the JNI should be loaded in the static block.
|
||||
*
|
||||
* @return True if the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static boolean getExtractOnStaticLoad() {
|
||||
return extractOnStaticLoad.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the JNI should be loaded in the static block.
|
||||
*
|
||||
* @param load Whether the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static void setExtractOnStaticLoad(boolean load) {
|
||||
extractOnStaticLoad.set(load);
|
||||
}
|
||||
|
||||
/** Utility class. */
|
||||
private Helper() {}
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -72,4 +87,7 @@ public class CameraServerCvJNI {
|
||||
public static native long grabSinkFrame(int sink, long imageNativeObj);
|
||||
|
||||
public static native long grabSinkFrameTimeout(int sink, long imageNativeObj, double timeout);
|
||||
|
||||
/** Utility class. */
|
||||
private CameraServerCvJNI() {}
|
||||
}
|
||||
|
||||
@@ -11,21 +11,36 @@ import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/** CameraServer JNI. */
|
||||
public class CameraServerJNI {
|
||||
static boolean libraryLoaded = false;
|
||||
|
||||
static RuntimeLoader<CameraServerJNI> loader = null;
|
||||
|
||||
/** Sets whether JNI should be loaded in the static block. */
|
||||
public static class Helper {
|
||||
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
|
||||
|
||||
/**
|
||||
* Returns true if the JNI should be loaded in the static block.
|
||||
*
|
||||
* @return True if the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static boolean getExtractOnStaticLoad() {
|
||||
return extractOnStaticLoad.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the JNI should be loaded in the static block.
|
||||
*
|
||||
* @param load Whether the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static void setExtractOnStaticLoad(boolean load) {
|
||||
extractOnStaticLoad.set(load);
|
||||
}
|
||||
|
||||
/** Utility class. */
|
||||
private Helper() {}
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -347,4 +362,7 @@ public class CameraServerJNI {
|
||||
public static native int runMainRunLoopTimeout(double timeoutSeconds);
|
||||
|
||||
public static native void stopMainRunLoop();
|
||||
|
||||
/** Utility class. */
|
||||
private CameraServerJNI() {}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,7 @@ public class AccelerometerJNI extends JNIWrapper {
|
||||
* @return the Z acceleration
|
||||
*/
|
||||
public static native double getAccelerometerZ();
|
||||
|
||||
/** Utility class. */
|
||||
private AccelerometerJNI() {}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ public class AccumulatorResult {
|
||||
/** The number of sample value was accumulated over. */
|
||||
public long count;
|
||||
|
||||
/** Constructs an AccumulatorResult. */
|
||||
public AccumulatorResult() {}
|
||||
|
||||
/**
|
||||
* Set the value and count.
|
||||
*
|
||||
|
||||
@@ -97,4 +97,7 @@ public class AddressableLEDJNI extends JNIWrapper {
|
||||
* @see "HAL_StopAddressableLEDOutput"
|
||||
*/
|
||||
public static native void stop(int handle);
|
||||
|
||||
/** Utility class. */
|
||||
private AddressableLEDJNI() {}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,20 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/** Alliance station ID. */
|
||||
public enum AllianceStationID {
|
||||
/** Unknown. */
|
||||
Unknown,
|
||||
/** Red 1. */
|
||||
Red1,
|
||||
/** Red 2. */
|
||||
Red2,
|
||||
/** Red 3. */
|
||||
Red3,
|
||||
/** Blue 1. */
|
||||
Blue1,
|
||||
/** Blue 2. */
|
||||
Blue2,
|
||||
/** Blue 3. */
|
||||
Blue3
|
||||
}
|
||||
|
||||
@@ -126,4 +126,7 @@ public class AnalogGyroJNI extends JNIWrapper {
|
||||
* @see "HAL_GetAnalogGyroCenter"
|
||||
*/
|
||||
public static native int getAnalogGyroCenter(int handle);
|
||||
|
||||
/** Utility class. */
|
||||
private AnalogGyroJNI() {}
|
||||
}
|
||||
|
||||
@@ -497,4 +497,7 @@ public class AnalogJNI extends JNIWrapper {
|
||||
* @see "HAL_GetAnalogTriggerFPGAIndex"
|
||||
*/
|
||||
public static native int getAnalogTriggerFPGAIndex(int analogTriggerHandle);
|
||||
|
||||
/** Utility class. */
|
||||
private AnalogJNI() {}
|
||||
}
|
||||
|
||||
@@ -177,4 +177,7 @@ public class CANAPIJNI extends JNIWrapper {
|
||||
*/
|
||||
public static native boolean readCANPacketTimeout(
|
||||
int handle, int apiId, int timeoutMs, CANData data);
|
||||
|
||||
/** Utility class. */
|
||||
private CANAPIJNI() {}
|
||||
}
|
||||
|
||||
@@ -221,4 +221,7 @@ public class CTREPCMJNI extends JNIWrapper {
|
||||
* @see "HAL_SetCTREPCMOneShotDuration"
|
||||
*/
|
||||
public static native void setOneShotDuration(int handle, int index, int durMs);
|
||||
|
||||
/** Utility class. */
|
||||
private CTREPCMJNI() {}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,7 @@ public class ConstantsJNI extends JNIWrapper {
|
||||
* @see "HAL_GetSystemClockTicksPerMicrosecond"
|
||||
*/
|
||||
public static native int getSystemClockTicksPerMicrosecond();
|
||||
|
||||
/** Utility class. */
|
||||
private ConstantsJNI() {}
|
||||
}
|
||||
|
||||
@@ -279,4 +279,7 @@ public class CounterJNI extends JNIWrapper {
|
||||
* @see "HAL_SetCounterReverseDirection"
|
||||
*/
|
||||
public static native void setCounterReverseDirection(int counterHandle, boolean reverseDirection);
|
||||
|
||||
/** Utility class. */
|
||||
private CounterJNI() {}
|
||||
}
|
||||
|
||||
@@ -178,4 +178,7 @@ public class DIOJNI extends JNIWrapper {
|
||||
* @see "HAL_SetDigitalPWMOutputChannel"
|
||||
*/
|
||||
public static native void setDigitalPWMOutputChannel(int pwmGenerator, int channel);
|
||||
|
||||
/** Utility class. */
|
||||
DIOJNI() {}
|
||||
}
|
||||
|
||||
@@ -245,4 +245,7 @@ public class DMAJNI extends JNIWrapper {
|
||||
* @return The DMA sample
|
||||
*/
|
||||
public static native DMAJNISample.BaseStore getSensorReadData(int handle);
|
||||
|
||||
/** Utility class. */
|
||||
private DMAJNI() {}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,7 @@ public class DigitalGlitchFilterJNI extends JNIWrapper {
|
||||
* @see "HAL_GetFilterPeriod"
|
||||
*/
|
||||
public static native int getFilterPeriod(int filterIndex);
|
||||
|
||||
/** Utility class. */
|
||||
private DigitalGlitchFilterJNI() {}
|
||||
}
|
||||
|
||||
@@ -372,5 +372,6 @@ public class DriverStationJNI extends JNIWrapper {
|
||||
*/
|
||||
public static native boolean getOutputsActive();
|
||||
|
||||
/** Utility class. */
|
||||
private DriverStationJNI() {}
|
||||
}
|
||||
|
||||
@@ -78,4 +78,7 @@ public class DutyCycleJNI extends JNIWrapper {
|
||||
* @see "HAL_GetDutyCycleFPGAIndex"
|
||||
*/
|
||||
public static native int getFPGAIndex(int handle);
|
||||
|
||||
/** Utility class. */
|
||||
private DutyCycleJNI() {}
|
||||
}
|
||||
|
||||
@@ -275,4 +275,7 @@ public class EncoderJNI extends JNIWrapper {
|
||||
* @see "HAL_GetEncoderEncodingType"
|
||||
*/
|
||||
public static native int getEncoderEncodingType(int encoderHandle);
|
||||
|
||||
/** Utility class. */
|
||||
private EncoderJNI() {}
|
||||
}
|
||||
|
||||
@@ -135,4 +135,7 @@ public class I2CJNI extends JNIWrapper {
|
||||
* @see "HAL_CloseI2C"
|
||||
*/
|
||||
public static native void i2CClose(int port);
|
||||
|
||||
/** Utility class. */
|
||||
private I2CJNI() {}
|
||||
}
|
||||
|
||||
@@ -113,4 +113,7 @@ public class InterruptJNI extends JNIWrapper {
|
||||
* @see "HAL_ReleaseWaitingInterrupt"
|
||||
*/
|
||||
public static native void releaseWaitingInterrupt(int interruptHandle);
|
||||
|
||||
/** Utility class. */
|
||||
private InterruptJNI() {}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,30 @@ public class JNIWrapper {
|
||||
static boolean libraryLoaded = false;
|
||||
static RuntimeLoader<JNIWrapper> loader = null;
|
||||
|
||||
/** Sets whether JNI should be loaded in the static block. */
|
||||
public static class Helper {
|
||||
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
|
||||
|
||||
/**
|
||||
* Returns true if the JNI should be loaded in the static block.
|
||||
*
|
||||
* @return True if the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static boolean getExtractOnStaticLoad() {
|
||||
return extractOnStaticLoad.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the JNI should be loaded in the static block.
|
||||
*
|
||||
* @param load Whether the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static void setExtractOnStaticLoad(boolean load) {
|
||||
extractOnStaticLoad.set(load);
|
||||
}
|
||||
|
||||
/** Utility class. */
|
||||
private Helper() {}
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -57,4 +71,7 @@ public class JNIWrapper {
|
||||
}
|
||||
|
||||
public static void suppressUnused(Object object) {}
|
||||
|
||||
/** Utility class. */
|
||||
public JNIWrapper() {}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,7 @@ public class LEDJNI extends JNIWrapper {
|
||||
* @see "HAL_GetRadioLEDState"
|
||||
*/
|
||||
public static native int getRadioLEDState();
|
||||
|
||||
/** Utility class. */
|
||||
private LEDJNI() {}
|
||||
}
|
||||
|
||||
@@ -101,4 +101,7 @@ public class NotifierJNI extends JNIWrapper {
|
||||
* @return the FPGA time the notifier returned
|
||||
*/
|
||||
public static native long waitForNotifierAlarm(int notifierHandle);
|
||||
|
||||
/** Utility class. */
|
||||
private NotifierJNI() {}
|
||||
}
|
||||
|
||||
@@ -44,4 +44,7 @@ public class PWMJNI extends DIOJNI {
|
||||
public static native void setAlwaysHighMode(int pwmPortHandle);
|
||||
|
||||
public static native void setPWMPeriodScale(int pwmPortHandle, int squelchMask);
|
||||
|
||||
/** Utility class. */
|
||||
private PWMJNI() {}
|
||||
}
|
||||
|
||||
@@ -185,4 +185,7 @@ public class PortsJNI extends JNIWrapper {
|
||||
* @see "HAL_GetNumREVPHChannels"
|
||||
*/
|
||||
public static native int getNumREVPHChannels();
|
||||
|
||||
/** Utility class. */
|
||||
private PortsJNI() {}
|
||||
}
|
||||
|
||||
@@ -282,4 +282,7 @@ public class PowerDistributionJNI extends JNIWrapper {
|
||||
* @see "HAL_GetPowerDistributionVersion"
|
||||
*/
|
||||
public static native PowerDistributionVersion getVersion(int handle);
|
||||
|
||||
/** Utility class. */
|
||||
private PowerDistributionJNI() {}
|
||||
}
|
||||
|
||||
@@ -167,4 +167,7 @@ public class PowerJNI extends JNIWrapper {
|
||||
* @return current CPU temperature in degrees Celsius
|
||||
*/
|
||||
public static native double getCPUTemp();
|
||||
|
||||
/** Utility class. */
|
||||
private PowerJNI() {}
|
||||
}
|
||||
|
||||
@@ -286,4 +286,7 @@ public class REVPHJNI extends JNIWrapper {
|
||||
* @see "HAL_GetREVPHVersion"
|
||||
*/
|
||||
public static native REVPHVersion getVersion(int handle);
|
||||
|
||||
/** Utility class. */
|
||||
private REVPHJNI() {}
|
||||
}
|
||||
|
||||
@@ -57,4 +57,7 @@ public class RelayJNI extends DIOJNI {
|
||||
* @see "HAL_GetRelay"
|
||||
*/
|
||||
public static native boolean getRelay(int relayPortHandle);
|
||||
|
||||
/** Utility class. */
|
||||
private RelayJNI() {}
|
||||
}
|
||||
|
||||
@@ -302,4 +302,7 @@ public class SPIJNI extends JNIWrapper {
|
||||
*/
|
||||
public static native void spiConfigureAutoStall(
|
||||
int port, int csToSclkTicks, int stallTicks, int pow2BytesPerRead);
|
||||
|
||||
/** Utility class. */
|
||||
private SPIJNI() {}
|
||||
}
|
||||
|
||||
@@ -205,4 +205,7 @@ public class SerialPortJNI extends JNIWrapper {
|
||||
* @see "HAL_CloseSerial"
|
||||
*/
|
||||
public static native void serialClose(int handle);
|
||||
|
||||
/** Utility class. */
|
||||
private SerialPortJNI() {}
|
||||
}
|
||||
|
||||
@@ -286,4 +286,7 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
* @param handle simulated value handle
|
||||
*/
|
||||
public static native void resetSimValue(int handle);
|
||||
|
||||
/** Utility class. */
|
||||
private SimDeviceJNI() {}
|
||||
}
|
||||
|
||||
@@ -37,4 +37,7 @@ public class ThreadsJNI extends JNIWrapper {
|
||||
* @see "HAL_SetCurrentThreadPriority"
|
||||
*/
|
||||
public static native boolean setCurrentThreadPriority(boolean realTime, int priority);
|
||||
|
||||
/** Utility class. */
|
||||
private ThreadsJNI() {}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@ import edu.wpi.first.hal.CANStreamMessage;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CANStreamOverflowException extends IOException {
|
||||
/** The messages. */
|
||||
private final CANStreamMessage[] m_messages;
|
||||
|
||||
/** The length of messages read. */
|
||||
private final int m_messagesRead;
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,16 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for accelerometer data. */
|
||||
public class AccelerometerDataJNI extends JNIWrapper {
|
||||
/**
|
||||
* Register a callback to be run when this accelerometer activates.
|
||||
*
|
||||
* @param index the index
|
||||
* @param callback the callback
|
||||
* @param initialNotify whether to run the callback with the initial state
|
||||
* @return the CallbackStore object associated with this callback
|
||||
*/
|
||||
public static native int registerActiveCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
@@ -53,4 +62,7 @@ public class AccelerometerDataJNI extends JNIWrapper {
|
||||
public static native void setZ(int index, double z);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private AccelerometerDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for addressable LED data. */
|
||||
public class AddressableLEDDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -54,4 +55,7 @@ public class AddressableLEDDataJNI extends JNIWrapper {
|
||||
public static native void resetData(int index);
|
||||
|
||||
public static native int findForChannel(int channel);
|
||||
|
||||
/** Utility class. */
|
||||
private AddressableLEDDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for analog gyro data. */
|
||||
public class AnalogGyroDataJNI extends JNIWrapper {
|
||||
public static native int registerAngleCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -35,4 +36,7 @@ public class AnalogGyroDataJNI extends JNIWrapper {
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private AnalogGyroDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for analog input data. */
|
||||
public class AnalogInDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -89,4 +90,7 @@ public class AnalogInDataJNI extends JNIWrapper {
|
||||
public static native void setAccumulatorDeadband(int index, int AccumulatorDeadband);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private AnalogInDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for analog output data. */
|
||||
public class AnalogOutDataJNI extends JNIWrapper {
|
||||
public static native int registerVoltageCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -26,4 +27,7 @@ public class AnalogOutDataJNI extends JNIWrapper {
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private AnalogOutDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for analog trigger data. */
|
||||
public class AnalogTriggerDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -37,4 +38,7 @@ public class AnalogTriggerDataJNI extends JNIWrapper {
|
||||
public static native void resetData(int index);
|
||||
|
||||
public static native int findForChannel(int channel);
|
||||
|
||||
/** Utility class. */
|
||||
private AnalogTriggerDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for CTRE PCM data. */
|
||||
public class CTREPCMDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -68,4 +69,7 @@ public class CTREPCMDataJNI extends JNIWrapper {
|
||||
int index, int channel, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private CTREPCMDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for DIO data. */
|
||||
public class DIODataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -53,4 +54,7 @@ public class DIODataJNI extends JNIWrapper {
|
||||
public static native void setFilterIndex(int index, int filterIndex);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private DIODataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for digital PWM data. */
|
||||
public class DigitalPWMDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -37,4 +38,7 @@ public class DigitalPWMDataJNI extends JNIWrapper {
|
||||
public static native void resetData(int index);
|
||||
|
||||
public static native int findForChannel(int channel);
|
||||
|
||||
/** Utility class. */
|
||||
private DigitalPWMDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for Driver Station data. */
|
||||
public class DriverStationDataJNI extends JNIWrapper {
|
||||
public static native int registerEnabledCallback(NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
@@ -134,4 +135,7 @@ public class DriverStationDataJNI extends JNIWrapper {
|
||||
public static native void setReplayNumber(int replayNumber);
|
||||
|
||||
public static native void resetData();
|
||||
|
||||
/** Utility class. */
|
||||
private DriverStationDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for duty cycle data. */
|
||||
public class DutyCycleDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -37,4 +38,7 @@ public class DutyCycleDataJNI extends JNIWrapper {
|
||||
public static native void resetData(int index);
|
||||
|
||||
public static native int findForChannel(int channel);
|
||||
|
||||
/** Utility class. */
|
||||
private DutyCycleDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for encoder data. */
|
||||
public class EncoderDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -99,4 +100,7 @@ public class EncoderDataJNI extends JNIWrapper {
|
||||
public static native void resetData(int index);
|
||||
|
||||
public static native int findForChannel(int channel);
|
||||
|
||||
/** Utility class. */
|
||||
private EncoderDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for I2C data. */
|
||||
public class I2CDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -25,4 +26,7 @@ public class I2CDataJNI extends JNIWrapper {
|
||||
public static native void cancelWriteCallback(int index, int uid);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private I2CDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,12 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for notifier data. */
|
||||
public class NotifierDataJNI extends JNIWrapper {
|
||||
public static native long getNextTimeout();
|
||||
|
||||
public static native int getNumNotifiers();
|
||||
|
||||
/** Utility class. */
|
||||
private NotifierDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for PWM data. */
|
||||
public class PWMDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -62,4 +63,7 @@ public class PWMDataJNI extends JNIWrapper {
|
||||
public static native void setZeroLatch(int index, boolean zeroLatch);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private PWMDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for power distribution data. */
|
||||
public class PowerDistributionDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -44,4 +45,7 @@ public class PowerDistributionDataJNI extends JNIWrapper {
|
||||
public static native void setCurrent(int index, int channel, double current);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private PowerDistributionDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for REV PH data. */
|
||||
public class REVPHDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -68,4 +69,7 @@ public class REVPHDataJNI extends JNIWrapper {
|
||||
int index, int channel, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private REVPHDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for relay data. */
|
||||
public class RelayDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedForwardCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -44,4 +45,7 @@ public class RelayDataJNI extends JNIWrapper {
|
||||
public static native void setReverse(int index, boolean reverse);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private RelayDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for roboRIO data. */
|
||||
public class RoboRioDataJNI extends JNIWrapper {
|
||||
public static native int registerFPGAButtonCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
@@ -186,4 +187,7 @@ public class RoboRioDataJNI extends JNIWrapper {
|
||||
public static native void setRadioLEDState(int state);
|
||||
|
||||
public static native void resetData();
|
||||
|
||||
/** Utility class. */
|
||||
private RoboRioDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for SPI accelerometer data. */
|
||||
public class SPIAccelerometerDataJNI extends JNIWrapper {
|
||||
public static native int registerActiveCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -53,4 +54,7 @@ public class SPIAccelerometerDataJNI extends JNIWrapper {
|
||||
public static native void setZ(int index, double z);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private SPIAccelerometerDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for SPI data. */
|
||||
public class SPIDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
@@ -30,4 +31,7 @@ public class SPIDataJNI extends JNIWrapper {
|
||||
public static native void cancelReadAutoReceiveBufferCallback(int index, int uid);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
/** Utility class. */
|
||||
private SPIDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.HALValue;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for sim device data. */
|
||||
public class SimDeviceDataJNI extends JNIWrapper {
|
||||
public static native void setSimDeviceEnabled(String prefix, boolean enabled);
|
||||
|
||||
@@ -106,4 +107,7 @@ public class SimDeviceDataJNI extends JNIWrapper {
|
||||
public static native double[] getSimValueEnumDoubleValues(int handle);
|
||||
|
||||
public static native void resetSimDeviceData();
|
||||
|
||||
/** Utility class. */
|
||||
private SimDeviceDataJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.simulation;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
/** JNI for simulator. */
|
||||
public class SimulatorJNI extends JNIWrapper {
|
||||
public static native void setRuntimeType(int type);
|
||||
|
||||
@@ -28,4 +29,7 @@ public class SimulatorJNI extends JNIWrapper {
|
||||
public static native void stepTimingAsync(long delta);
|
||||
|
||||
public static native void resetHandles();
|
||||
|
||||
/** Utility class. */
|
||||
private SimulatorJNI() {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.hal.util;
|
||||
|
||||
/** Exception for bad status codes from the chip object. */
|
||||
public final class UncleanStatusException extends IllegalStateException {
|
||||
/** The status code from the chip object. */
|
||||
private final int m_statusCode;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,16 +18,30 @@ public final class NetworkTablesJNI {
|
||||
static boolean libraryLoaded = false;
|
||||
static RuntimeLoader<NetworkTablesJNI> loader = null;
|
||||
|
||||
/** Sets whether JNI should be loaded in the static block. */
|
||||
public static class Helper {
|
||||
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
|
||||
|
||||
/**
|
||||
* Returns true if the JNI should be loaded in the static block.
|
||||
*
|
||||
* @return True if the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static boolean getExtractOnStaticLoad() {
|
||||
return extractOnStaticLoad.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the JNI should be loaded in the static block.
|
||||
*
|
||||
* @param load Whether the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static void setExtractOnStaticLoad(boolean load) {
|
||||
extractOnStaticLoad.set(load);
|
||||
}
|
||||
|
||||
/** Utility class. */
|
||||
private Helper() {}
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -358,5 +372,8 @@ public final class NetworkTablesJNI {
|
||||
public static native void stopConnectionDataLog(int logger);
|
||||
|
||||
public static native int addLogger(int poller, int minLevel, int maxLevel);
|
||||
|
||||
/** Utility class. */
|
||||
private NetworkTablesJNI() {}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,16 +18,30 @@ public final class NetworkTablesJNI {
|
||||
static boolean libraryLoaded = false;
|
||||
static RuntimeLoader<NetworkTablesJNI> loader = null;
|
||||
|
||||
/** Sets whether JNI should be loaded in the static block. */
|
||||
public static class Helper {
|
||||
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
|
||||
|
||||
/**
|
||||
* Returns true if the JNI should be loaded in the static block.
|
||||
*
|
||||
* @return True if the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static boolean getExtractOnStaticLoad() {
|
||||
return extractOnStaticLoad.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the JNI should be loaded in the static block.
|
||||
*
|
||||
* @param load Whether the JNI should be loaded in the static block.
|
||||
*/
|
||||
public static void setExtractOnStaticLoad(boolean load) {
|
||||
extractOnStaticLoad.set(load);
|
||||
}
|
||||
|
||||
/** Utility class. */
|
||||
private Helper() {}
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -494,4 +508,7 @@ public final class NetworkTablesJNI {
|
||||
public static native void stopConnectionDataLog(int logger);
|
||||
|
||||
public static native int addLogger(int poller, int minLevel, int maxLevel);
|
||||
|
||||
/** Utility class. */
|
||||
private NetworkTablesJNI() {}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
|
||||
package edu.wpi.first.networktables;
|
||||
|
||||
/** NetworkTables timestamped object. */
|
||||
/**
|
||||
* NetworkTables timestamped object.
|
||||
*
|
||||
* @param <T> Value type.
|
||||
*/
|
||||
public final class TimestampedObject<T> {
|
||||
/**
|
||||
* Create a timestamped value.
|
||||
|
||||
@@ -138,6 +138,10 @@
|
||||
<Bug pattern="URF_UNREAD_FIELD" />
|
||||
<Class name="edu.wpi.first.wpilibj.ADIS16470_IMU" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="URF_UNREAD_FIELD" />
|
||||
<Class name="edu.wpi.first.wpilibj.AnalogTrigger" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" />
|
||||
</Match>
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Set;
|
||||
* subsystems its components require.
|
||||
*/
|
||||
public abstract class WrapperCommand extends Command {
|
||||
/** Command being wrapped. */
|
||||
protected final Command m_command;
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,6 +69,7 @@ class WrapperCommand : public CommandHelper<Command, WrapperCommand> {
|
||||
wpi::SmallSet<Subsystem*, 4> GetRequirements() const override;
|
||||
|
||||
protected:
|
||||
/// Command being wrapped.
|
||||
std::unique_ptr<Command> m_command;
|
||||
};
|
||||
} // namespace frc2
|
||||
|
||||
@@ -679,8 +679,13 @@ double ADIS16448_IMU::CompFilterProcess(double compAngle, double accelAngle,
|
||||
return compAngle;
|
||||
}
|
||||
|
||||
int ADIS16448_IMU::ConfigDecRate(uint16_t DecimationSetting) {
|
||||
uint16_t writeValue = DecimationSetting;
|
||||
int ADIS16448_IMU::ConfigDecRate(uint16_t decimationRate) {
|
||||
// Switches the active SPI port to standard SPI mode, writes a new value to
|
||||
// the DECIMATE register in the IMU, and re-enables auto SPI.
|
||||
//
|
||||
// This function enters standard SPI mode, writes a new DECIMATE setting to
|
||||
// the IMU, adjusts the sample scale factor, and re-enters auto SPI mode.
|
||||
uint16_t writeValue = decimationRate;
|
||||
uint16_t readbackValue;
|
||||
if (!SwitchToStandardSPI()) {
|
||||
REPORT_ERROR("Failed to configure/reconfigure standard SPI.");
|
||||
@@ -688,14 +693,14 @@ int ADIS16448_IMU::ConfigDecRate(uint16_t DecimationSetting) {
|
||||
}
|
||||
|
||||
/* Check max */
|
||||
if (DecimationSetting > 9) {
|
||||
if (decimationRate > 9) {
|
||||
REPORT_ERROR(
|
||||
"Attempted to write an invalid decimation value. Capping at 9");
|
||||
DecimationSetting = 9;
|
||||
decimationRate = 9;
|
||||
}
|
||||
|
||||
/* Shift decimation setting to correct position and select internal sync */
|
||||
writeValue = (DecimationSetting << 8) | 0x1;
|
||||
writeValue = (decimationRate << 8) | 0x1;
|
||||
|
||||
/* Apply to IMU */
|
||||
WriteRegister(SMPL_PRD, writeValue);
|
||||
|
||||
@@ -348,31 +348,22 @@ int ADIS16470_IMU::ConfigCalTime(CalibrationTime new_cal_time) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Switches the active SPI port to standard SPI mode, writes a new value
|
||||
*to the DECIMATE register in the IMU, and re-enables auto SPI.
|
||||
*
|
||||
* @param reg Decimation value to be set.
|
||||
*
|
||||
* @return An int indicating the success or failure of writing the new DECIMATE
|
||||
*setting and returning to auto SPI mode. 0 = Success, 1 = No Change, 2 =
|
||||
*Failure
|
||||
*
|
||||
* This function enters standard SPI mode, writes a new DECIMATE setting to the
|
||||
*IMU, adjusts the sample scale factor, and re-enters auto SPI mode.
|
||||
**/
|
||||
int ADIS16470_IMU::ConfigDecRate(uint16_t reg) {
|
||||
uint16_t m_reg = reg;
|
||||
int ADIS16470_IMU::ConfigDecRate(uint16_t decimationRate) {
|
||||
// Switches the active SPI port to standard SPI mode, writes a new value to
|
||||
// the DECIMATE register in the IMU, and re-enables auto SPI.
|
||||
//
|
||||
// This function enters standard SPI mode, writes a new DECIMATE setting to
|
||||
// the IMU, adjusts the sample scale factor, and re-enters auto SPI mode.
|
||||
if (!SwitchToStandardSPI()) {
|
||||
REPORT_ERROR("Failed to configure/reconfigure standard SPI.");
|
||||
return 2;
|
||||
}
|
||||
if (m_reg > 1999) {
|
||||
if (decimationRate > 1999) {
|
||||
REPORT_ERROR("Attempted to write an invalid decimation value.");
|
||||
m_reg = 1999;
|
||||
decimationRate = 1999;
|
||||
}
|
||||
m_scaled_sample_rate = (((m_reg + 1.0) / 2000.0) * 1000000.0);
|
||||
WriteRegister(DEC_RATE, m_reg);
|
||||
m_scaled_sample_rate = (((decimationRate + 1.0) / 2000.0) * 1000000.0);
|
||||
WriteRegister(DEC_RATE, decimationRate);
|
||||
if (!SwitchToAutoSPI()) {
|
||||
REPORT_ERROR("Failed to configure/reconfigure auto SPI.");
|
||||
return 2;
|
||||
|
||||
@@ -56,23 +56,47 @@ namespace frc {
|
||||
class ADIS16448_IMU : public wpi::Sendable,
|
||||
public wpi::SendableHelper<ADIS16448_IMU> {
|
||||
public:
|
||||
/* ADIS16448 Calibration Time Enum Class */
|
||||
/**
|
||||
* ADIS16448 calibration times.
|
||||
*/
|
||||
enum class CalibrationTime {
|
||||
/// 32 ms calibration time.
|
||||
_32ms = 0,
|
||||
/// 64 ms calibration time.
|
||||
_64ms = 1,
|
||||
/// 128 ms calibration time.
|
||||
_128ms = 2,
|
||||
/// 256 ms calibration time.
|
||||
_256ms = 3,
|
||||
/// 512 ms calibration time.
|
||||
_512ms = 4,
|
||||
/// 1 s calibration time.
|
||||
_1s = 5,
|
||||
/// 2 s calibration time.
|
||||
_2s = 6,
|
||||
/// 4 s calibration time.
|
||||
_4s = 7,
|
||||
/// 8 s calibration time.
|
||||
_8s = 8,
|
||||
/// 16 s calibration time.
|
||||
_16s = 9,
|
||||
/// 32 s calibration time.
|
||||
_32s = 10,
|
||||
/// 64 s calibration time.
|
||||
_64s = 11
|
||||
};
|
||||
|
||||
enum IMUAxis { kX, kY, kZ };
|
||||
/**
|
||||
* IMU axes.
|
||||
*/
|
||||
enum IMUAxis {
|
||||
/// The IMU's X axis.
|
||||
kX,
|
||||
/// The IMU's Y axis.
|
||||
kY,
|
||||
/// The IMU's Z axis.
|
||||
kZ
|
||||
};
|
||||
|
||||
/**
|
||||
* IMU constructor on onboard MXP CS0, Z-up orientation, and complementary
|
||||
@@ -183,31 +207,71 @@ class ADIS16448_IMU : public wpi::Sendable,
|
||||
*/
|
||||
units::meters_per_second_squared_t GetAccelZ() const;
|
||||
|
||||
/**
|
||||
* Returns the complementary angle around the X axis computed from
|
||||
* accelerometer and gyro rate measurements.
|
||||
*/
|
||||
units::degree_t GetXComplementaryAngle() const;
|
||||
|
||||
/**
|
||||
* Returns the complementary angle around the Y axis computed from
|
||||
* accelerometer and gyro rate measurements.
|
||||
*/
|
||||
units::degree_t GetYComplementaryAngle() const;
|
||||
|
||||
/**
|
||||
* Returns the X-axis filtered acceleration angle.
|
||||
*/
|
||||
units::degree_t GetXFilteredAccelAngle() const;
|
||||
|
||||
/**
|
||||
* Returns the Y-axis filtered acceleration angle.
|
||||
*/
|
||||
units::degree_t GetYFilteredAccelAngle() const;
|
||||
|
||||
/**
|
||||
* Returns the magnetic field strength in the X axis.
|
||||
*/
|
||||
units::tesla_t GetMagneticFieldX() const;
|
||||
|
||||
/**
|
||||
* Returns the magnetic field strength in the Y axis.
|
||||
*/
|
||||
units::tesla_t GetMagneticFieldY() const;
|
||||
|
||||
/**
|
||||
* Returns the magnetic field strength in the Z axis.
|
||||
*/
|
||||
units::tesla_t GetMagneticFieldZ() const;
|
||||
|
||||
/**
|
||||
* Returns the barometric pressure.
|
||||
*/
|
||||
units::pounds_per_square_inch_t GetBarometricPressure() const;
|
||||
|
||||
/**
|
||||
* Returns the temperature.
|
||||
*/
|
||||
units::celsius_t GetTemperature() const;
|
||||
|
||||
IMUAxis GetYawAxis() const;
|
||||
|
||||
int SetYawAxis(IMUAxis yaw_axis);
|
||||
|
||||
/**
|
||||
* Checks the connection status of the IMU.
|
||||
*
|
||||
* @return True if the IMU is connected, false otherwise.
|
||||
*/
|
||||
bool IsConnected() const;
|
||||
|
||||
int ConfigDecRate(uint16_t DecimationRate);
|
||||
/**
|
||||
* Configures the decimation rate of the IMU.
|
||||
*
|
||||
* @param decimationRate The new decimation value.
|
||||
* @return 0 if success, 1 if no change, 2 if error.
|
||||
*/
|
||||
int ConfigDecRate(uint16_t decimationRate);
|
||||
|
||||
/**
|
||||
* Get the SPI port number.
|
||||
|
||||
@@ -53,27 +53,93 @@ namespace frc {
|
||||
class ADIS16470_IMU : public wpi::Sendable,
|
||||
public wpi::SendableHelper<ADIS16470_IMU> {
|
||||
public:
|
||||
/* ADIS16470 Calibration Time Enum Class */
|
||||
/**
|
||||
* ADIS16470 calibration times.
|
||||
*/
|
||||
enum class CalibrationTime {
|
||||
/// 32 ms calibration time.
|
||||
_32ms = 0,
|
||||
/// 64 ms calibration time.
|
||||
_64ms = 1,
|
||||
/// 128 ms calibration time.
|
||||
_128ms = 2,
|
||||
/// 256 ms calibration time.
|
||||
_256ms = 3,
|
||||
/// 512 ms calibration time.
|
||||
_512ms = 4,
|
||||
/// 1 s calibration time.
|
||||
_1s = 5,
|
||||
/// 2 s calibration time.
|
||||
_2s = 6,
|
||||
/// 4 s calibration time.
|
||||
_4s = 7,
|
||||
/// 8 s calibration time.
|
||||
_8s = 8,
|
||||
/// 16 s calibration time.
|
||||
_16s = 9,
|
||||
/// 32 s calibration time.
|
||||
_32s = 10,
|
||||
/// 64 s calibration time.
|
||||
_64s = 11
|
||||
};
|
||||
|
||||
enum IMUAxis { kX, kY, kZ, kYaw, kPitch, kRoll };
|
||||
/**
|
||||
* IMU axes.
|
||||
*
|
||||
* kX, kY, and kZ refer to the IMU's X, Y, and Z axes respectively. kYaw,
|
||||
* kPitch, and kRoll are configured by the user to refer to an X, Y, or Z
|
||||
* axis.
|
||||
*/
|
||||
enum IMUAxis {
|
||||
/// The IMU's X axis.
|
||||
kX,
|
||||
/// The IMU's Y axis.
|
||||
kY,
|
||||
/// The IMU's Z axis.
|
||||
kZ,
|
||||
/// The user-configured yaw axis.
|
||||
kYaw,
|
||||
/// The user-configured pitch axis.
|
||||
kPitch,
|
||||
/// The user-configured roll axis.
|
||||
kRoll
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new ADIS16740 IMU object.
|
||||
*
|
||||
* The default setup is the onboard SPI port with a calibration time of 4
|
||||
* seconds. Yaw, pitch, and roll are kZ, kX, and kY respectively.
|
||||
*/
|
||||
ADIS16470_IMU();
|
||||
|
||||
/**
|
||||
* Creates a new ADIS16740 IMU object.
|
||||
*
|
||||
* The default setup is the onboard SPI port with a calibration time of 4
|
||||
* seconds.
|
||||
*
|
||||
* <b><i>Input axes limited to kX, kY and kZ. Specifying kYaw, kPitch,or kRoll
|
||||
* will result in an error.</i></b>
|
||||
*
|
||||
* @param yaw_axis The axis that measures the yaw
|
||||
* @param pitch_axis The axis that measures the pitch
|
||||
* @param roll_axis The axis that measures the roll
|
||||
*/
|
||||
ADIS16470_IMU(IMUAxis yaw_axis, IMUAxis pitch_axis, IMUAxis roll_axis);
|
||||
|
||||
/**
|
||||
* Creates a new ADIS16740 IMU object.
|
||||
*
|
||||
* <b><i>Input axes limited to kX, kY and kZ. Specifying kYaw, kPitch, or
|
||||
* kRoll will result in an error.</i></b>
|
||||
*
|
||||
* @param yaw_axis The axis that measures the yaw
|
||||
* @param pitch_axis The axis that measures the pitch
|
||||
* @param roll_axis The axis that measures the roll
|
||||
* @param port The SPI Port the gyro is plugged into
|
||||
* @param cal_time Calibration time
|
||||
*/
|
||||
explicit ADIS16470_IMU(IMUAxis yaw_axis, IMUAxis pitch_axis,
|
||||
IMUAxis roll_axis, frc::SPI::Port port,
|
||||
CalibrationTime cal_time);
|
||||
@@ -84,9 +150,12 @@ class ADIS16470_IMU : public wpi::Sendable,
|
||||
ADIS16470_IMU& operator=(ADIS16470_IMU&&) = default;
|
||||
|
||||
/**
|
||||
* @brief Configures the decimation rate of the IMU.
|
||||
* Configures the decimation rate of the IMU.
|
||||
*
|
||||
* @param decimationRate The new decimation value.
|
||||
* @return 0 if success, 1 if no change, 2 if error.
|
||||
*/
|
||||
int ConfigDecRate(uint16_t reg);
|
||||
int ConfigDecRate(uint16_t decimationRate);
|
||||
|
||||
/**
|
||||
* @brief Switches the active SPI port to standard SPI mode, writes the
|
||||
@@ -101,8 +170,11 @@ class ADIS16470_IMU : public wpi::Sendable,
|
||||
int ConfigCalTime(CalibrationTime new_cal_time);
|
||||
|
||||
/**
|
||||
* @brief Resets the gyro accumulations to a heading of zero. This can be used
|
||||
* if the "zero" orientation of the sensor needs to be changed in runtime.
|
||||
* Reset the gyro.
|
||||
*
|
||||
* Resets the gyro accumulations to a heading of zero. This can be used if
|
||||
* there is significant drift in the gyro and it needs to be recalibrated
|
||||
* after running.
|
||||
*/
|
||||
void Reset();
|
||||
|
||||
@@ -144,14 +216,18 @@ class ADIS16470_IMU : public wpi::Sendable,
|
||||
void SetGyroAngleZ(units::degree_t angle);
|
||||
|
||||
/**
|
||||
* @param axis The IMUAxis whose angle to return
|
||||
* @return The axis angle (CCW positive)
|
||||
* Returns the axis angle (CCW positive).
|
||||
*
|
||||
* @param axis The IMUAxis whose angle to return.
|
||||
* @return The axis angle (CCW positive).
|
||||
*/
|
||||
units::degree_t GetAngle(IMUAxis axis) const;
|
||||
|
||||
/**
|
||||
* @param axis The IMUAxis whose rate to return
|
||||
* @return Axis angular rate (CCW positive)
|
||||
* Returns the axis angular rate (CCW positive).
|
||||
*
|
||||
* @param axis The IMUAxis whose rate to return.
|
||||
* @return Axis angular rate (CCW positive).
|
||||
*/
|
||||
units::degrees_per_second_t GetRate(IMUAxis axis) const;
|
||||
|
||||
|
||||
@@ -26,14 +26,42 @@ namespace frc {
|
||||
class ADXL345_I2C : public nt::NTSendable,
|
||||
public wpi::SendableHelper<ADXL345_I2C> {
|
||||
public:
|
||||
enum Range { kRange_2G = 0, kRange_4G = 1, kRange_8G = 2, kRange_16G = 3 };
|
||||
/**
|
||||
* Accelerometer range.
|
||||
*/
|
||||
enum Range {
|
||||
/// 2 Gs max.
|
||||
kRange_2G = 0,
|
||||
/// 4 Gs max.
|
||||
kRange_4G = 1,
|
||||
/// 8 Gs max.
|
||||
kRange_8G = 2,
|
||||
/// 16 Gs max.
|
||||
kRange_16G = 3
|
||||
};
|
||||
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
/**
|
||||
* Accelerometer axes.
|
||||
*/
|
||||
enum Axes {
|
||||
/// X axis.
|
||||
kAxis_X = 0x00,
|
||||
/// Y axis.
|
||||
kAxis_Y = 0x02,
|
||||
/// Z axis.
|
||||
kAxis_Z = 0x04
|
||||
};
|
||||
|
||||
/**
|
||||
* Container type for accelerations from all axes.
|
||||
*/
|
||||
struct AllAxes {
|
||||
double XAxis;
|
||||
double YAxis;
|
||||
double ZAxis;
|
||||
/// Acceleration along the X axis in g-forces.
|
||||
double XAxis = 0.0;
|
||||
/// Acceleration along the Y axis in g-forces.
|
||||
double YAxis = 0.0;
|
||||
/// Acceleration along the Z axis in g-forces.
|
||||
double ZAxis = 0.0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,14 +21,42 @@ namespace frc {
|
||||
class ADXL345_SPI : public nt::NTSendable,
|
||||
public wpi::SendableHelper<ADXL345_SPI> {
|
||||
public:
|
||||
enum Range { kRange_2G = 0, kRange_4G = 1, kRange_8G = 2, kRange_16G = 3 };
|
||||
/**
|
||||
* Accelerometer range.
|
||||
*/
|
||||
enum Range {
|
||||
/// 2 Gs max.
|
||||
kRange_2G = 0,
|
||||
/// 4 Gs max.
|
||||
kRange_4G = 1,
|
||||
/// 8 Gs max.
|
||||
kRange_8G = 2,
|
||||
/// 16 Gs max.
|
||||
kRange_16G = 3
|
||||
};
|
||||
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
/**
|
||||
* Accelerometer axes.
|
||||
*/
|
||||
enum Axes {
|
||||
/// X axis.
|
||||
kAxis_X = 0x00,
|
||||
/// Y axis.
|
||||
kAxis_Y = 0x02,
|
||||
/// Z axis.
|
||||
kAxis_Z = 0x04
|
||||
};
|
||||
|
||||
/**
|
||||
* Container type for accelerations from all axes.
|
||||
*/
|
||||
struct AllAxes {
|
||||
double XAxis;
|
||||
double YAxis;
|
||||
double ZAxis;
|
||||
/// Acceleration along the X axis in g-forces.
|
||||
double XAxis = 0.0;
|
||||
/// Acceleration along the Y axis in g-forces.
|
||||
double YAxis = 0.0;
|
||||
/// Acceleration along the Z axis in g-forces.
|
||||
double ZAxis = 0.0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,13 +19,40 @@ namespace frc {
|
||||
*/
|
||||
class ADXL362 : public nt::NTSendable, public wpi::SendableHelper<ADXL362> {
|
||||
public:
|
||||
enum Range { kRange_2G = 0, kRange_4G = 1, kRange_8G = 2 };
|
||||
/**
|
||||
* Accelerometer range.
|
||||
*/
|
||||
enum Range {
|
||||
/// 2 Gs max.
|
||||
kRange_2G = 0,
|
||||
/// 4 Gs max.
|
||||
kRange_4G = 1,
|
||||
/// 8 Gs max.
|
||||
kRange_8G = 2
|
||||
};
|
||||
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
/**
|
||||
* Accelerometer axes.
|
||||
*/
|
||||
enum Axes {
|
||||
/// X axis.
|
||||
kAxis_X = 0x00,
|
||||
/// Y axis.
|
||||
kAxis_Y = 0x02,
|
||||
/// Z axis.
|
||||
kAxis_Z = 0x04
|
||||
};
|
||||
|
||||
/**
|
||||
* Container type for accelerations from all axes.
|
||||
*/
|
||||
struct AllAxes {
|
||||
double XAxis;
|
||||
double YAxis;
|
||||
double ZAxis;
|
||||
/// Acceleration along the X axis in g-forces.
|
||||
double XAxis = 0.0;
|
||||
/// Acceleration along the Y axis in g-forces.
|
||||
double YAxis = 0.0;
|
||||
/// Acceleration along the Z axis in g-forces.
|
||||
double ZAxis = 0.0;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
@@ -33,14 +33,14 @@ class AnalogOutput : public wpi::Sendable,
|
||||
/**
|
||||
* Set the value of the analog output.
|
||||
*
|
||||
* @param voltage The output value in Volts, from 0.0 to +5.0
|
||||
* @param voltage The output value in Volts, from 0.0 to +5.0.
|
||||
*/
|
||||
void SetVoltage(double voltage);
|
||||
|
||||
/**
|
||||
* Get the voltage of the analog output
|
||||
* Get the voltage of the analog output.
|
||||
*
|
||||
* @return The value in Volts, from 0.0 to +5.0
|
||||
* @return The value in Volts, from 0.0 to +5.0.
|
||||
*/
|
||||
double GetVoltage() const;
|
||||
|
||||
|
||||
@@ -6,10 +6,15 @@
|
||||
|
||||
namespace frc {
|
||||
|
||||
/** Defines the state in which the AnalogTrigger triggers. */
|
||||
enum class AnalogTriggerType {
|
||||
/// In window.
|
||||
kInWindow = 0,
|
||||
/// State.
|
||||
kState = 1,
|
||||
/// Rising Pulse.
|
||||
kRisingPulse = 2,
|
||||
/// Falling pulse.
|
||||
kFallingPulse = 3
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,17 @@ namespace frc {
|
||||
class BuiltInAccelerometer : public wpi::Sendable,
|
||||
public wpi::SendableHelper<BuiltInAccelerometer> {
|
||||
public:
|
||||
enum Range { kRange_2G = 0, kRange_4G = 1, kRange_8G = 2 };
|
||||
/**
|
||||
* Accelerometer range.
|
||||
*/
|
||||
enum Range {
|
||||
/// 2 Gs max.
|
||||
kRange_2G = 0,
|
||||
/// 4 Gs max.
|
||||
kRange_4G = 1,
|
||||
/// 8 Gs max.
|
||||
kRange_8G = 2
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
||||
@@ -426,25 +426,43 @@ class XboxController : public GenericHID {
|
||||
*/
|
||||
BooleanEvent RightTrigger(EventLoop* loop) const;
|
||||
|
||||
/** Represents a digital button on an XboxController. */
|
||||
struct Button {
|
||||
/// Left bumper.
|
||||
static constexpr int kLeftBumper = 5;
|
||||
/// Right bumper.
|
||||
static constexpr int kRightBumper = 6;
|
||||
/// Left stick.
|
||||
static constexpr int kLeftStick = 9;
|
||||
/// Right stick.
|
||||
static constexpr int kRightStick = 10;
|
||||
/// A.
|
||||
static constexpr int kA = 1;
|
||||
/// B.
|
||||
static constexpr int kB = 2;
|
||||
/// X.
|
||||
static constexpr int kX = 3;
|
||||
/// Y.
|
||||
static constexpr int kY = 4;
|
||||
/// Back.
|
||||
static constexpr int kBack = 7;
|
||||
/// Start.
|
||||
static constexpr int kStart = 8;
|
||||
};
|
||||
|
||||
/** Represents an axis on an XboxController. */
|
||||
struct Axis {
|
||||
/// Left X.
|
||||
static constexpr int kLeftX = 0;
|
||||
/// Right X.
|
||||
static constexpr int kRightX = 4;
|
||||
/// Left Y.
|
||||
static constexpr int kLeftY = 1;
|
||||
/// Right Y.
|
||||
static constexpr int kRightY = 5;
|
||||
/// Left trigger.
|
||||
static constexpr int kLeftTrigger = 2;
|
||||
/// Right trigger.
|
||||
static constexpr int kRightTrigger = 3;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -20,7 +20,27 @@ class [[deprecated(
|
||||
Accelerometer(Accelerometer&&) = default;
|
||||
Accelerometer& operator=(Accelerometer&&) = default;
|
||||
|
||||
enum Range { kRange_2G = 0, kRange_4G = 1, kRange_8G = 2, kRange_16G = 3 };
|
||||
/**
|
||||
* Accelerometer range.
|
||||
*/
|
||||
enum Range {
|
||||
/**
|
||||
* 2 Gs max.
|
||||
*/
|
||||
kRange_2G = 0,
|
||||
/**
|
||||
* 4 Gs max.
|
||||
*/
|
||||
kRange_4G = 1,
|
||||
/**
|
||||
* 8 Gs max.
|
||||
*/
|
||||
kRange_8G = 2,
|
||||
/**
|
||||
* 16 Gs max.
|
||||
*/
|
||||
kRange_16G = 3
|
||||
};
|
||||
|
||||
/**
|
||||
* Common interface for setting the measuring range of an accelerometer.
|
||||
|
||||
@@ -14,7 +14,7 @@ class ADXL345_I2C;
|
||||
namespace sim {
|
||||
|
||||
/**
|
||||
* Class to control a simulated ADXRS450 gyroscope.
|
||||
* Class to control a simulated ADXL345.
|
||||
*/
|
||||
class ADXL345Sim {
|
||||
public:
|
||||
|
||||
@@ -13,7 +13,7 @@ class ADXL362;
|
||||
namespace sim {
|
||||
|
||||
/**
|
||||
* Class to control a simulated ADXRS450 gyroscope.
|
||||
* Class to control a simulated ADXL362.
|
||||
*/
|
||||
class ADXL362Sim {
|
||||
public:
|
||||
|
||||
@@ -23,9 +23,9 @@ namespace frc::sim {
|
||||
* voltage). Call the Update() method to update the simulation. Set simulated
|
||||
* sensor readings with the simulated positions in the GetOutput() method.
|
||||
*
|
||||
* @tparam States The number of states of the system.
|
||||
* @tparam Inputs The number of inputs to the system.
|
||||
* @tparam Outputs The number of outputs of the system.
|
||||
* @tparam States Number of states of the system.
|
||||
* @tparam Inputs Number of inputs to the system.
|
||||
* @tparam Outputs Number of outputs of the system.
|
||||
*/
|
||||
template <int States, int Inputs, int Outputs>
|
||||
class LinearSystemSim {
|
||||
|
||||
@@ -94,18 +94,31 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
private static final int PROD_ID = 0x56; // Product identifier
|
||||
private static final int SERIAL_NUM = 0x58; // Lot-specific serial number
|
||||
|
||||
/** ADIS16448 calibration times. */
|
||||
public enum CalibrationTime {
|
||||
/** 32 ms calibration time */
|
||||
_32ms(0),
|
||||
/** 64 ms calibration time */
|
||||
_64ms(1),
|
||||
/** 128 ms calibration time */
|
||||
_128ms(2),
|
||||
/** 256 ms calibration time */
|
||||
_256ms(3),
|
||||
/** 512 ms calibration time */
|
||||
_512ms(4),
|
||||
/** 1 s calibration time */
|
||||
_1s(5),
|
||||
/** 2 s calibration time */
|
||||
_2s(6),
|
||||
/** 4 s calibration time */
|
||||
_4s(7),
|
||||
/** 8 s calibration time */
|
||||
_8s(8),
|
||||
/** 16 s calibration time */
|
||||
_16s(9),
|
||||
/** 32 s calibration time */
|
||||
_32s(10),
|
||||
/** 64 s calibration time */
|
||||
_64s(11);
|
||||
|
||||
private final int value;
|
||||
@@ -115,9 +128,13 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
/** IMU axes. */
|
||||
public enum IMUAxis {
|
||||
/** The IMU's X axis. */
|
||||
kX,
|
||||
/** The IMU's Y axis. */
|
||||
kY,
|
||||
/** The IMU's Z axis. */
|
||||
kZ
|
||||
}
|
||||
|
||||
@@ -248,11 +265,14 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
/** Creates a new ADIS16448_IMU object. */
|
||||
public ADIS16448_IMU() {
|
||||
this(IMUAxis.kZ, SPI.Port.kMXP, CalibrationTime._512ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ADIS16448_IMU object.
|
||||
*
|
||||
* @param yaw_axis The axis that measures the yaw
|
||||
* @param port The SPI Port the gyro is plugged into
|
||||
* @param cal_time Calibration time
|
||||
@@ -332,6 +352,11 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
m_connected = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the connection status of the IMU.
|
||||
*
|
||||
* @return True if the IMU is connected, false otherwise.
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
if (m_simConnected != null) {
|
||||
return m_simConnected.get();
|
||||
@@ -339,7 +364,6 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
/** */
|
||||
private static int toUShort(byte[] buf) {
|
||||
return (((buf[0] & 0xFF) << 8) + ((buf[1] & 0xFF) << 0));
|
||||
}
|
||||
@@ -348,7 +372,7 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
return (buf[0] & 0xFF);
|
||||
}
|
||||
|
||||
public static int toUShort(int... buf) {
|
||||
private static int toUShort(int... buf) {
|
||||
return (((buf[0] & 0xFF) << 8) + (buf[1] & 0xFF));
|
||||
}
|
||||
|
||||
@@ -481,7 +505,18 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int configDecRate(int m_decRate) {
|
||||
/**
|
||||
* Configures the decimation rate of the IMU.
|
||||
*
|
||||
* @param decimationRate The new decimation value.
|
||||
* @return 0 if success, 1 if no change, 2 if error.
|
||||
*/
|
||||
public int configDecRate(int decimationRate) {
|
||||
// Switches the active SPI port to standard SPI mode, writes a new value to
|
||||
// the DECIMATE register in the IMU, and re-enables auto SPI.
|
||||
//
|
||||
// This function enters standard SPI mode, writes a new DECIMATE setting to
|
||||
// the IMU, adjusts the sample scale factor, and re-enters auto SPI mode.
|
||||
int writeValue;
|
||||
int readbackValue;
|
||||
if (!switchToStandardSPI()) {
|
||||
@@ -490,19 +525,19 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/* Check max */
|
||||
if (m_decRate > 9) {
|
||||
if (decimationRate > 9) {
|
||||
DriverStation.reportError(
|
||||
"Attempted to write an invalid decimation value. Capping at 9", false);
|
||||
m_decRate = 9;
|
||||
decimationRate = 9;
|
||||
}
|
||||
if (m_decRate < 0) {
|
||||
if (decimationRate < 0) {
|
||||
DriverStation.reportError(
|
||||
"Attempted to write an invalid decimation value. Capping at 0", false);
|
||||
m_decRate = 0;
|
||||
decimationRate = 0;
|
||||
}
|
||||
|
||||
/* Shift decimation setting to correct position and select internal sync */
|
||||
writeValue = (m_decRate << 8) | 0x1;
|
||||
writeValue = (decimationRate << 8) | 0x1;
|
||||
|
||||
/* Apply to IMU */
|
||||
writeRegister(SMPL_PRD, writeValue);
|
||||
@@ -624,6 +659,12 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
m_spi.write(buf, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the gyro.
|
||||
*
|
||||
* <p>Resets the gyro accumulations to a heading of zero. This can be used if there is significant
|
||||
* drift in the gyro and it needs to be recalibrated after running.
|
||||
*/
|
||||
public void reset() {
|
||||
synchronized (this) {
|
||||
m_integ_gyro_angle_x = 0.0;
|
||||
@@ -957,7 +998,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Yaw axis angle in degrees (CCW positive)
|
||||
* Returns the yaw axis angle in degrees (CCW positive).
|
||||
*
|
||||
* @return Yaw axis angle in degrees (CCW positive).
|
||||
*/
|
||||
public synchronized double getAngle() {
|
||||
switch (m_yaw_axis) {
|
||||
@@ -973,7 +1016,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Yaw axis angular rate in degrees per second (CCW positive)
|
||||
* 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) {
|
||||
@@ -989,14 +1034,18 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Yaw Axis
|
||||
* Returns which axis, kX, kY, or kZ, is set to the yaw axis.
|
||||
*
|
||||
* @return IMUAxis Yaw Axis
|
||||
*/
|
||||
public IMUAxis getYawAxis() {
|
||||
return m_yaw_axis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return accumulated gyro angle in the X axis in degrees
|
||||
* Returns the accumulated gyro angle in the X axis in degrees.
|
||||
*
|
||||
* @return The accumulated gyro angle in the X axis in degrees.
|
||||
*/
|
||||
public synchronized double getGyroAngleX() {
|
||||
if (m_simGyroAngleX != null) {
|
||||
@@ -1006,7 +1055,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return accumulated gyro angle in the Y axis in degrees
|
||||
* Returns the accumulated gyro angle in the Y axis in degrees.
|
||||
*
|
||||
* @return The accumulated gyro angle in the Y axis in degrees.
|
||||
*/
|
||||
public synchronized double getGyroAngleY() {
|
||||
if (m_simGyroAngleY != null) {
|
||||
@@ -1016,7 +1067,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return accumulated gyro angle in the Z axis in degrees
|
||||
* Returns the accumulated gyro angle in the Z axis in degrees.
|
||||
*
|
||||
* @return The accumulated gyro angle in the Z axis in degrees.
|
||||
*/
|
||||
public synchronized double getGyroAngleZ() {
|
||||
if (m_simGyroAngleZ != null) {
|
||||
@@ -1026,7 +1079,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return gyro angular rate in the X axis in degrees per second
|
||||
* Returns the gyro angular rate in the X axis in degrees per second.
|
||||
*
|
||||
* @return The gyro angular rate in the X axis in degrees per second.
|
||||
*/
|
||||
public synchronized double getGyroRateX() {
|
||||
if (m_simGyroRateX != null) {
|
||||
@@ -1036,7 +1091,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return gyro angular rate in the Y axis in degrees per second
|
||||
* Returns the gyro angular rate in the Y axis in degrees per second.
|
||||
*
|
||||
* @return The gyro angular rate in the Y axis in degrees per second.
|
||||
*/
|
||||
public synchronized double getGyroRateY() {
|
||||
if (m_simGyroRateY != null) {
|
||||
@@ -1046,7 +1103,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return gyro angular rate in the Z axis in degrees per second
|
||||
* Returns the gyro angular rate in the Z axis in degrees per second.
|
||||
*
|
||||
* @return The gyro angular rate in the Z axis in degrees per second.
|
||||
*/
|
||||
public synchronized double getGyroRateZ() {
|
||||
if (m_simGyroRateZ != null) {
|
||||
@@ -1056,7 +1115,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return urrent acceleration in the X axis in meters per second squared
|
||||
* Returns the acceleration in the X axis in meters per second squared.
|
||||
*
|
||||
* @return The acceleration in the X axis in meters per second squared.
|
||||
*/
|
||||
public synchronized double getAccelX() {
|
||||
if (m_simAccelX != null) {
|
||||
@@ -1066,7 +1127,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current acceleration in the Y axis in meters per second squared
|
||||
* Returns the acceleration in the Y axis in meters per second squared.
|
||||
*
|
||||
* @return The acceleration in the Y axis in meters per second squared.
|
||||
*/
|
||||
public synchronized double getAccelY() {
|
||||
if (m_simAccelY != null) {
|
||||
@@ -1076,7 +1139,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current acceleration in the Z axis in meters per second squared
|
||||
* Returns the acceleration in the Z axis in meters per second squared.
|
||||
*
|
||||
* @return The acceleration in the Z axis in meters per second squared.
|
||||
*/
|
||||
public synchronized double getAccelZ() {
|
||||
if (m_simAccelZ != null) {
|
||||
@@ -1086,7 +1151,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Magnetic field strength in the X axis in Tesla
|
||||
* Returns the magnetic field strength in the X axis in Tesla.
|
||||
*
|
||||
* @return The magnetic field strength in the X axis in Tesla.
|
||||
*/
|
||||
public synchronized double getMagneticFieldX() {
|
||||
// mG to T
|
||||
@@ -1094,7 +1161,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Magnetic field strength in the Y axis in Tesla
|
||||
* Returns the magnetic field strength in the Y axis in Tesla.
|
||||
*
|
||||
* @return The magnetic field strength in the Y axis in Tesla.
|
||||
*/
|
||||
public synchronized double getMagneticFieldY() {
|
||||
// mG to T
|
||||
@@ -1102,7 +1171,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Magnetic field strength in the Z axis in Tesla
|
||||
* Returns the magnetic field strength in the Z axis in Tesla.
|
||||
*
|
||||
* @return The magnetic field strength in the Z axis in Tesla.
|
||||
*/
|
||||
public synchronized double getMagneticFieldZ() {
|
||||
// mG to T
|
||||
@@ -1110,35 +1181,47 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return X-axis complementary angle in degrees
|
||||
* Returns the complementary angle around the X axis computed from accelerometer and gyro rate
|
||||
* measurements.
|
||||
*
|
||||
* @return The X-axis complementary angle in degrees.
|
||||
*/
|
||||
public synchronized double getXComplementaryAngle() {
|
||||
return m_compAngleX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Y-axis complementary angle in degrees
|
||||
* Returns the complementary angle around the Y axis computed from accelerometer and gyro rate
|
||||
* measurements.
|
||||
*
|
||||
* @return The Y-axis complementary angle in degrees.
|
||||
*/
|
||||
public synchronized double getYComplementaryAngle() {
|
||||
return m_compAngleY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return X-axis filtered acceleration angle in degrees
|
||||
* Returns the X-axis filtered acceleration angle in degrees.
|
||||
*
|
||||
* @return The X-axis filtered acceleration angle in degrees.
|
||||
*/
|
||||
public synchronized double getXFilteredAccelAngle() {
|
||||
return m_accelAngleX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Y-axis filtered acceleration angle in degrees
|
||||
* Returns the Y-axis filtered acceleration angle in degrees.
|
||||
*
|
||||
* @return The Y-axis filtered acceleration angle in degrees.
|
||||
*/
|
||||
public synchronized double getYFilteredAccelAngle() {
|
||||
return m_accelAngleY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Barometric Pressure in PSI
|
||||
* Returns the barometric pressure in PSI.
|
||||
*
|
||||
* @return The barometric pressure in PSI.
|
||||
*/
|
||||
public synchronized double getBarometricPressure() {
|
||||
// mbar to PSI conversion
|
||||
@@ -1146,7 +1229,9 @@ public class ADIS16448_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Temperature in degrees Celsius
|
||||
* Returns the temperature in degrees Celsius.
|
||||
*
|
||||
* @return The temperature in degrees Celsius.
|
||||
*/
|
||||
public synchronized double getTemperature() {
|
||||
return m_temp;
|
||||
|
||||
@@ -155,31 +155,31 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
|
||||
FLASH_CNT
|
||||
};
|
||||
|
||||
/** Calibration times for the ADIS16470. */
|
||||
/** ADIS16470 calibration times. */
|
||||
public enum CalibrationTime {
|
||||
/** 32ms calibration */
|
||||
/** 32 ms calibration time */
|
||||
_32ms(0),
|
||||
/** 64ms calibration */
|
||||
/** 64 ms calibration time */
|
||||
_64ms(1),
|
||||
/** 128ms calibration */
|
||||
/** 128 ms calibration time */
|
||||
_128ms(2),
|
||||
/** 256ms calibration */
|
||||
/** 256 ms calibration time */
|
||||
_256ms(3),
|
||||
/** 512ms calibration */
|
||||
/** 512 ms calibration time */
|
||||
_512ms(4),
|
||||
/** 1 second calibration */
|
||||
/** 1 s calibration time */
|
||||
_1s(5),
|
||||
/** 2 second calibration */
|
||||
/** 2 s calibration time */
|
||||
_2s(6),
|
||||
/** 4 second calibration */
|
||||
/** 4 s calibration time */
|
||||
_4s(7),
|
||||
/** 8 second calibration */
|
||||
/** 8 s calibration time */
|
||||
_8s(8),
|
||||
/** 16 second calibration */
|
||||
/** 16 s calibration time */
|
||||
_16s(9),
|
||||
/** 32 second calibration */
|
||||
/** 32 s calibration time */
|
||||
_32s(10),
|
||||
/** 64 second calibration */
|
||||
/** 64 s calibration time */
|
||||
_64s(11);
|
||||
|
||||
private final int value;
|
||||
@@ -202,11 +202,11 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
|
||||
kY,
|
||||
/** The IMU's Z axis */
|
||||
kZ,
|
||||
/** The user configured yaw axis */
|
||||
/** The user-configured yaw axis */
|
||||
kYaw,
|
||||
/** The user configured pitch axis */
|
||||
/** The user-configured pitch axis */
|
||||
kPitch,
|
||||
/** The user configured roll axis */
|
||||
/** The user-configured roll axis */
|
||||
kRoll,
|
||||
}
|
||||
|
||||
@@ -290,19 +290,22 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ADIS16740 IMU object. The default setup is the onboard SPI port with a
|
||||
* calibration time of 4 seconds. Yaw, pitch, and roll are kZ, kX, and kY respectively.
|
||||
* Creates a new ADIS16740 IMU object.
|
||||
*
|
||||
* <p>The default setup is the onboard SPI port with a calibration time of 4 seconds. Yaw, pitch,
|
||||
* and roll are kZ, kX, and kY respectively.
|
||||
*/
|
||||
public ADIS16470_IMU() {
|
||||
this(IMUAxis.kZ, IMUAxis.kX, IMUAxis.kY, SPI.Port.kOnboardCS0, CalibrationTime._4s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ADIS16740 IMU object. The default setup is the onboard SPI port with a
|
||||
* calibration time of 4 seconds.
|
||||
* Creates a new ADIS16740 IMU object.
|
||||
*
|
||||
* <p>The default setup is the onboard SPI port with a calibration time of 4 seconds.
|
||||
*
|
||||
* <p><b><i>Input axes limited to kX, kY and kZ. Specifying kYaw, kPitch,or kRoll will result in
|
||||
* an error. </i></b>
|
||||
* an error.</i></b>
|
||||
*
|
||||
* @param yaw_axis The axis that measures the yaw
|
||||
* @param pitch_axis The axis that measures the pitch
|
||||
@@ -315,8 +318,8 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
|
||||
/**
|
||||
* Creates a new ADIS16740 IMU object.
|
||||
*
|
||||
* <p><b><i> Input axes limited to kX, kY and kZ. Specifying kYaw, kPitch,or kRoll will result in
|
||||
* an error. </i></b>
|
||||
* <p><b><i>Input axes limited to kX, kY and kZ. Specifying kYaw, kPitch,or kRoll will result in
|
||||
* an error.</i></b>
|
||||
*
|
||||
* @param yaw_axis The axis that measures the yaw
|
||||
* @param pitch_axis The axis that measures the pitch
|
||||
@@ -625,21 +628,25 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
|
||||
/**
|
||||
* Configures the decimation rate of the IMU.
|
||||
*
|
||||
* @param reg The new decimation value.
|
||||
* @return 0 if OK, 2 if error
|
||||
* @param decimationRate The new decimation value.
|
||||
* @return 0 if success, 1 if no change, 2 if error.
|
||||
*/
|
||||
public int configDecRate(int reg) {
|
||||
int m_reg = reg;
|
||||
public int configDecRate(int decimationRate) {
|
||||
// Switches the active SPI port to standard SPI mode, writes a new value to
|
||||
// the DECIMATE register in the IMU, and re-enables auto SPI.
|
||||
//
|
||||
// This function enters standard SPI mode, writes a new DECIMATE setting to
|
||||
// the IMU, adjusts the sample scale factor, and re-enters auto SPI mode.
|
||||
if (!switchToStandardSPI()) {
|
||||
DriverStation.reportError("Failed to configure/reconfigure standard SPI.", false);
|
||||
return 2;
|
||||
}
|
||||
if (m_reg > 1999) {
|
||||
if (decimationRate > 1999) {
|
||||
DriverStation.reportError("Attempted to write an invalid decimation value.", false);
|
||||
m_reg = 1999;
|
||||
decimationRate = 1999;
|
||||
}
|
||||
m_scaled_sample_rate = (((m_reg + 1.0) / 2000.0) * 1000000.0);
|
||||
writeRegister(DEC_RATE, m_reg);
|
||||
m_scaled_sample_rate = (((decimationRate + 1.0) / 2000.0) * 1000000.0);
|
||||
writeRegister(DEC_RATE, decimationRate);
|
||||
System.out.println("Decimation register: " + readRegister(DEC_RATE));
|
||||
if (!switchToAutoSPI()) {
|
||||
DriverStation.reportError("Failed to configure/reconfigure auto SPI.", false);
|
||||
@@ -1003,8 +1010,10 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the gyro accumulations to a heading of zero. This can be used if the "zero" orientation
|
||||
* of the sensor needs to be changed in runtime.
|
||||
* Reset the gyro.
|
||||
*
|
||||
* <p>Resets the gyro accumulations to a heading of zero. This can be used if there is significant
|
||||
* drift in the gyro and it needs to be recalibrated after running.
|
||||
*/
|
||||
public void reset() {
|
||||
synchronized (this) {
|
||||
@@ -1086,8 +1095,10 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param axis The IMUAxis whose angle to return
|
||||
* @return The axis angle in degrees (CCW positive)
|
||||
* Returns the axis angle in degrees (CCW positive).
|
||||
*
|
||||
* @param axis The IMUAxis whose angle to return.
|
||||
* @return The axis angle in degrees (CCW positive).
|
||||
*/
|
||||
public synchronized double getAngle(IMUAxis axis) {
|
||||
switch (axis) {
|
||||
@@ -1126,8 +1137,10 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param axis The IMUAxis whose rate to return
|
||||
* @return Axis angular rate in degrees per second (CCW positive)
|
||||
* Returns the axis angular rate in degrees per second (CCW positive).
|
||||
*
|
||||
* @param axis The IMUAxis whose rate to return.
|
||||
* @return Axis angular rate in degrees per second (CCW positive).
|
||||
*/
|
||||
public synchronized double getRate(IMUAxis axis) {
|
||||
switch (axis) {
|
||||
@@ -1192,49 +1205,65 @@ public class ADIS16470_IMU implements AutoCloseable, Sendable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The acceleration in the X axis
|
||||
* Returns the acceleration in the X axis in meters per second squared.
|
||||
*
|
||||
* @return The acceleration in the X axis in meters per second squared.
|
||||
*/
|
||||
public synchronized double getAccelX() {
|
||||
return m_accel_x * 9.81;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The acceleration in the Y axis
|
||||
* Returns the acceleration in the Y axis in meters per second squared.
|
||||
*
|
||||
* @return The acceleration in the Y axis in meters per second squared.
|
||||
*/
|
||||
public synchronized double getAccelY() {
|
||||
return m_accel_y * 9.81;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The acceleration in the Z axis
|
||||
* Returns the acceleration in the Z axis in meters per second squared.
|
||||
*
|
||||
* @return The acceleration in the Z axis in meters per second squared.
|
||||
*/
|
||||
public synchronized double getAccelZ() {
|
||||
return m_accel_z * 9.81;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The X-axis complementary angle
|
||||
* Returns the complementary angle around the X axis computed from accelerometer and gyro rate
|
||||
* measurements.
|
||||
*
|
||||
* @return The X-axis complementary angle in degrees.
|
||||
*/
|
||||
public synchronized double getXComplementaryAngle() {
|
||||
return m_compAngleX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Y-axis complementary angle
|
||||
* Returns the complementary angle around the Y axis computed from accelerometer and gyro rate
|
||||
* measurements.
|
||||
*
|
||||
* @return The Y-axis complementary angle in degrees.
|
||||
*/
|
||||
public synchronized double getYComplementaryAngle() {
|
||||
return m_compAngleY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The X-axis filtered acceleration angle
|
||||
* Returns the X-axis filtered acceleration angle in degrees.
|
||||
*
|
||||
* @return The X-axis filtered acceleration angle in degrees.
|
||||
*/
|
||||
public synchronized double getXFilteredAccelAngle() {
|
||||
return m_accelAngleX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Y-axis filtered acceleration angle
|
||||
* Returns the Y-axis filtered acceleration angle in degrees.
|
||||
*
|
||||
* @return The Y-axis filtered acceleration angle in degrees.
|
||||
*/
|
||||
public synchronized double getYFilteredAccelAngle() {
|
||||
return m_accelAngleY;
|
||||
|
||||
@@ -43,16 +43,25 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
|
||||
private static final byte kDataFormat_FullRes = 0x08;
|
||||
private static final byte kDataFormat_Justify = 0x04;
|
||||
|
||||
/** Accelerometer range. */
|
||||
public enum Range {
|
||||
/** 2 Gs max. */
|
||||
k2G,
|
||||
/** 4 Gs max. */
|
||||
k4G,
|
||||
/** 8 Gs max. */
|
||||
k8G,
|
||||
/** 16 Gs max. */
|
||||
k16G
|
||||
}
|
||||
|
||||
/** Accelerometer axes. */
|
||||
public enum Axes {
|
||||
/** X axis. */
|
||||
kX((byte) 0x00),
|
||||
/** Y axis. */
|
||||
kY((byte) 0x02),
|
||||
/** Z axis. */
|
||||
kZ((byte) 0x04);
|
||||
|
||||
/** The integer value representing this enumeration. */
|
||||
@@ -63,11 +72,20 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/** Container type for accelerations from all axes. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class AllAxes {
|
||||
/** Acceleration along the X axis in g-forces. */
|
||||
public double XAxis;
|
||||
|
||||
/** Acceleration along the Y axis in g-forces. */
|
||||
public double YAxis;
|
||||
|
||||
/** Acceleration along the Z axis in g-forces. */
|
||||
public double ZAxis;
|
||||
|
||||
/** Default constructor. */
|
||||
public AllAxes() {}
|
||||
}
|
||||
|
||||
private I2C m_i2c;
|
||||
@@ -123,10 +141,20 @@ public class ADXL345_I2C implements NTSendable, AutoCloseable {
|
||||
SendableRegistry.addLW(this, "ADXL345_I2C", port.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the I2C port.
|
||||
*
|
||||
* @return The I2C port.
|
||||
*/
|
||||
public int getPort() {
|
||||
return m_i2c.getPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the I2C device address.
|
||||
*
|
||||
* @return The I2C device address.
|
||||
*/
|
||||
public int getDeviceAddress() {
|
||||
return m_i2c.getDeviceAddress();
|
||||
}
|
||||
|
||||
@@ -40,16 +40,25 @@ public class ADXL345_SPI implements NTSendable, AutoCloseable {
|
||||
private static final int kDataFormat_FullRes = 0x08;
|
||||
private static final int kDataFormat_Justify = 0x04;
|
||||
|
||||
/** Accelerometer range. */
|
||||
public enum Range {
|
||||
/** 2 Gs max. */
|
||||
k2G,
|
||||
/** 4 Gs max. */
|
||||
k4G,
|
||||
/** 8 Gs max. */
|
||||
k8G,
|
||||
/** 16 Gs max. */
|
||||
k16G
|
||||
}
|
||||
|
||||
/** Accelerometer axes. */
|
||||
public enum Axes {
|
||||
/** X axis. */
|
||||
kX((byte) 0x00),
|
||||
/** Y axis. */
|
||||
kY((byte) 0x02),
|
||||
/** Z axis. */
|
||||
kZ((byte) 0x04);
|
||||
|
||||
/** The integer value representing this enumeration. */
|
||||
@@ -60,11 +69,20 @@ public class ADXL345_SPI implements NTSendable, AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/** Container type for accelerations from all axes. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class AllAxes {
|
||||
/** Acceleration along the X axis in g-forces. */
|
||||
public double XAxis;
|
||||
|
||||
/** Acceleration along the Y axis in g-forces. */
|
||||
public double YAxis;
|
||||
|
||||
/** Acceleration along the Z axis in g-forces. */
|
||||
public double ZAxis;
|
||||
|
||||
/** Default constructor. */
|
||||
public AllAxes() {}
|
||||
}
|
||||
|
||||
private SPI m_spi;
|
||||
@@ -102,6 +120,11 @@ public class ADXL345_SPI implements NTSendable, AutoCloseable {
|
||||
SendableRegistry.addLW(this, "ADXL345_SPI", port.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SPI port.
|
||||
*
|
||||
* @return The SPI port.
|
||||
*/
|
||||
public int getPort() {
|
||||
return m_spi.getPort();
|
||||
}
|
||||
|
||||
@@ -43,17 +43,26 @@ public class ADXL362 implements NTSendable, AutoCloseable {
|
||||
|
||||
private static final byte kPowerCtl_Measure = 0x02;
|
||||
|
||||
/** Accelerometer range. */
|
||||
public enum Range {
|
||||
/** 2 Gs max. */
|
||||
k2G,
|
||||
/** 4 Gs max. */
|
||||
k4G,
|
||||
/** 8 Gs max. */
|
||||
k8G
|
||||
}
|
||||
|
||||
/** Accelerometer axes. */
|
||||
public enum Axes {
|
||||
/** X axis. */
|
||||
kX((byte) 0x00),
|
||||
/** Y axis. */
|
||||
kY((byte) 0x02),
|
||||
/** Z axis. */
|
||||
kZ((byte) 0x04);
|
||||
|
||||
/** Axis value. */
|
||||
public final byte value;
|
||||
|
||||
Axes(byte value) {
|
||||
@@ -61,11 +70,20 @@ public class ADXL362 implements NTSendable, AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/** Container type for accelerations from all axes. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class AllAxes {
|
||||
/** Acceleration along the X axis in g-forces. */
|
||||
public double XAxis;
|
||||
|
||||
/** Acceleration along the Y axis in g-forces. */
|
||||
public double YAxis;
|
||||
|
||||
/** Acceleration along the Z axis in g-forces. */
|
||||
public double ZAxis;
|
||||
|
||||
/** Default constructor. */
|
||||
public AllAxes() {}
|
||||
}
|
||||
|
||||
private SPI m_spi;
|
||||
@@ -142,6 +160,11 @@ public class ADXL362 implements NTSendable, AutoCloseable {
|
||||
SendableRegistry.addLW(this, "ADXL362", port.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SPI port.
|
||||
*
|
||||
* @return The SPI port.
|
||||
*/
|
||||
public int getPort() {
|
||||
return m_spi.getPort();
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ public class AnalogEncoder implements Sendable, AutoCloseable {
|
||||
private double m_distancePerRotation = 1.0;
|
||||
private double m_lastPosition;
|
||||
|
||||
protected SimDevice m_simDevice;
|
||||
protected SimDouble m_simPosition;
|
||||
protected SimDouble m_simAbsolutePosition;
|
||||
private SimDevice m_simDevice;
|
||||
private SimDouble m_simPosition;
|
||||
private SimDouble m_simAbsolutePosition;
|
||||
|
||||
/**
|
||||
* Construct a new AnalogEncoder attached to a specific AnalogIn channel.
|
||||
|
||||
@@ -50,10 +50,20 @@ public class AnalogOutput implements Sendable, AutoCloseable {
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of the analog output.
|
||||
*
|
||||
* @param voltage The output value in Volts, from 0.0 to +5.0.
|
||||
*/
|
||||
public void setVoltage(double voltage) {
|
||||
AnalogJNI.setAnalogOutput(m_port, voltage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the voltage of the analog output.
|
||||
*
|
||||
* @return The value in Volts, from 0.0 to +5.0.
|
||||
*/
|
||||
public double getVoltage() {
|
||||
return AnalogJNI.getAnalogOutput(m_port);
|
||||
}
|
||||
|
||||
@@ -30,9 +30,12 @@ public class AnalogTrigger implements Sendable, AutoCloseable {
|
||||
/** Where the analog trigger is attached. */
|
||||
protected int m_port;
|
||||
|
||||
protected AnalogInput m_analogInput;
|
||||
protected DutyCycle m_dutyCycle;
|
||||
protected boolean m_ownsAnalog;
|
||||
private AnalogInput m_analogInput;
|
||||
|
||||
@SuppressWarnings({"PMD.SingularField", "PMD.UnusedPrivateField"})
|
||||
private DutyCycle m_dutyCycle;
|
||||
|
||||
private boolean m_ownsAnalog;
|
||||
|
||||
/**
|
||||
* Constructor for an analog trigger given a channel number.
|
||||
|
||||
@@ -106,9 +106,13 @@ public class AnalogTriggerOutput extends DigitalSource implements Sendable {
|
||||
|
||||
/** Defines the state in which the AnalogTrigger triggers. */
|
||||
public enum AnalogTriggerType {
|
||||
/** In window. */
|
||||
kInWindow(AnalogJNI.AnalogTriggerType.kInWindow),
|
||||
/** State. */
|
||||
kState(AnalogJNI.AnalogTriggerType.kState),
|
||||
/** Rising pulse. */
|
||||
kRisingPulse(AnalogJNI.AnalogTriggerType.kRisingPulse),
|
||||
/** Falling pulse. */
|
||||
kFallingPulse(AnalogJNI.AnalogTriggerType.kFallingPulse);
|
||||
|
||||
private final int value;
|
||||
|
||||
@@ -17,9 +17,13 @@ import edu.wpi.first.util.sendable.SendableRegistry;
|
||||
* <p>This class allows access to the roboRIO's internal accelerometer.
|
||||
*/
|
||||
public class BuiltInAccelerometer implements Sendable, AutoCloseable {
|
||||
/** Accelerometer range. */
|
||||
public enum Range {
|
||||
/** 2 Gs max. */
|
||||
k2G,
|
||||
/** 4 Gs max. */
|
||||
k4G,
|
||||
/** 8 Gs max. */
|
||||
k8G
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,18 @@ package edu.wpi.first.wpilibj;
|
||||
* source. The source can either be a digital input or analog trigger but not both.
|
||||
*/
|
||||
public abstract class DigitalSource implements AutoCloseable {
|
||||
/**
|
||||
* Returns true if this DigitalSource is an AnalogTrigger.
|
||||
*
|
||||
* @return True if this DigitalSource is an AnalogTrigger.
|
||||
*/
|
||||
public abstract boolean isAnalogTrigger();
|
||||
|
||||
/**
|
||||
* The DigitalSource channel.
|
||||
*
|
||||
* @return The DigitalSource channel.
|
||||
*/
|
||||
public abstract int getChannel();
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,17 +23,28 @@ import edu.wpi.first.wpilibj.event.EventLoop;
|
||||
public class XboxController extends GenericHID {
|
||||
/** Represents a digital button on an XboxController. */
|
||||
public enum Button {
|
||||
/** Left bumper. */
|
||||
kLeftBumper(5),
|
||||
/** Right bumper. */
|
||||
kRightBumper(6),
|
||||
/** Left stick. */
|
||||
kLeftStick(9),
|
||||
/** Right stick. */
|
||||
kRightStick(10),
|
||||
/** A. */
|
||||
kA(1),
|
||||
/** B. */
|
||||
kB(2),
|
||||
/** X. */
|
||||
kX(3),
|
||||
/** Y. */
|
||||
kY(4),
|
||||
/** Back. */
|
||||
kBack(7),
|
||||
/** Start. */
|
||||
kStart(8);
|
||||
|
||||
/** Button value. */
|
||||
public final int value;
|
||||
|
||||
Button(int value) {
|
||||
@@ -60,13 +71,20 @@ public class XboxController extends GenericHID {
|
||||
|
||||
/** Represents an axis on an XboxController. */
|
||||
public enum Axis {
|
||||
/** Left X. */
|
||||
kLeftX(0),
|
||||
/** Right X. */
|
||||
kRightX(4),
|
||||
/** Left Y. */
|
||||
kLeftY(1),
|
||||
/** Right Y. */
|
||||
kRightY(5),
|
||||
/** Left trigger. */
|
||||
kLeftTrigger(2),
|
||||
/** Right trigger. */
|
||||
kRightTrigger(3);
|
||||
|
||||
/** Axis value. */
|
||||
public final int value;
|
||||
|
||||
Axis(int value) {
|
||||
|
||||
@@ -11,10 +11,15 @@ package edu.wpi.first.wpilibj.interfaces;
|
||||
*/
|
||||
@Deprecated(since = "2024", forRemoval = true)
|
||||
public interface Accelerometer {
|
||||
/** Accelerometer range. */
|
||||
enum Range {
|
||||
/** 2 Gs max. */
|
||||
k2G,
|
||||
/** 4 Gs max. */
|
||||
k4G,
|
||||
/** 8 Gs max. */
|
||||
k8G,
|
||||
/** 16 Gs max. */
|
||||
k16G
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,11 @@ import edu.wpi.first.wpilibj.ADXL345_I2C;
|
||||
import edu.wpi.first.wpilibj.ADXL345_SPI;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Class to control a simulated ADXL345. */
|
||||
public class ADXL345Sim {
|
||||
protected SimDouble m_simX;
|
||||
protected SimDouble m_simY;
|
||||
protected SimDouble m_simZ;
|
||||
private SimDouble m_simX;
|
||||
private SimDouble m_simY;
|
||||
private SimDouble m_simZ;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -48,15 +49,30 @@ public class ADXL345Sim {
|
||||
Objects.requireNonNull(m_simZ);
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
m_simX.set(x);
|
||||
/**
|
||||
* Sets the X acceleration.
|
||||
*
|
||||
* @param accel The X acceleration.
|
||||
*/
|
||||
public void setX(double accel) {
|
||||
m_simX.set(accel);
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
m_simY.set(y);
|
||||
/**
|
||||
* Sets the Y acceleration.
|
||||
*
|
||||
* @param accel The Y acceleration.
|
||||
*/
|
||||
public void setY(double accel) {
|
||||
m_simY.set(accel);
|
||||
}
|
||||
|
||||
public void setZ(double z) {
|
||||
m_simZ.set(z);
|
||||
/**
|
||||
* Sets the Z acceleration.
|
||||
*
|
||||
* @param accel The Z acceleration.
|
||||
*/
|
||||
public void setZ(double accel) {
|
||||
m_simZ.set(accel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,11 @@ import edu.wpi.first.hal.SimDouble;
|
||||
import edu.wpi.first.wpilibj.ADXL362;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Class to control a simulated ADXL362. */
|
||||
public class ADXL362Sim {
|
||||
protected SimDouble m_simX;
|
||||
protected SimDouble m_simY;
|
||||
protected SimDouble m_simZ;
|
||||
private SimDouble m_simX;
|
||||
private SimDouble m_simY;
|
||||
private SimDouble m_simZ;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -34,15 +35,30 @@ public class ADXL362Sim {
|
||||
Objects.requireNonNull(m_simZ);
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
m_simX.set(x);
|
||||
/**
|
||||
* Sets the X acceleration.
|
||||
*
|
||||
* @param accel The X acceleration.
|
||||
*/
|
||||
public void setX(double accel) {
|
||||
m_simX.set(accel);
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
m_simY.set(y);
|
||||
/**
|
||||
* Sets the Y acceleration.
|
||||
*
|
||||
* @param accel The Y acceleration.
|
||||
*/
|
||||
public void setY(double accel) {
|
||||
m_simY.set(accel);
|
||||
}
|
||||
|
||||
public void setZ(double z) {
|
||||
m_simZ.set(z);
|
||||
/**
|
||||
* Sets the Z acceleration.
|
||||
*
|
||||
* @param accel The Z acceleration.
|
||||
*/
|
||||
public void setZ(double accel) {
|
||||
m_simZ.set(accel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ import org.ejml.simple.SimpleMatrix;
|
||||
*
|
||||
* <p>Set simulated sensor readings with the simulated positions in {@link #getOutput()}
|
||||
*
|
||||
* @param <States> The number of states of the system.
|
||||
* @param <Inputs> The number of inputs to the system.
|
||||
* @param <Outputs> The number of outputs of the system.
|
||||
* @param <States> Number of states of the system.
|
||||
* @param <Inputs> Number of inputs to the system.
|
||||
* @param <Outputs> Number of outputs of the system.
|
||||
*/
|
||||
public class LinearSystemSim<States extends Num, Inputs extends Num, Outputs extends Num> {
|
||||
// The plant that represents the linear system.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user