mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-26 01:51:40 +00:00
Fix usage reporting. (#1964)
## Description Fixes the amount of cameras and pose estimators reported by usage reporting. ## Meta Merge checklist: - [x] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [x] The description documents the _what_ and _why_ - [ ] If this PR changes behavior or adds a feature, user documentation is updated - [ ] If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly - [ ] If this PR touches configuration, this is backwards compatible with settings back to v2024.3.1 - [ ] If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated - [ ] If this PR addresses a bug, a regression test for it is added --------- Signed-off-by: Jade Turner <spacey-sooty@proton.me>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
from enum import Enum
|
||||
from typing import List
|
||||
|
||||
import hal
|
||||
import ntcore
|
||||
|
||||
# magical import to make serde stuff work
|
||||
@@ -48,6 +49,8 @@ def setVersionCheckEnabled(enabled: bool):
|
||||
|
||||
|
||||
class PhotonCamera:
|
||||
instance_count = 1
|
||||
|
||||
def __init__(self, cameraName: str):
|
||||
"""Constructs a PhotonCamera from the name of the camera.
|
||||
|
||||
@@ -108,6 +111,13 @@ class PhotonCamera:
|
||||
# Start the time sync server
|
||||
inst.start()
|
||||
|
||||
# Usage reporting
|
||||
hal.report(
|
||||
hal.tResourceType.kResourceType_PhotonCamera.value,
|
||||
PhotonCamera.instance_count,
|
||||
)
|
||||
PhotonCamera.instance_count += 1
|
||||
|
||||
def getAllUnreadResults(self) -> List[PhotonPipelineResult]:
|
||||
"""
|
||||
The list of pipeline results sent by PhotonVision since the last call to getAllUnreadResults().
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
import enum
|
||||
from typing import Optional
|
||||
|
||||
import hal
|
||||
import wpilib
|
||||
from robotpy_apriltag import AprilTagFieldLayout
|
||||
from wpimath.geometry import Pose2d, Pose3d, Transform3d
|
||||
@@ -61,6 +62,8 @@ class PoseStrategy(enum.Enum):
|
||||
|
||||
|
||||
class PhotonPoseEstimator:
|
||||
instance_count = 1
|
||||
|
||||
"""
|
||||
The PhotonPoseEstimator class filters or combines readings from all the AprilTags visible at a
|
||||
given timestamp on the field to produce a single robot in field pose, using the strategy set
|
||||
@@ -96,7 +99,12 @@ class PhotonPoseEstimator:
|
||||
self._lastPose: Optional[Pose3d] = None
|
||||
self._referencePose: Optional[Pose3d] = None
|
||||
|
||||
# TODO: Implement HAL reporting
|
||||
# Usage reporting
|
||||
hal.report(
|
||||
hal.tResourceType.kResourceType_PhotonPoseEstimator.value,
|
||||
PhotonPoseEstimator.instance_count,
|
||||
)
|
||||
PhotonPoseEstimator.instance_count += 1
|
||||
|
||||
@property
|
||||
def fieldTags(self) -> AprilTagFieldLayout:
|
||||
|
||||
@@ -58,7 +58,7 @@ import org.photonvision.timesync.TimeSyncSingleton;
|
||||
|
||||
/** Represents a camera that is connected to PhotonVision. */
|
||||
public class PhotonCamera implements AutoCloseable {
|
||||
private static int InstanceCount = 0;
|
||||
private static int InstanceCount = 1;
|
||||
public static final String kTableName = "photonvision";
|
||||
private static final String PHOTON_ALERT_GROUP = "PhotonAlerts";
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ import org.photonvision.targeting.PhotonTrackedTarget;
|
||||
* below. Example usage can be found in our apriltagExample example project.
|
||||
*/
|
||||
public class PhotonPoseEstimator {
|
||||
private static int InstanceCount = 0;
|
||||
private static int InstanceCount = 1;
|
||||
|
||||
/** Position estimation strategies that can be used by the {@link PhotonPoseEstimator} class. */
|
||||
public enum PoseStrategy {
|
||||
|
||||
@@ -225,7 +225,7 @@ class PhotonCamera {
|
||||
private:
|
||||
units::second_t lastVersionCheckTime = 0_s;
|
||||
static bool VERSION_CHECK_ENABLED;
|
||||
inline static int InstanceCount = 0;
|
||||
inline static int InstanceCount = 1;
|
||||
|
||||
units::second_t prevTimeSyncWarnTime = 0_s;
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ class PhotonPoseEstimator {
|
||||
|
||||
units::second_t poseCacheTimestamp;
|
||||
|
||||
inline static int InstanceCount = 0;
|
||||
inline static int InstanceCount = 1;
|
||||
|
||||
inline void InvalidatePoseCache() { poseCacheTimestamp = -1_s; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user