From 1ffadeda2fac023741c9a828714bb4ac29fcd815 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 12 Feb 2017 23:24:17 -0500 Subject: Working on closing #15 - still needs work. --- include/survive.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/survive.h b/include/survive.h index d29b487..7d461c7 100644 --- a/include/survive.h +++ b/include/survive.h @@ -35,7 +35,9 @@ struct SurviveObject #ifdef USE_OLD_DISAMBIGUATOR uint32_t last_master_time; uint32_t last_slave_time; - int32_t last_photo_length; + int16_t last_master_length; + int16_t last_slave_length; + int8_t is_on_slave; #else uint32_t last_master_time; struct disambiguator * d; -- cgit v1.2.3 From ff7167fb8afff6633db422290864e5da302d9afb Mon Sep 17 00:00:00 2001 From: cnlohr Date: Mon, 13 Feb 2017 01:16:05 -0500 Subject: Update disambiguator. I think I got it right this time, finally. Also, seems to output OOTX data pretty good. --- include/survive.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/survive.h b/include/survive.h index 7d461c7..d2f5bfe 100644 --- a/include/survive.h +++ b/include/survive.h @@ -32,16 +32,11 @@ struct SurviveObject //Flood info, for calculating which laser is currently sweeping. int8_t oldcode; - #ifdef USE_OLD_DISAMBIGUATOR - uint32_t last_master_time; - uint32_t last_slave_time; - int16_t last_master_length; - int16_t last_slave_length; - int8_t is_on_slave; - #else - uint32_t last_master_time; - struct disambiguator * d; - #endif + uint32_t last_time[2]; //0 = master, 1 = slave. Hardcoded, because it cannot simply be expanded. + uint32_t last_length[2]; + int8_t sync_set_number; //0 = master, 1 = slave, -1 = fault. Possibly more lighthouses??? + int8_t did_handle_ootx; + uint32_t recent_sync_time; uint32_t last_lighttime; //May be a 24- or 32- bit number depending on what device. -- cgit v1.2.3 From 35e08aaa24bd01e6ace453f89ddb73a6bb0508b0 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Tue, 14 Feb 2017 01:00:33 -0500 Subject: Still not working, but getting closer to dynamic OOTX decoding. --- include/survive.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/survive.h b/include/survive.h index d2f5bfe..4a95a2f 100644 --- a/include/survive.h +++ b/include/survive.h @@ -10,6 +10,12 @@ 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 { struct SurviveContext * ctx; @@ -32,10 +38,10 @@ struct SurviveObject //Flood info, for calculating which laser is currently sweeping. int8_t oldcode; - uint32_t last_time[2]; //0 = master, 1 = slave. Hardcoded, because it cannot simply be expanded. - uint32_t last_length[2]; - int8_t sync_set_number; //0 = master, 1 = slave, -1 = fault. Possibly more lighthouses??? - int8_t did_handle_ootx; + uint32_t last_time[NUM_LIGHTHOUSES]; + uint32_t last_length[NUM_LIGHTHOUSES]; + int8_t sync_set_number; //0 = master, 1 = slave, -1 = fault. + int8_t did_handle_ootx; //If unset, will send lightcap data for sync pulses next time a sensor is hit. uint32_t recent_sync_time; uint32_t last_lighttime; //May be a 24- or 32- bit number depending on what device. @@ -64,8 +70,15 @@ struct SurviveObject * survive_get_so_by_name( struct SurviveContext * ctx, cons //Utilitiy functions. int survive_simple_inflate( struct SurviveContext * ctx, const char * input, int inlen, char * output, int outlen ); -//TODO: Need to make this do haptic responses for hands. +//TODO: Need to make this do haptic responses for hands. int survive_usb_send_magic( struct SurviveContext * ctx, int on ); +//Install the calibrator. +void survive_cal_install( struct SurviveContext * ctx ); + +//Call these from your callback if overridden. +void survive_default_light_process( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length ); +void survive_default_imu_process( struct SurviveObject * so, int16_t * accelgyro, uint32_t timecode, int id ); + #endif -- cgit v1.2.3 From 32fbccbd7d90f1e456d1e477eab2128aaf88df93 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Thu, 16 Feb 2017 17:16:31 -0500 Subject: Move to having an angle callback. --- include/survive.h | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/survive.h b/include/survive.h index 4a95a2f..3e8dc35 100644 --- a/include/survive.h +++ b/include/survive.h @@ -3,19 +3,19 @@ #include -#define SV_FLOAT double +#ifndef FLT +#define FLT double +#endif 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 { struct SurviveContext * ctx; @@ -31,17 +31,26 @@ struct SurviveObject int8_t ison:1; int8_t additional_flags:6; - SV_FLOAT * sensor_locations; - SV_FLOAT * sensor_normals; + FLT * sensor_locations; + FLT * sensor_normals; + + //Timing sensitive data (mostly for disambiguation) + int32_t timebase_hz; //48,000,000 for normal vive hardware. (checked) + int32_t timecenter_ticks; //200,000 for normal vive hardware. (checked) + int32_t pulsedist_max_ticks; //500,000 for normal vive hardware. (guessed) + int32_t pulselength_min_sync; //2,200 for normal vive hardware. (guessed) + int32_t pulse_in_clear_time; //35,000 for normal vive hardware. (guessed) + int32_t pulse_max_for_sweep; //1,800 for normal vive hardware. (guessed) + int32_t pulse_synctime_offset; //20,000 for normal vive hardware. (guessed) + int32_t pulse_synctime_slack; //5,000 for normal vive hardware. (guessed) int8_t nr_locations; //Flood info, for calculating which laser is currently sweeping. int8_t oldcode; - - uint32_t last_time[NUM_LIGHTHOUSES]; - uint32_t last_length[NUM_LIGHTHOUSES]; int8_t sync_set_number; //0 = master, 1 = slave, -1 = fault. int8_t did_handle_ootx; //If unset, will send lightcap data for sync pulses next time a sensor is hit. + uint32_t last_time[NUM_LIGHTHOUSES]; + uint32_t last_length[NUM_LIGHTHOUSES]; uint32_t recent_sync_time; uint32_t last_lighttime; //May be a 24- or 32- bit number depending on what device. @@ -50,17 +59,19 @@ struct SurviveObject int tsl; }; -typedef void (*text_feedback_fnptr)( struct SurviveContext * ctx, const char * fault ); +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(); //For any of these, you may pass in 0 for the function pointer to use default behavior. -void survive_install_info_fn( struct SurviveContext * ctx, text_feedback_fnptr fbp ); -void survive_install_error_fn( struct SurviveContext * ctx, text_feedback_fnptr fbp ); +void survive_install_info_fn( struct SurviveContext * ctx, text_feedback_func fbp ); +void survive_install_error_fn( struct SurviveContext * ctx, text_feedback_func fbp ); void survive_install_light_fn( struct SurviveContext * ctx, light_process_func fbp ); void survive_install_imu_fn( struct SurviveContext * ctx, imu_process_func fbp ); +void survive_install_angle_fn( struct SurviveContext * ctx, angle_process_func fbp ); void survive_close( struct SurviveContext * ctx ); int survive_poll(); @@ -77,8 +88,11 @@ int survive_usb_send_magic( struct SurviveContext * ctx, int on ); void survive_cal_install( struct SurviveContext * ctx ); //Call these from your callback if overridden. -void survive_default_light_process( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length ); +//Accept higher-level data. +void survive_default_light_process( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length ); void survive_default_imu_process( struct SurviveObject * so, int16_t * accelgyro, uint32_t timecode, int id ); +void survive_default_angle_process( struct SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle ); + #endif -- cgit v1.2.3