From e5cc00096e7b0700c75160c62f598a8af412c082 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Fri, 16 Mar 2018 10:39:26 -0600 Subject: Refactored how the persistence (now called sensor_activations) worked --- include/libsurvive/poser.h | 3 +-- include/libsurvive/survive.h | 34 ++++++++++++++++++++++++++++++++-- include/libsurvive/survive_types.h | 2 ++ 3 files changed, 35 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/libsurvive/poser.h b/include/libsurvive/poser.h index eb0de3b..6c74c52 100644 --- a/include/libsurvive/poser.h +++ b/include/libsurvive/poser.h @@ -41,8 +41,7 @@ typedef struct uint32_t timecode; //In object-local ticks. } PoserDataIMU; -typedef struct -{ +typedef struct PoserDataLight { PoserData hdr; int sensor_id; int acode; //OOTX Code associated with this sweep. bit 1 indicates vertical(1) or horizontal(0) sweep diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 7a0ed1e..7a9ec64 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -1,14 +1,43 @@ #ifndef _SURVIVE_H #define _SURVIVE_H -#include -#include "survive_types.h" #include "poser.h" +#include "survive_types.h" +#include +#include #ifdef __cplusplus extern "C" { #endif +/** + * This struct encodes what the last effective angles seen on a sensor were, and when they occured. + */ +typedef struct { + FLT angles[SENSORS_PER_OBJECT][NUM_LIGHTHOUSES][2]; // 2 Axes (Angles in LH space) + uint32_t timecode[SENSORS_PER_OBJECT][NUM_LIGHTHOUSES][2]; // Timecode per axis in ticks +} SurviveSensorActivations; + +struct PoserDataLight; +/** + * Adds a lightData packet to the table. + */ +void SurviveSensorActivations_add(SurviveSensorActivations *self, struct PoserDataLight *lightData); + +/** + * Returns true iff both angles for the given sensor and lighthouse were seen at most `tolerance` ticks before the given + * `timecode_now`. + */ +bool SurviveSensorActivations_isPairValid(const SurviveSensorActivations *self, uint32_t tolerance, + uint32_t timecode_now, uint32_t sensor_idx, int lh); + +/** + * Default tolerance that gives a somewhat accuate representation of current state. + * + * Don't rely on this to be a given value. + */ +extern uint32_t SurviveSensorActivations_default_tolerance; + //DANGER: This structure may be redefined. Note that it is logically split into 64-bit chunks //for optimization on 32- and 64-bit systems. @@ -70,6 +99,7 @@ struct SurviveObject haptic_func haptic; + SurviveSensorActivations activations; //Debug int tsl; }; diff --git a/include/libsurvive/survive_types.h b/include/libsurvive/survive_types.h index ce0baac..3c7dc7f 100644 --- a/include/libsurvive/survive_types.h +++ b/include/libsurvive/survive_types.h @@ -1,6 +1,8 @@ #ifndef _SURVIVE_TYPES_H #define _SURVIVE_TYPES_H +#include "stdint.h" + #ifdef __cplusplus extern "C" { #endif -- cgit v1.2.3