Class OculusSubsystem
- All Implemented Interfaces:
Sendable
,Subsystem
,PoseSource
This subsystem leverages the Quest's inside-out SLAM tracking system to provide high-frequency (120Hz) robot pose estimation. Key features:
- Global SLAM-based localization - Field mapping and persistence - Sub-millimeter tracking precision - High update rate (120Hz) - Drift-free position tracking - Fast relocalization
The system operates in phases: 1. Pre-match mapping to capture field features 2. Initial pose acquisition and alignment 3. Continuous pose updates during match 4. Recovery handling if tracking is lost
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the most recent pose estimate from this source.Gets a human-readable identifier for this pose source.Gets the standard deviations of measurement uncertainty for this pose source.boolean
Checks if the pose source is currently connected and providing valid data.void
periodic()
Updates subsystem state and processes Quest data.boolean
ping()
Tests Quest communication.boolean
resetToPose
(Pose2d targetPose) Initiates pose reset operation.boolean
Initiates heading reset operation.Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystem
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
OculusSubsystem
Creates a new OculusSubsystem.Initializes communication with Quest hardware and prepares logging systems. The subsystem starts in an uninitialized state requiring pose calibration.
- Parameters:
io
- Interface for Quest hardware communication
-
-
Method Details
-
periodic
public void periodic()Updates subsystem state and processes Quest data.Called periodically by the command scheduler. This method: - Updates hardware inputs - Processes new pose data - Handles state transitions - Manages reset operations - Updates logging
-
resetToPose
Initiates pose reset operation.Attempts to reset Quest SLAM origin to align with target pose.
- Parameters:
targetPose
- Desired robot pose after reset- Returns:
- true if reset initiated successfully
-
zeroHeading
public boolean zeroHeading()Initiates heading reset operation.Attempts to zero current Quest heading measurement.
- Returns:
- true if reset initiated successfully
-
ping
public boolean ping()Tests Quest communication.Sends ping command to verify hardware connectivity.
- Returns:
- true if ping initiated successfully
-
isConnected
public boolean isConnected()Checks if the pose source is currently connected and providing valid data.This method should: - Verify hardware connectivity (if applicable) - Check data freshness - Validate sensor readings - Monitor update frequency
Quest connection is determined by checking if we've received any new Quest timestamp updates within our timeout window. Small variations in update timing are allowed, only triggering disconnect on significant delays.
- Specified by:
isConnected
in interfacePoseSource
- Returns:
- true if the source is connected and providing valid data
-
getCurrentPose
Gets the most recent pose estimate from this source.The returned pose should be: - In field-relative coordinates - Using the standard FRC coordinate system: - Origin at field corner - +X towards opposite alliance wall - +Y towards driver station - CCW positive rotation
If no valid pose is available, returns null.
Returns field-relative robot pose from Quest SLAM.
- Specified by:
getCurrentPose
in interfacePoseSource
- Returns:
- The current robot pose estimate, or null if unavailable
-
getStdDevs
Gets the standard deviations of measurement uncertainty for this pose source.Returns a 3x1 matrix containing standard deviations for: - X position (meters) - Y position (meters) - Rotation (radians)
These values should: - Reflect real measurement uncertainty - Scale with distance/conditions - Account for systematic errors - Consider environmental factors
Returns constant measurement uncertainty for Quest tracking.
- Specified by:
getStdDevs
in interfacePoseSource
- Returns:
- 3x1 matrix of standard deviations [x, y, theta]
-
getSourceName
Gets a human-readable identifier for this pose source.Used for: - Logging - Debugging - User interfaces - Status reporting
- Specified by:
getSourceName
in interfacePoseSource
- Returns:
- String identifier for this pose source
-