aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--calibrate.c2
-rw-r--r--include/libsurvive/poser.h1
-rwxr-xr-xsrc/survive_cal.c56
-rw-r--r--src/survive_cal.h3
-rw-r--r--src/survive_data.c10
-rw-r--r--src/survive_process.c3
7 files changed, 78 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index a642877..1899c4c 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,12 @@ LIBSURVIVE_CORE:=$(LIBSURVIVE_CORE)
LIBSURVIVE_O:=$(POSERS) $(REDISTS) $(LIBSURVIVE_CORE)
LIBSURVIVE_C:=$(LIBSURVIVE_O:.o=.c)
+
+#If you want to use HIDAPI on Linux.
+#CFLAGS:=$(CFLAGS) -DHIDAPI
+#REDISTS:=$(REDISTS) redist/hid-linux.o
+#LDFLAGS:=$(LDFLAGS) -ludev
+
#Useful Preprocessor Directives:
# -DUSE_DOUBLE = use double instead of float for most operations.
# -DNOZLIB = use puff.c
diff --git a/calibrate.c b/calibrate.c
index 726a8cc..f27131a 100644
--- a/calibrate.c
+++ b/calibrate.c
@@ -56,7 +56,7 @@ void my_light_process( struct SurviveObject * so, int sensor_id, int acode, int
// if( timeinsweep < 0 ) return;
survive_default_light_process( so, sensor_id, acode, timeinsweep, timecode, length );
if( sensor_id < 0 ) return;
- if( acode == -1 ) return;
+ if( acode < 0 ) return;
//return;
int jumpoffset = sensor_id;
if( strcmp( so->codename, "WM0" ) == 0 ) jumpoffset += 32;
diff --git a/include/libsurvive/poser.h b/include/libsurvive/poser.h
index 98c926e..cf11e0c 100644
--- a/include/libsurvive/poser.h
+++ b/include/libsurvive/poser.h
@@ -45,6 +45,7 @@ typedef struct
//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 (Angles in LH space)
+ FLT synctimes[SENSORS_PER_OBJECT][NUM_LIGHTHOUSES];
PoserDataIMU lastimu;
} PoserDataFullScene;
diff --git a/src/survive_cal.c b/src/survive_cal.c
index 9dc3af2..04931cc 100755
--- a/src/survive_cal.c
+++ b/src/survive_cal.c
@@ -196,6 +196,21 @@ void survive_cal_light( struct SurviveObject * so, int sensor_id, int acode, int
if( i == NUM_LIGHTHOUSES ) cd->stage = 2; //If all lighthouses have their OOTX set, move on.
}
break;
+ case 3: //Look for light sync lengths.
+ {
+ if( acode >= -2 ) break;
+ else if( acode < -4 ) break;
+ int lh = (-acode) - 3;
+
+ if( strcmp( so->codename, "WM0" ) == 0 )
+ sensor_id += 32;
+ if( strcmp( so->codename, "WM1" ) == 0 )
+ sensor_id += 64;
+
+ cd->all_sync_times[sensor_id][lh][cd->all_sync_counts[sensor_id][lh]++] = length;
+ break;
+ }
+
}
}
@@ -333,6 +348,8 @@ static void reset_calibration( struct SurviveCalData * cd )
cd->found_common = 0;
cd->times_found_common = 0;
cd->stage = 2;
+
+ memset( cd->all_sync_counts, 0, sizeof( cd->all_sync_counts ) );
}
static void handle_calibration( struct SurviveCalData *cd )
@@ -358,9 +375,45 @@ static void handle_calibration( struct SurviveCalData *cd )
#else
mkdir( "calinfo", 0755 );
#endif
+ int sen, axis, lh;
+ FLT temp_syncs[SENSORS_PER_OBJECT][NUM_LIGHTHOUSES];
+
+ //Just to get it out of the way early, we'll calculate the sync-pulse-lengths here.
+ FILE * sync_time_info = fopen( "calinfo/synctime.csv", "w" );
+
+ for( sen = 0; sen < MAX_SENSORS_TO_CAL; sen++ )
+ for( lh = 0; lh < NUM_LIGHTHOUSES; lh++ )
+ {
+ int count = cd->all_sync_counts[sen][lh];
+ int i;
+ double totaltime;
+
+ totaltime = 0;
+
+ if( count < 20 ) continue;
+ for( i = 0; i < count; i++ )
+ {
+ totaltime += cd->all_sync_times[sen][lh][i];
+ }
+ FLT avg = totaltime/count;
+
+ double stddev = 0.0;
+ for( i = 0; i < count; i++ )
+ {
+ stddev += (cd->all_sync_times[sen][lh][i] - avg)*(cd->all_sync_times[sen][lh][i] - avg);
+ }
+ stddev /= count;
+
+ fprintf( sync_time_info, "%d %d %f %d %f\n", sen, lh, totaltime/count, count, stddev );
+ }
+
+ fclose( sync_time_info );
+
+
+
+
FILE * hists = fopen( "calinfo/histograms.csv", "w" );
FILE * ptinfo = fopen( "calinfo/ptinfo.csv", "w" );
- int sen, axis, lh;
for( sen = 0; sen < MAX_SENSORS_TO_CAL; sen++ )
for( lh = 0; lh < NUM_LIGHTHOUSES; lh++ )
for( axis = 0; axis < 2; axis++ )
@@ -526,6 +579,7 @@ static void handle_calibration( struct SurviveCalData *cd )
fsd.lengths[i][j][1] = cd->avglens[dataindex+1];
fsd.angles[i][j][0] = cd->avgsweeps[dataindex+0];
fsd.angles[i][j][1] = cd->avgsweeps[dataindex+1];
+ fsd.synctimes[i][j] = temp_syncs[i][j];
}
int r = cd->ConfigPoserFn( cd->poseobjects[obj], (PoserData*)&fsd );
diff --git a/src/survive_cal.h b/src/survive_cal.h
index 701dc60..c64b8f9 100644
--- a/src/survive_cal.h
+++ b/src/survive_cal.h
@@ -56,6 +56,9 @@ struct SurviveCalData
int8_t found_common;
int8_t times_found_common;
+ FLT all_sync_times[MAX_SENSORS_TO_CAL][NUM_LIGHTHOUSES][DRPTS];
+ int16_t all_sync_counts[MAX_SENSORS_TO_CAL][NUM_LIGHTHOUSES];
+
//For camfind (4+)
//Index is calculated with: int dataindex = sen*(2*NUM_LIGHTHOUSES)+lh*2+axis;
FLT avgsweeps[MAX_CAL_PT_DAT];
diff --git a/src/survive_data.c b/src/survive_data.c
index ffeacff..8c5c646 100644
--- a/src/survive_data.c
+++ b/src/survive_data.c
@@ -69,7 +69,7 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le )
{
int is_new_pulse = delta > so->pulselength_min_sync /*1500*/ + last_sync_length;
- //printf("m sync %d %d %d %d\n", le->sensor_id, so->last_sync_time[ssn], le->timestamp, delta);
+
so->did_handle_ootx = 0;
@@ -114,6 +114,14 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le )
}
}
}
+
+ //Extra tidbit for storing length-of-sync-pulses.
+ {
+ int32_t main_divisor = so->timebase_hz / 384000; //125 @ 48 MHz.
+ int base_station = is_new_pulse;
+ printf( "%s %d %d %d\n", so->codename, le->sensor_id, so->sync_set_number, le->length );
+ ctx->lightproc( so, le->sensor_id, -3 - so->sync_set_number, 0, le->timestamp, le->length );
+ }
}
diff --git a/src/survive_process.c b/src/survive_process.c
index 8dc849a..9295638 100644
--- a/src/survive_process.c
+++ b/src/survive_process.c
@@ -16,6 +16,9 @@ void survive_default_light_process( SurviveObject * so, int sensor_id, int acode
survive_cal_light( so, sensor_id, acode, timeinsweep, timecode, length );
}
+ //We don't use sync times, yet.
+ if( acode < -1 ) return;
+
if( base_station > NUM_LIGHTHOUSES ) return;
//No loner need sync information past this point.