Skip to content

Commit 5209d42

Browse files
authored
Merge pull request #472 from thedropbears/we-are-a-team-that-logs
We-are-a-team-that-logs
2 parents ac84c6e + ff89d51 commit 5209d42

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

components/vision.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class VisualLocalizer(HasPerLoopCache):
7272

7373
reproj_error_threshold = tunable(2.0)
7474

75+
tags_state = tunable("none")
76+
7577
def __init__(
7678
self,
7779
# The name of the camera in PhotonVision.
@@ -323,6 +325,8 @@ def execute(self) -> None:
323325
for results in all_results:
324326
# if results didn't see any targets
325327
if not results.getTargets():
328+
self.tags_state = "none"
329+
326330
return
327331

328332
# if we have already processed these results
@@ -353,6 +357,9 @@ def execute(self) -> None:
353357
self.rotation_vision_uncertainty_multi_tag,
354358
),
355359
)
360+
self.tags_state = "multi"
361+
else:
362+
self.tags_state = "none"
356363

357364
if self.should_log:
358365
# Multitag results don't have best and alternates
@@ -369,6 +376,7 @@ def execute(self) -> None:
369376
or target.getBestCameraToTarget().translation().norm()
370377
> self.CAMERA_MAX_RANGE
371378
):
379+
self.tags_state = "none"
372380
continue
373381

374382
heading = self.heading_buffer.sample(results.getTimestampSeconds())
@@ -396,6 +404,8 @@ def execute(self) -> None:
396404
),
397405
)
398406

407+
self.tags_state = "single"
408+
399409
if self.should_log:
400410
self.best_log.setPose(pose)
401411

robot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def createObjects(self) -> None:
6060
self.event_loop = wpilib.event.EventLoop()
6161
self.data_log = wpilib.DataLogManager.getLog()
6262

63+
# Log driver station data
64+
wpilib.DriverStation.startDataLog(self.data_log)
65+
6366
# Log deploy info to show in AdvantageScope.
6467
meta_table = ntcore.NetworkTableInstance.getDefault().getTable("Metadata")
6568
deploy_info = wpilib.deployinfo.getDeployData()

0 commit comments

Comments
 (0)