Skip to content

Commit a4503b6

Browse files
committed
feat: adding a fuzzy equals check in SpikeGLX API
1 parent 3f195ad commit a4503b6

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

Assets/Scripts/API/APISpikeGLX.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@
1212

1313
public class APISpikeGLX : MonoBehaviour
1414
{
15+
private const float FUZZY_DISTANCE = 0.01f;
16+
1517
[SerializeField] private TMP_InputField _helloSpikeGLXPathInput;
1618
private HashSet<Process> _processList;
19+
private Dictionary<ProbeManager, Vector3> _lastPositions;
1720

1821
#region Unity
1922

2023
private void Awake()
2124
{
2225
_processList = new HashSet<Process>();
26+
_lastPositions = new();
2327
}
2428

2529
private void OnEnable()
@@ -122,10 +126,28 @@ public void SendData()
122126
{
123127
if (probeManager.APITarget == null || probeManager.APITarget.Equals("None"))
124128
continue;
129+
130+
Vector3 pos = probeManager.ProbeController.Insertion.apmldv;
131+
132+
if (_lastPositions.ContainsKey(probeManager))
133+
{
134+
if (FuzzyEquals(pos, _lastPositions[probeManager]))
135+
continue;
136+
_lastPositions[probeManager] = pos;
137+
}
138+
else
139+
_lastPositions.Add(probeManager, pos);
140+
125141
SendProbeData(probeManager);
126142
}
127143
}
128144

145+
private bool FuzzyEquals(Vector3 a, Vector3 b)
146+
{
147+
Debug.Log(Vector3.Distance(a, b));
148+
return Vector3.Distance(a, b) < FUZZY_DISTANCE;
149+
}
150+
129151
public void PickHelloSGLXPath()
130152
{
131153
Debug.Log("Opening file browser");

Assets/Scripts/API/trajectoryplanner.api.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"GUID:160da71e82fca504abe6ab7833979cdb",
88
"GUID:70bb1e15c633f124aaefadd846c63184",
99
"GUID:5189d4f0178db074da4a316e98d9b3d3",
10-
"GUID:c685d05731421f64287ad6d13be5af0e"
10+
"GUID:c685d05731421f64287ad6d13be5af0e",
11+
"GUID:bcfae4c7cb9968e45808db945035df54"
1112
],
1213
"includePlatforms": [],
1314
"excludePlatforms": [],
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"Date": "11/29/2023 10:20:31 PM",
2+
"Date": "11/30/2023 3:46:50 PM",
33
"UnityVersion": "2022.3.12f1",
44
"com.unity.scriptablebuildpipeline": "1.21.20",
55
"com.unity.addressables": "1.21.18",
66
"traceEvents": [
7-
{"name": "Building Use Existing Build (requires built groups)", "ph": "X", "dur": 1420.8, "tid": 1, "ts": 1589, "pid": 1}
7+
{"name": "Building Use Existing Build (requires built groups)", "ph": "X", "dur": 4626.1, "tid": 1, "ts": 1758, "pid": 1}
88
]
99
}

ProjectSettings/ProjectSettings.asset

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ PlayerSettings:
137137
vulkanEnableCommandBufferRecycling: 1
138138
loadStoreDebugModeEnabled: 0
139139
bundleVersion: 1.0.3
140-
preloadedAssets: []
140+
preloadedAssets:
141+
- {fileID: 11400000, guid: 6057f25234ce83a4bbb3ae618a501907, type: 2}
141142
metroInputSource: 0
142143
wsaTransparentSwapchain: 0
143144
m_HolographicPauseOnTrackingLoss: 1

0 commit comments

Comments
 (0)