Skip to main content

PhotonVision API Emulation Plan

This document defines what HeliOS must expose so PhotonVision clients can read camera results from HeliOS through the PhotonVision NT API shape.

Scope

ItemDecision
Adapter granularityDevice-wide root table with per-camera subtables
Root table/photonvision
Camera table/photonvision/<camera_name> for each HeliOS stream
Feature gateemulate_photonvision_api in POST /v1/device/nt4

Current vs Target

AreaCurrent HeliOS behaviorTarget PhotonVision-compatible behaviorRequired change
NT publishingGeneric HeliOS telemetry in backend/src/helios-api/src/nt4/bridge.rsPhotonVision table hierarchy and key namesAdd PV adapter publisher layer
PV camera discoveryNo PV camera namespace publishingStable per-camera subtables under /photonvisionAdd camera name mapping from streams
rawBytes packetHeliOS can read PV rawBytes from external PV (backend/src/helios-api/src/nt4/photonvision.rs)HeliOS publishes PV-compatible packed packet per cameraAdd packet encoder for PV schema/version
PV control keysNot consumedAccept per-camera and global PV control keysAdd NT subscribers + control translation
Multi-stream semanticsStream-centric internalsPV camera-centric API with independent camera stateAdd per-camera cache and update loop

NT API Surface (Per Camera)

These entries live under /photonvision/<camera_name>.

KeyTypeMeaningHeliOS statusWork needed
rawBytesbyte[]Packed target result payloadMissingEncode PV packet format from stream detections
latencyMillisdoublePipeline latency msMissingPublish per-camera latency
hasTargetbooleanWhether current pipeline has targetMissingPublish from detection count
targetPitchdoubleTarget pitch degreesMissingPublish selected target pitch
targetYawdoubleTarget yaw degreesMissingPublish selected target yaw
targetAreadoubleTarget area percentMissingPublish selected target area
targetSkewdoubleTarget skew degreesMissingPublish selected target skew
targetPosedouble[]Target pose [x,y,z,qw,qx,qy,qz]MissingConvert detection pose to PV schema
targetPixelsXdoublePixel X crosshairMissingPublish selected target center X
targetPixelsYdoublePixel Y crosshairMissingPublish selected target center Y

NT API Surface (Per Camera Controls)

These entries also live under /photonvision/<camera_name>.

KeyTypeExpected behaviorHeliOS statusWork needed
pipelineIndexintChange camera pipeline indexMissingMap to stream pipeline selection
driverModebooleanToggle driver modeMissingMap to stream processing mode
inputSaveImgCmdbooleanRising edge triggers input image saveMissingMap to media capture command
outputSaveImgCmdbooleanRising edge triggers output image saveMissingMap to media capture command

NT API Surface (Global Controls)

These entries live on root /photonvision.

KeyTypeExpected behaviorHeliOS statusWork needed
ledModeintLED mode (-1,0,1,2)MissingMap to device/per-camera LED control policy

Implementation Work Packages

PackageFiles to add/updateNotes
Adapter routingbackend/src/helios-api/src/main.rs, backend/src/helios-api/src/http/mod.rsRoute + lifecycle registration
PV publisherbackend/src/helios-api/src/nt4/bridge.rs and new nt4/photonvision_emulation.rsKeep generic publisher unaffected
PV packet encoderNew nt4/photonvision_packet_encode.rsMirror PV decode expectations for rawBytes
Control subscriberNew nt4/photonvision_control.rsWatch command keys and apply updates
Camera namingNew adapter name resolverStable deterministic camera names across restarts
Backpressure/cacheNew per-camera result cacheAvoid per-subscriber recompute and stale bursts

Conformance Test Matrix

TestPass criteria
Table hierarchyRoot /photonvision exists; one subtable per camera
Key/type conformanceAll documented PV keys publish correct NT types
rawBytes decodeOfficial Photon client decodes rawBytes without errors
Control behaviorpipelineIndex, driverMode, save-image commands apply correctly
Global LED controlRoot ledMode updates LED state according to PV semantics
Multi-camera isolationChanges on one camera do not affect others unintentionally

Notes

TopicDetail
Upstream directionPhotonVision docs recommend PhotonLib over direct NT API for long-term support
API lifecycle riskPhotonVision docs indicate NT API may be removed in 2027
HeliOS strategyKeep emulation isolated behind feature flag and adapter module boundaries

References