mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11:40 +00:00
Upgrade to wpilib alpha-6 (#2434)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ryanforce08 <rradtke1208@gmail.com> Co-authored-by: PJ Reiniger <pj.reiniger@gmail.com> Co-authored-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: Matt Morley <matthew.morley.ca@gmail.com>
This commit is contained in:
@@ -6,8 +6,9 @@ import cv2 as cv
|
||||
import numpy as np
|
||||
import wpilib
|
||||
from robotpy_apriltag import AprilTagField, AprilTagFieldLayout
|
||||
from wpimath.geometry import Pose3d, Transform3d
|
||||
from wpimath import Pose3d, Transform3d
|
||||
from wpimath.units import meters, seconds
|
||||
from wpiutil import PixelFormat
|
||||
|
||||
from ..estimation import OpenCVHelp, RotTrlTransform3d, TargetModel, VisionEstimation
|
||||
from ..estimation.cameraTargetRelation import CameraTargetRelation
|
||||
@@ -66,7 +67,7 @@ class PhotonCameraSim:
|
||||
# TODO switch this back to default True when the functionality is enabled
|
||||
self.videoSimProcEnabled: bool = False
|
||||
self.heartbeatCounter: int = 0
|
||||
self.nextNtEntryTime = wpilib.Timer.getFPGATimestamp()
|
||||
self.nextNtEntryTime = wpilib.Timer.getMonotonicTimestamp()
|
||||
self.tagLayout = tagLayout
|
||||
|
||||
self.cam = camera
|
||||
@@ -76,7 +77,7 @@ class PhotonCameraSim:
|
||||
# TODO Check fps is right
|
||||
self.videoSimRaw = cs.CvSource(
|
||||
self.cam.getName() + "-raw",
|
||||
cs.VideoMode.PixelFormat.kGray,
|
||||
PixelFormat.GRAY,
|
||||
self.prop.getResWidth(),
|
||||
self.prop.getResHeight(),
|
||||
1,
|
||||
@@ -88,7 +89,7 @@ class PhotonCameraSim:
|
||||
# TODO Check fps is right
|
||||
self.videoSimProcessed = cs.CvSource(
|
||||
self.cam.getName() + "-processed",
|
||||
cs.VideoMode.PixelFormat.kGray,
|
||||
PixelFormat.GRAY,
|
||||
self.prop.getResWidth(),
|
||||
self.prop.getResHeight(),
|
||||
1,
|
||||
@@ -182,7 +183,7 @@ class PhotonCameraSim:
|
||||
ready
|
||||
"""
|
||||
# check if this camera is ready for another frame update
|
||||
now = wpilib.Timer.getFPGATimestamp()
|
||||
now = wpilib.Timer.getMonotonicTimestamp()
|
||||
timestamp = 0.0
|
||||
iter = 0
|
||||
# prepare next latest update
|
||||
@@ -434,7 +435,7 @@ class PhotonCameraSim:
|
||||
|
||||
# put this simulated data to NT
|
||||
self.heartbeatCounter += 1
|
||||
publishTimestampMicros = wpilib.Timer.getFPGATimestamp() * 1e6
|
||||
publishTimestampMicros = wpilib.Timer.getMonotonicTimestamp() * 1e6
|
||||
return PhotonPipelineResult(
|
||||
ntReceiveTimestampMicros=int(publishTimestampMicros + 10),
|
||||
metadata=PhotonPipelineMetadata(
|
||||
@@ -461,7 +462,7 @@ class PhotonCameraSim:
|
||||
:param receiveTimestamp: The (sim) timestamp when this result was read by NT in microseconds. If not passed image capture time is assumed be (current time - latency)
|
||||
"""
|
||||
if receiveTimestamp_us is None:
|
||||
receiveTimestamp_us = wpilib.Timer.getFPGATimestamp() * 1e6
|
||||
receiveTimestamp_us = wpilib.Timer.getMonotonicTimestamp() * 1e6
|
||||
receiveTimestamp_us = int(receiveTimestamp_us)
|
||||
|
||||
self.ts.latencyMillisEntry.set(result.getLatencyMillis(), receiveTimestamp_us)
|
||||
|
||||
Reference in New Issue
Block a user