aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2017-03-03 02:15:04 -0500
committercnlohr <lohr85@gmail.com>2017-03-03 02:15:04 -0500
commit58b19da6848e64c9ca7aa47d8b3e0cd30db89d44 (patch)
treeae22943ea2072a92a50dc4524886d91341c52977
parentb5ff8e57a6bd86931f00465f8009626dcd36d94d (diff)
downloadlibsurvive-58b19da6848e64c9ca7aa47d8b3e0cd30db89d44.tar.gz
libsurvive-58b19da6848e64c9ca7aa47d8b3e0cd30db89d44.tar.bz2
Split out into some more things in the include folder. Getting closer to trying to have posers.
-rw-r--r--Makefile2
-rw-r--r--include/libsurvive/poser.h54
-rw-r--r--include/libsurvive/survive.h (renamed from include/survive.h)31
-rw-r--r--include/libsurvive/survive_types.h29
-rw-r--r--src/survive_internal.h2
5 files changed, 88 insertions, 30 deletions
diff --git a/Makefile b/Makefile
index 75b5606..470cbe3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
all : lib data_recorder test calibrate calibrate_client
-CFLAGS:=-Iinclude -I. -fPIC -g -O0 -Iredist -flto -DUSE_DOUBLE -std=gnu99
+CFLAGS:=-Iinclude/libsurvive -I. -fPIC -g -O0 -Iredist -flto -DUSE_DOUBLE -std=gnu99
LDFLAGS:=-lpthread -lusb-1.0 -lz -lX11 -lm -flto -g
diff --git a/include/libsurvive/poser.h b/include/libsurvive/poser.h
new file mode 100644
index 0000000..4894acf
--- /dev/null
+++ b/include/libsurvive/poser.h
@@ -0,0 +1,54 @@
+#ifndef _LSPOSER_H
+#define _LSPOSER_H
+
+#include "survive_types.h"
+
+typedef enum PoserType_t
+{
+ POSERDATA_NONE = 0,
+ POSERDATA_IMU,
+ POSERDATA_LIGHT, //Single lighting event.
+ POSERDATA_FULL_SCENE, //Full, statified X, Y sweep data for both lighthouses.
+} PoserType;
+
+struct PoserData
+{
+ PoserType pt;
+ uint8_t data[0];
+};
+
+struct PoserDataIMU
+{
+ PoserType pt;
+ uint8_t datamask; //0 = accel present, 1 = gyro present, 2 = mag present.
+ FLT accel[3];
+ FLT gyro[3];
+ FLT mag[3];
+};
+
+struct PoserDataLight
+{
+ PoserType pt;
+ int sensor_id;
+ int acode; //OOTX Code associated with this sweep. base_station = acode >> 2; axis = acode & 1;
+ uint32_t timecode; //In object-local ticks.
+ FLT length; //In seconds
+ FLT angle; //In radians from center of lighthouse.
+};
+
+struct PoserDataFullScene
+{
+ PoserType pt;
+
+ //If "lengths[...]" < 0, means not a valid piece of sweep information.
+ FLT lengths[SENSORS_PER_OBJECT][NUM_LIGHTHOUSES][2];
+ FLT angles [SENSORS_PER_OBJECT][NUM_LIGHTHOUSES][2]; //2 Axes
+
+ struct PoserDataIMU lastimu;
+};
+
+//When you register your posers using the internal system,
+typedef int (*PoserCB)( struct SurviveObject * so, struct PoserData * pd );
+
+
+#endif
diff --git a/include/survive.h b/include/libsurvive/survive.h
index 0d43465..536c7fb 100644
--- a/include/survive.h
+++ b/include/libsurvive/survive.h
@@ -2,29 +2,13 @@
#define _SURVIVE_H
#include <stdint.h>
-
-#ifndef FLT
-#ifdef USE_DOUBLE
-#define FLT double
-#else
-#define FLT float
-#endif
-#endif
+#include "poser.h"
struct SurviveContext;
//DANGER: This structure may be redefined. Note that it is logically split into 64-bit chunks
//for optimization on 32- and 64-bit systems.
-//Careful with this, you can't just add another one right now, would take minor changes in survive_data.c and the cal tools.
-//It will also require a recompile. TODO: revisit this and correct the comment once fixed.
-#define NUM_LIGHTHOUSES 2
-
-struct SurviveObject;
-
-//XXX TODO -> Probably should be one function to take multiple types of input?
-typedef int (*ResolverCB)( struct SurviveObject * so );
-
struct SurviveObject
{
struct SurviveContext * ctx;
@@ -45,9 +29,10 @@ struct SurviveObject
FLT PoseConfidence; //0..1
FLT Position[3];
FLT Rotation[4];
- void * Resolver;
- ResolverCB * PreferredResolverFn; //XXX TODO
+ void * PoserData; //Initialized to zero, configured by poser, can be anything the poser wants.
+ PoserCB * PoserFn;
+ //Device-specific information about the location of the sensors. This data will be used by the poser.
int8_t nr_locations;
FLT * sensor_locations;
FLT * sensor_normals;
@@ -77,14 +62,6 @@ struct SurviveObject
int tsl;
};
-
-
-
-typedef void (*text_feedback_func)( struct SurviveContext * ctx, const char * fault );
-typedef void (*light_process_func)( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length );
-typedef void (*imu_process_func)( struct SurviveObject * so, int16_t * accelgyro, uint32_t timecode, int id );
-typedef void (*angle_process_func)( struct SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle );
-
struct SurviveContext * survive_init( int headless );
//For any of these, you may pass in 0 for the function pointer to use default behavior.
diff --git a/include/libsurvive/survive_types.h b/include/libsurvive/survive_types.h
new file mode 100644
index 0000000..593819f
--- /dev/null
+++ b/include/libsurvive/survive_types.h
@@ -0,0 +1,29 @@
+#ifndef _SURVIVE_TYPES_H
+#define _SURVIVE_TYPES_H
+
+#ifndef FLT
+#ifdef USE_DOUBLE
+#define FLT double
+#else
+#define FLT float
+#endif
+#endif
+
+
+//Careful with this, you can't just add another one right now, would take minor changes in survive_data.c and the cal tools.
+//It will also require a recompile. TODO: revisit this and correct the comment once fixed.
+#define NUM_LIGHTHOUSES 2
+
+#define INTBUFFSIZE 64
+#define SENSORS_PER_OBJECT 32
+
+struct SurviveObject;
+struct SurviveContext;
+
+typedef void (*text_feedback_func)( struct SurviveContext * ctx, const char * fault );
+typedef void (*light_process_func)( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length );
+typedef void (*imu_process_func)( struct SurviveObject * so, int16_t * accelgyro, uint32_t timecode, int id );
+typedef void (*angle_process_func)( struct SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle );
+
+#endif
+
diff --git a/src/survive_internal.h b/src/survive_internal.h
index 1fdef41..9d04d93 100644
--- a/src/survive_internal.h
+++ b/src/survive_internal.h
@@ -27,8 +27,6 @@
//XXX TODO This one needs to be rewritten.
#define SV_KILL() exit(0)
-#define INTBUFFSIZE 64
-#define SENSORS_PER_OBJECT 32
struct SurviveContext;
struct SurviveUSBInterface;