Skip to content

Commit 350057a

Browse files
committed
FicTrac changed number of output fields.
Fixed fictrac state structure to have additional field.
1 parent 5914955 commit 350057a

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

pybmt/fictrac/state.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import numpy as np
22
import ctypes
33

4-
# The number of FicTrac fields in the output file
5-
NUM_FICTRAC_FIELDS = 23
6-
74
class FicTracState(ctypes.Structure):
85
"""
96
This class represents the FicTrac tracking state. These are the exact same values written to the output log file
@@ -26,6 +23,7 @@ class FicTracState(ctypes.Structure):
2623
('inty', ctypes.c_double),
2724
('timestamp', ctypes.c_double),
2825
('seq_num', ctypes.c_int),
26+
('delta_timestamp', ctypes.c_double),
2927
]
3028

3129
@classmethod
@@ -38,13 +36,16 @@ def zmq_string_msg_to_state(cls, data):
3836
:return: The FicTracState structure with values corresponding to data.
3937
"""
4038

39+
# The number of FicTrac fields in the output file
40+
num_fictrac_fields = 24
41+
4142
# Create a FicTrac state object\structure
4243
fstate = cls()
4344

4445
# Parse the string
4546
values = [x.strip() for x in data.split(',')]
4647

47-
if len(values) != NUM_FICTRAC_FIELDS:
48+
if len(values) != num_fictrac_fields:
4849
raise ValueError("Message from FicTrac did not have appropriate number of fields.")
4950

5051
# Convert strings to appropriate types and assign fields
@@ -93,7 +94,8 @@ def to_np_array(self):
9394
self.intx,
9495
self.inty,
9596
self.timestamp,
96-
self.seq_num
97+
self.seq_num,
98+
self.delta_timestamp
9799
])
98100

99101
def __repr__(self):

tests/fictrac/test_config_data/test_config_local.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## FicTrac config file (build Nov 2 2018)
1+
## FicTrac config file (build Nov 21 2019)
22
c2a_cnrs_yz : { 304, 37, 293, 37, 293, 48, 304, 48 }
33
c2a_r : { -1.209684, 1.208704, 1.208508 }
44
c2a_src : c2a_cnrs_yz
@@ -17,11 +17,10 @@ roi_circ : { 82, 162, 97, 118, 131, 81, 289, 94, 324, 162 }
1717
roi_ignr : { { 46, 186, 358, 192, 364, 286, 44, 284 }, { 193, 125, 205, 120, 224, 127, 234, 134, 237, 154, 229, 170, 209, 173, 189, 170, 184, 155, 181, 141 } }
1818
roi_r : 0.022890
1919
save_debug : n
20-
save_raw : 0
20+
save_raw : n
2121
socket_port : 5556
2222
src_fn : test.mp4
2323
src_fps : -1.000000
2424
thr_ratio : 1.25
2525
thr_win_pc : 0.25
2626
vfov : 3.085
27-

tests/fictrac/test_state.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pybmt.fictrac.state import FicTracState
66

77
# A test message that is exactly formatted like fictrac's state messages
8-
test_msg = "1, 0.00061658055072047, 0.00049280924124894, 0.00028854775028054, 4383.0244305051, -0.00049229297796647, 0.00028846777828354, -0.00061703022026165, 0.0053108667004006, -0.0013475230246914, 0.00028682299296761, -1.2046443372631, 1.2104273986131, 1.2054460682211, 0.00028831588044736, 0.00049238194388207, 0.00061703022026165, 1.0407586027826, 0.00057058394234585, 0.00028846777828354, 0.00049229297796647, 20, 1"
8+
test_msg = "1, 0.00061658055072047, 0.00049280924124894, 0.00028854775028054, 4383.0244305051, -0.00049229297796647, 0.00028846777828354, -0.00061703022026165, 0.0053108667004006, -0.0013475230246914, 0.00028682299296761, -1.2046443372631, 1.2104273986131, 1.2054460682211, 0.00028831588044736, 0.00049238194388207, 0.00061703022026165, 1.0407586027826, 0.00057058394234585, 0.00028846777828354, 0.00049229297796647, 20, 1, 0.0000234"
99

1010
# The values of the message.
1111
test_values = np.array([1, 0.00061658055072047, 0.00049280924124894, 0.00028854775028054,
@@ -14,7 +14,7 @@
1414
0.00028682299296761, -1.2046443372631, 1.2104273986131, 1.2054460682211,
1515
0.00028831588044736, 0.00049238194388207, 0.00061703022026165,
1616
1.0407586027826, 0.00057058394234585, 0.00028846777828354, 0.00049229297796647,
17-
20, 1])
17+
20, 1, 0.0000234])
1818

1919
# Create a state from the above message
2020
fstate = FicTracState.zmq_string_msg_to_state(test_msg)

0 commit comments

Comments
 (0)