From 795766ab15131b5de9b752501ae7bb5d4ebe58fa Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Thu, 14 Sep 2023 01:10:28 -0400 Subject: Faster (global var sampling, not reactive) metrics --- virtual-programs/apriltags.folk | 4 +++- virtual-programs/archive/metrics.folk | 8 ++++---- virtual-programs/camera.folk | 4 ++++ virtual-programs/display.folk | 7 +++---- 4 files changed, 14 insertions(+), 9 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/apriltags.folk b/virtual-programs/apriltags.folk index ac2c4f8b..8bdd415a 100644 --- a/virtual-programs/apriltags.folk +++ b/virtual-programs/apriltags.folk @@ -114,6 +114,7 @@ On process { set ::tagsCache [dict create] # TODO: Garbage-collect this cache. +set ::aprilTime none When the collected matches for [list /someone/ detects tags /tags/ at /timestamp/ in time /aprilTime/] are /matches/ { set tagsSeen [dict create] foreach match $matches { @@ -136,5 +137,6 @@ When the collected matches for [list /someone/ detects tags /tags/ at /timestamp Claim tag $id has center [dict get $tag center] size [dict get $tag size] Claim tag $id has corners [dict get $tag corners] } - Claim the AprilTag time is [lmap m $matches {dict get $m aprilTime}] + set ::aprilTime [lmap m $matches {dict get $m aprilTime}] + Claim the AprilTag time is $::aprilTime } diff --git a/virtual-programs/archive/metrics.folk b/virtual-programs/archive/metrics.folk index fe6baebd..e5389512 100644 --- a/virtual-programs/archive/metrics.folk +++ b/virtual-programs/archive/metrics.folk @@ -1,13 +1,13 @@ -When $::thisNode has step count /c/ & the camera time is /cameraTime/ & the AprilTag time is /aprilTime/ { +When $::thisNode has step count /c/ { Wish $this is labelled [string trim " Metrics ---- step count: $c step time: $::stepTime -camera time: $cameraTime -AprilTag time: $aprilTime -display time: $::Display::displayTime +camera time: $::cameraTime +AprilTag time: $::aprilTime +display time: $::displayTime "] } diff --git a/virtual-programs/camera.folk b/virtual-programs/camera.folk index 0a95c8f0..428c4195 100644 --- a/virtual-programs/camera.folk +++ b/virtual-programs/camera.folk @@ -29,6 +29,10 @@ On process { } } +set ::cameraTime none +When the camera time is /cameraTime/ { + set ::cameraTime $cameraTime +} # For backward compatibility. When the camera frame is /grayFrame/ at /timestamp/ { Claim the camera frame is $grayFrame diff --git a/virtual-programs/display.folk b/virtual-programs/display.folk index d3f6b610..75ad5cf1 100644 --- a/virtual-programs/display.folk +++ b/virtual-programs/display.folk @@ -35,8 +35,6 @@ namespace eval ::Display { proc fillPolygon args { uplevel [list Wish display runs [list Display::fillPolygon {*}$args] on layer $::Display::LAYER] } - - variable displayTime none } On process { @@ -87,7 +85,8 @@ On process { Step } } -# TODO: remove this compatibility hack + +set ::displayTime none When the display time is /displayTime/ { - set ::Display::displayTime $displayTime + set ::displayTime $displayTime } -- cgit v1.2.3 From f9d232657dab54bc990570fff9a08a377303d8da Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Thu, 14 Sep 2023 15:43:40 -0400 Subject: Fix metrics backward compat --- virtual-programs/display.folk | 2 ++ 1 file changed, 2 insertions(+) (limited to 'virtual-programs') diff --git a/virtual-programs/display.folk b/virtual-programs/display.folk index 75ad5cf1..674cf1f7 100644 --- a/virtual-programs/display.folk +++ b/virtual-programs/display.folk @@ -86,7 +86,9 @@ On process { } } +set ::Display::displayTime none set ::displayTime none When the display time is /displayTime/ { + set ::Display::displayTime $displayTime set ::displayTime $displayTime } -- cgit v1.2.3