Class QuestNavWrapper
- All Implemented Interfaces:
AutoCloseable
VisionSystem, the pose filter and telemetry like every other
VisionCamera.
QuestNavWrapper quest = new QuestNavWrapper(new QuestNav(),
new VisionCameraConfig()
.withRobotToCamera(Inches.of(-10), Inches.of(0), Inches.of(14), // where the headset is
Degrees.of(0), Degrees.of(0), Degrees.of(180)));
// Once the robot's pose is known (at the start of autonomous, or from AprilTags while disabled):
quest.setRobotPose(startingPose);
The config's robot-to-camera transform is where the headset is on the robot. The Quest reports its own pose, and the wrapper moves it back to the robot's origin with that transform, so measure it carefully: an error in the headset's yaw turns every estimate.
The Quest tracks its pose relative to where it was when its tracking started, not on the field,
so its poses mean nothing until it is told where the robot is with setRobotPose(Pose2d). Until then, and from each pose reset until the headset confirms it, its
estimates are rejected. A reset sent with QuestNav.setPose(Pose3d) directly counts too, once the
wrapper exists. If the robot
program restarts while the headset keeps tracking (a brownout, for example), trustCurrentPose() accepts the pose the headset already has. If the QuestNav app on the headset
restarts, its tracking starts over, so its estimates are rejected again until the next reset.
Estimates are checked with VisionPoseFilter.checkWithoutTags(VisionPoseEstimate, Field, double): the age, field bounds,
height, tilt, pose jump and custom checks apply, the tag checks don't. Estimates taken while the
headset has lost tracking are rejected. Accepted estimates get the standard deviations from withStdDevs(Distance, Angle), not the filter's.
VisionCamera.update() calls QuestNav.commandPeriodic(), so QuestNav's callbacks still fire,
and reads QuestNav.getAllUnreadPoseFrames(). Don't call either elsewhere: each frame is
handed out only once. The headset has no pipelines; pipeline settings are ignored.
In simulation, the headset reports the robot's true pose from its VisionSim world in
its own tracking frame, which starts where the robot was on the first update, as a real headset's
does. setRobotPose(Pose2d) resets it at once. Use the wrapper's setRobotPose(Pose2d) in simulation, since the simulated headset doesn't read QuestNav.setPose(Pose3d). The world's blackouts and dropouts drop the headset's frames too.
No vendor configs are accepted; use getCamera() for QuestNav settings.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe camera name QuestNav estimates and telemetry are reported under.Fields inherited from class VisionCamera
config, name -
Constructor Summary
ConstructorsConstructorDescriptionQuestNavWrapper(gg.questnav.questnav.QuestNav questNav, VisionCameraConfig config) Wraps a QuestNav headset. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyPipelineIndex(int index) Switches the real camera's pipeline.checkEstimate(VisionPoseEstimate estimate, VisionPoseFilter filter, Field field, double nowSeconds, double averageTagAreaPercent) Runs the pose filter on an estimate.voidclose()Closes the reset subscribers, then the parts every camera shares.gg.questnav.questnav.QuestNavThe vendor's camera object, for settings YALL doesn't cover.The standard deviations given to accepted estimates.The simulated world this headset is in, whichVisionSystem.updateSimulation(Pose2d)updates.booleanWhether the headset's poses are on the field: it has confirmed a pose reset (ortrustCurrentPose()was called), and no newer reset is waiting for its response.booleanWhether this headset is giving simulated poses.booleanWhether the headset is tracking its pose.protected booleanWhether the real camera is sending data.protected List<VisionFrame> Reads the frames the real camera produced since the last call.protected intReads the real camera's pipeline.voidsetRobotPose(Pose2d robotPose) Tells the headset where the robot is, on the floor.voidsetRobotPose(Pose3d robotPose) Tells the headset where the robot is, which puts its poses on the field.voidAccepts the pose the headset already has, without resetting it.withStdDevs(Distance xy, Angle heading) Sets the standard deviations given to accepted estimates.Methods inherited from class VisionCamera
addVisionMeasurements, applyRobotOrientation, applyRobotToCamera, cacheRobotToCamera, forEachEstimatedPose, getBestTarget, getCameraFieldPose, getCameraSim, getCameraYawOnRobot, getConfig, getEstimatedPose, getEstimatedPoses, getFilterStats, getLastRejectionReason, getLatestResult, getName, getPipelineIndex, getRejectedPoses, getRobotToCamera, getSimulatedPoseEstimator, getTargets, getUnreadResults, hasTargets, isConnected, resetFilterStats, setPipelineIndex, setRobotOrientation, setRobotOrientation, setRobotOrientation, setRobotToCamera, setRobotToCamera, update
-
Field Details
-
NAME
The camera name QuestNav estimates and telemetry are reported under.- See Also:
-
-
Constructor Details
-
Method Details
-
withStdDevs
Sets the standard deviations given to accepted estimates. Defaults to QuestNav's recommended 2 cm for x and y and 2 degrees for the heading.- Parameters:
xy- Standard deviation of x and y.heading- Standard deviation of the heading.- Returns:
- This wrapper, for chaining.
-
getStdDevs
-
setRobotPose
Tells the headset where the robot is, which puts its poses on the field. Call it when the robot's pose is known: at the start of autonomous, or from AprilTag estimates while disabled. Estimates are rejected until the headset confirms the reset.- Parameters:
robotPose- The robot's pose on the field.
-
setRobotPose
Tells the headset where the robot is, on the floor.- Parameters:
robotPose- The robot's pose on the field.- See Also:
-
trustCurrentPose
public void trustCurrentPose()Accepts the pose the headset already has, without resetting it. Use it when the robot program restarted while the headset kept tracking, such as after a brownout mid-match, so the headset's poses are still on the field from an earlier reset. -
isPoseSet
public boolean isPoseSet()Whether the headset's poses are on the field: it has confirmed a pose reset (ortrustCurrentPose()was called), and no newer reset is waiting for its response.- Returns:
- true if its estimates can be accepted.
-
isTracking
public boolean isTracking()Whether the headset is tracking its pose. Simulated headsets track unless their world is blacked out.- Returns:
- true if tracking.
-
readFrames
Description copied from class:VisionCameraReads the frames the real camera produced since the last call. Call once per loop.- Specified by:
readFramesin classVisionCamera- Returns:
- The frames, oldest first.
-
checkEstimate
protected Optional<String> checkEstimate(VisionPoseEstimate estimate, VisionPoseFilter filter, Field field, double nowSeconds, double averageTagAreaPercent) Description copied from class:VisionCameraRuns the pose filter on an estimate. AprilTag cameras useVisionPoseFilter.check(VisionPoseEstimate, Field, double, double); a pose source that doesn't use tags overrides this, for example withVisionPoseFilter.checkWithoutTags(VisionPoseEstimate, Field, double).- Overrides:
checkEstimatein classVisionCamera- Parameters:
estimate- The estimate.filter- The config's pose filter.field- The config's field.nowSeconds- CurrentTimer.getMonotonicTimestamp().averageTagAreaPercent- Average image area of the frame's AprilTags, or NaN if unknown.- Returns:
- Why the estimate was rejected, or empty to accept it.
-
applyPipelineIndex
protected void applyPipelineIndex(int index) Description copied from class:VisionCameraSwitches the real camera's pipeline.- Specified by:
applyPipelineIndexin classVisionCamera- Parameters:
index- Pipeline index.
-
readPipelineIndex
protected int readPipelineIndex()Description copied from class:VisionCameraReads the real camera's pipeline.- Specified by:
readPipelineIndexin classVisionCamera- Returns:
- Pipeline index.
-
readConnected
protected boolean readConnected()Description copied from class:VisionCameraWhether the real camera is sending data.- Specified by:
readConnectedin classVisionCamera- Returns:
- true if connected.
-
isSimulated
public boolean isSimulated()Whether this headset is giving simulated poses.- Overrides:
isSimulatedin classVisionCamera- Returns:
- true in simulation with simulation enabled in the config.
-
getVisionSim
The simulated world this headset is in, whichVisionSystem.updateSimulation(Pose2d)updates.- Overrides:
getVisionSimin classVisionCamera- Returns:
- The world, or empty when not simulating.
-
getCamera
public gg.questnav.questnav.QuestNav getCamera()Description copied from class:VisionCameraThe vendor's camera object, for settings YALL doesn't cover. Each wrapper narrows the return type to its vendor's class.- Specified by:
getCamerain classVisionCamera- Returns:
- The vendor's camera object.
-
close
public void close()Closes the reset subscribers, then the parts every camera shares.- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classVisionCamera
-