From 0d286eef9634116828ead278f9534f04ecbb6ecd Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 11 Mar 2017 16:36:28 -0500 Subject: Update a few files... need to get working with linmath. But first switching accounts. --- Makefile | 25 ++++++++++++++++--------- include/libsurvive/survive.h | 2 +- redist/linmath.h | 6 +++++- redist/lintest.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/survive_data.c | 2 +- 5 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 redist/lintest.c diff --git a/Makefile b/Makefile index 1a1712d..ec5d39b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ all : lib data_recorder test calibrate calibrate_client +CC:=gcc + CFLAGS:=-Iinclude/libsurvive -I. -fPIC -g -O0 -Iredist -flto -DUSE_DOUBLE -std=gnu99 LDFLAGS:=-lpthread -lusb-1.0 -lz -lX11 -lm -flto -g @@ -8,28 +10,33 @@ POSERS:=src/poser_dummy.o REDISTS:=redist/json_helpers.o redist/linmath.o redist/jsmn.o LIBSURVIVE_CORE:=src/survive.o src/survive_usb.o src/survive_data.o src/survive_process.o src/ootx_decoder.o src/survive_driverman.o src/survive_vive.o src/survive_config.o LIBSURVIVE_O:=$(CALS) $(POSERS) $(REDISTS) $(LIBSURVIVE_CORE) +LIBSURVIVE_C:=$(LIBSURVIVE_O:.o=.c) GRAPHICS_LOFI:=redist/DrawFunctions.o redist/XDriver.o # unused: redist/crc32.c -test : test.c lib/libsurvive.so redist/os_generic.o - gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) +test : test.c ./lib/libsurvive.so redist/os_generic.o + $(CC) -o $@ $^ $(LDFLAGS) $(CFLAGS) + +data_recorder : data_recorder.c ./lib/libsurvive.so redist/os_generic.c $(GRAPHICS_LOFI) + $(CC) -o $@ $^ $(LDFLAGS) $(CFLAGS) -data_recorder : data_recorder.c lib/libsurvive.so redist/os_generic.c $(GRAPHICS_LOFI) - gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) +calibrate : calibrate.c ./lib/libsurvive.so redist/os_generic.c $(GRAPHICS_LOFI) + $(CC) -o $@ $^ $(LDFLAGS) $(CFLAGS) -calibrate : calibrate.c lib/libsurvive.so redist/os_generic.c $(GRAPHICS_LOFI) - gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) +calibrate_client : calibrate_client.c ./lib/libsurvive.so redist/os_generic.c $(GRAPHICS_LOFI) + $(CC) -o $@ $^ $(LDFLAGS) $(CFLAGS) -calibrate_client : calibrate_client.c lib/libsurvive.so redist/os_generic.c $(GRAPHICS_LOFI) - gcc -o $@ $^ $(LDFLAGS) $(CFLAGS) +## Still not working!!! Don't use. +static_calibrate : calibrate.c redist/os_generic.c redist/XDriver.c redist/DrawFunctions.c $(LIBSURVIVE_C) + tcc -o $@ $^ $(CFLAGS) $(LDFLAGS) -DTCC lib: mkdir lib lib/libsurvive.so : $(LIBSURVIVE_O) - gcc -o $@ $^ $(LDFLAGS) -shared + $(CC) -o $@ $^ $(LDFLAGS) -shared clean : rm -rf *.o src/*.o *~ src/*~ test data_recorder lib/libsurvive.so redist/*.o redist/*~ diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 03249e9..b349ff1 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -140,7 +140,7 @@ void survive_default_angle_process( SurviveObject * so, int sensor_id, int acode void RegisterDriver( const char * name, void * data ); #define REGISTER_LINKTIME( func ) \ - void __attribute__((constructor)) Register##func() { RegisterDriver( #func, &func ); } + void __attribute__((constructor)) LTRegister##func() { RegisterDriver( #func, &func ); } diff --git a/redist/linmath.h b/redist/linmath.h index 676d182..a58b2bf 100644 --- a/redist/linmath.h +++ b/redist/linmath.h @@ -89,9 +89,13 @@ void quatevenproduct( FLT * q, FLT * qa, FLT * qb ); void quatoddproduct( FLT * outvec3, FLT * qa, FLT * qb ); void quatslerp( FLT * q, const FLT * qa, const FLT * qb, FLT t ); void quatrotatevector( FLT * vec3out, const FLT * quat, const FLT * vec3in ); - void quatfrom2vectors(FLT *q, const FLT *src, const FLT *dest); +//Poses are Position: [x, y, z] Quaternion: [q, x, y, z] +void ApplyPoseToPoint( FLT * pout, const FLT * pin, const FLT * pose ); +void InvertPose( FLT * poseout, const FLT * pose ); + + // Matrix Stuff typedef struct diff --git a/redist/lintest.c b/redist/lintest.c new file mode 100644 index 0000000..0a268ff --- /dev/null +++ b/redist/lintest.c @@ -0,0 +1,41 @@ +#include "linmath.h" +#include + +int main() +{ + + FLT e[3] = { 1,1,3.14 }; + FLT q[4]; + FLT m[16]; + + quatfromeuler( q, e ); + printf( "%f %f %f %f\n\n", PFFOUR( q ) ); + quattomatrix(m,q); + printf( "%f %f %f %f\n", PFFOUR( &m[0] ) ); + printf( "%f %f %f %f\n", PFFOUR( &m[4] ) ); + printf( "%f %f %f %f\n", PFFOUR( &m[8] ) ); + printf( "%f %f %f %f\n\n", PFFOUR( &m[12] ) ); + quatfrommatrix(q,m ); + printf( "%f %f %f %f\n\n", PFFOUR( q ) ); + quattoeuler( e,q ); + printf( "E: %f %f %f\n", e[0], e[1], e[2] ); + + + FLT p[3] = { 0, 0, 1 }; + printf( "%f %f %f\n", PFTHREE( p ) ); + quatrotatevector( p, q, p ); + printf( "%f %f %f\n", PFTHREE( p ) ); + printf( "Flipping rotation\n" ); + q[0] *= -1; //Wow that was easy. + quatrotatevector( p, q, p ); + printf( "%f %f %f\n", PFTHREE( p ) ); + + + //Try setting up a pose. + FLT mypose[7] = { 0, 0, 10, q[0], q[1], q[2], q[3] ); + ApplyPoseToPoint( FLT * pout, const FLT * pin, const FLT * pose ); +void InvertPose( FLT * poseout, const FLT * pose ); + + +} + diff --git a/src/survive_data.c b/src/survive_data.c index 63cc5c2..75edfb3 100644 --- a/src/survive_data.c +++ b/src/survive_data.c @@ -12,7 +12,7 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le ) //int32_t deltat = (uint32_t)le->timestamp - (uint32_t)so->last_master_time; //if( so->codename[0] != 'H' ) - //printf( "*** %s %d %d %d %d %d\n", so->codename, le->sensor_id, le->type, le->length, le->timestamp, le->timestamp-so->tsl ); + printf( "*** %s %d %d %d %d %d\n", so->codename, le->sensor_id, le->type, le->length, le->timestamp, le->timestamp-so->tsl ); if( le->sensor_id > SENSORS_PER_OBJECT ) { -- cgit v1.2.3