From 217adf4a3fd5621b6499195a882989b24d9ad615 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 23 Jun 2018 14:28:20 -0400 Subject: Fix my poser's use. --- src/poser_charlesrefine.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index b14d882..43558d6 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -55,9 +55,9 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { //TODO: Actually do Madgwick's algorithm LinmathQuat applymotion; const SurvivePose * object_pose = &so->OutPose; - imuData->gyro[0] *= 1./1000.; - imuData->gyro[1] *= 1./1000.; - imuData->gyro[2] *= 1./1000.; + imuData->gyro[0] *= 1./so->imu_freq; + imuData->gyro[1] *= 1./so->imu_freq; + imuData->gyro[2] *= 1./so->imu_freq; quatfromeuler( applymotion, imuData->gyro ); //printf( "%f %f %f\n", imuData->gyro [0], imuData->gyro [1], imuData->gyro [2] ); -- cgit v1.2.3 From b2151e0c8917258f5a9659296b6df5381645428e Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 23 Jun 2018 14:30:17 -0400 Subject: Remove extra reprojection info --- src/poser_charlesrefine.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index 43558d6..7cd27e3 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -421,6 +421,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { int l = 0, a = 0; if( lhid == 0 && axis == 0 ) for( l = 0; l < NUM_LIGHTHOUSES; l++ ) for( a = 0; a < 2; a++ ) dd->MixingConfidence[l][a] -= 0.1; +#if 0 for( l = 0; l < NUM_LIGHTHOUSES; l++ ) for( a = 0; a < 2; a++ ) { LinmathPoint3d MixThis = { 0, 0, 0 }; @@ -432,8 +433,8 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { //printf( "%f ", Confidence ); } scale3d( MixedPosition, MixedPosition, 1./MixedAmount ); - printf( "Reprojection disagreements:" ); +#endif for( l = 0; l < NUM_LIGHTHOUSES; l++ ) for( a = 0; a < 2; a++ ) { printf( "%f ", dist3d( dd->MixingPositions[l][a], MixedPosition ) ); -- cgit v1.2.3 From e21c1f96ad67015d7051eeeaf5e1e9183626922a Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 23 Jun 2018 16:28:35 -0400 Subject: Significant improvements to the CharlesRefine trcker, to consider confidence of tracking solution. --- src/poser_charlesrefine.c | 181 +++++++++++++++++++++++++++++++--------------- 1 file changed, 121 insertions(+), 60 deletions(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index 7cd27e3..1b392a3 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -20,7 +20,7 @@ typedef struct { int sweeplh; FLT normal_at_errors[MAX_PT_PER_SWEEP][3]; // Value is actually normalized, not just normal to sweep plane. - FLT quantity_errors[MAX_PT_PER_SWEEP]; + FLT quantity_errors[MAX_PT_PER_SWEEP]; //Dot product of error offset. FLT angles_at_pts[MAX_PT_PER_SWEEP]; SurvivePose object_pose_at_hit[MAX_PT_PER_SWEEP]; uint8_t sensor_ids[MAX_PT_PER_SWEEP]; @@ -32,6 +32,8 @@ typedef struct { int ptsweep; SurviveIMUTracker tracker; + + SurvivePose * lastlhp; } CharlesPoserData; int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { @@ -42,7 +44,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { SurvivePose object_pose_out; memcpy(&object_pose_out, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); memcpy(&dd->InteralPoseUsedForCalc, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); - so->PoseConfidence = 1.0; + so->PoseConfidence = 0.0; PoserData_poser_pose_func(pd, so, &object_pose_out); } @@ -103,7 +105,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { BaseStationData *bsd = &so->ctx->bsd[ld->lh]; if (!bsd->PositionSet) break; - SurvivePose *lhp = &bsd->Pose; + SurvivePose *lhp = dd->lastlhp = &bsd->Pose; FLT inangle = ld->angle; int sensor_id = ld->sensor_id; int axis = dd->sweepaxis; @@ -195,10 +197,11 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { case POSERDATA_SYNC: { PoserDataLight *l = (PoserDataLight *)pd; int lhid = l->lh; - // you can get sweepaxis and sweeplh. if (dd->ptsweep) { int i; + int applied_corrections = 0; + int normal_faults = 0; int lhid = dd->sweeplh; int axis = dd->sweepaxis; int pts = dd->ptsweep; @@ -224,6 +227,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { #define CORRECT_ROTATION_COEFFICIENT \ 0.2 // This starts to fall apart above 5.0, but for good reason. It is amplified by the number of points seen. #define ROTATIONAL_CORRECTION_MAXFORCE 0.01 +#define MINIMUM_CONFIDENCE_TO_CORRECT_POSITION 0.3 // Step 1: Determine standard of deviation, and average in order to // drop points that are likely in error. @@ -260,6 +264,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { // Step 2: Determine average lateral error. // We can actually always perform this operation. Even with only one point. + if ( so->PoseConfidence > MINIMUM_CONFIDENCE_TO_CORRECT_POSITION ) { FLT avg_err[3] = {0, 0, 0}; // Positional error. for (i = 0; i < pts; i++) { @@ -284,15 +289,24 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { // two points to make sure the error on this isn't unusually high? // If calculated error is unexpectedly high, then we should probably // Not apply the transform. - scale3d(avg_err, avg_err, -CORRECT_LATERAL_POSITION_COEFFICIENT); - add3d(vec_correct, vec_correct, avg_err); + + if( ( magnitude3d( avg_err ) < 0.4 || so->PoseConfidence < 0.6 ) ) + { + scale3d(avg_err, avg_err, -CORRECT_LATERAL_POSITION_COEFFICIENT); + add3d(vec_correct, vec_correct, avg_err); + applied_corrections++; + } + else + { + so->PoseConfidence *= 0.9; + } } // Step 3: Control telecoption from lighthouse. // we need to find out what the weighting is to determine "zoom" - if (validpoints > 1) // Can't correct "zoom" with only one point. + if (validpoints > 1 && so->PoseConfidence > MINIMUM_CONFIDENCE_TO_CORRECT_POSITION ) // Can't correct "zoom" with only one point. { FLT zoom = 0.0; FLT rmsang = 0.0; @@ -315,11 +329,20 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { zoom *= CORRECT_TELESCOPTION_COEFFICIENT; - FLT veccamalong[3]; - sub3d(veccamalong, lh_pose->Pos, dd->InteralPoseUsedForCalc.Pos); - normalize3d(veccamalong, veccamalong); - scale3d(veccamalong, veccamalong, zoom); - add3d(vec_correct, veccamalong, vec_correct); + //Don't apply completely wild zoom's unless our confidence is awful. + if( ( zoom < 0.4 || so->PoseConfidence < 0.6 ) && ( so->PoseConfidence > 0.3 ) ) + { + FLT veccamalong[3]; + sub3d(veccamalong, lh_pose->Pos, dd->InteralPoseUsedForCalc.Pos); + normalize3d(veccamalong, veccamalong); + scale3d(veccamalong, veccamalong, zoom); + add3d(vec_correct, veccamalong, vec_correct); + applied_corrections++; + } + else + { + so->PoseConfidence *= 0.9; + } } @@ -343,9 +366,8 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { #endif add3d(dd->InteralPoseUsedForCalc.Pos, vec_correct, dd->InteralPoseUsedForCalc.Pos); - - - //quatcopy(object_pose_out.Rot, dd->InteralPoseUsedForCalc.Rot); + //XXX TODO + // ?: Fuse accelerometer. // Stage 4: "Tug" on the rotation of the object, from all of the sensor's pov. // If we were able to determine likliehood of a hit in the sweep instead of afterward @@ -356,53 +378,84 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { for (i = 0; i < pts; i++) { if (!ptvalid[i]) continue; - FLT dist = dd->quantity_errors[i] - avgerr; + + FLT dist = dd->quantity_errors[i] - avgerr; //Relative dot-product error. FLT angle = dd->angles_at_pts[i]; int sensor_id = dd->sensor_ids[i]; - FLT *normal = dd->normal_at_errors[i]; - const SurvivePose *object_pose_at_hit = &dd->object_pose_at_hit[i]; - const FLT *sensor_inpos = &so->sensor_locations[sensor_id * 3]; + FLT * normal = dd->normal_at_errors[i]; + FLT * sensornormal = &so->sensor_normals[sensor_id*3]; + SurvivePose * lhp = dd->lastlhp; + const SurvivePose * object_pose_at_hit = &dd->object_pose_at_hit[i]; + const FLT * sensor_inpos = &so->sensor_locations[sensor_id * 3]; LinmathQuat world_to_object_space; quatgetreciprocal(world_to_object_space, object_pose_at_hit->Rot); - FLT correction_in_object_space[3]; // The amount across the surface of the object the rotation - // should happen. - - quatrotatevector(correction_in_object_space, world_to_object_space, normal); - dist *= CORRECT_ROTATION_COEFFICIENT; - if (dist > ROTATIONAL_CORRECTION_MAXFORCE) - dist = ROTATIONAL_CORRECTION_MAXFORCE; - if (dist < -ROTATIONAL_CORRECTION_MAXFORCE) - dist = -ROTATIONAL_CORRECTION_MAXFORCE; - - // Now, we have a "tug" vector in object-local space. Need to apply the torque. - FLT vector_from_center_of_object[3]; - normalize3d(vector_from_center_of_object, sensor_inpos); - // scale3d(vector_from_center_of_object, sensor_inpos, 10.0 ); - // vector_from_center_of_object[2]*=-1; - // vector_from_center_of_object[1]*=-1; - // vector_from_center_of_object[0]*=-1; - // vector_from_center_of_object - scale3d(vector_from_center_of_object, vector_from_center_of_object, 1); - - FLT new_vector_in_object_space[3]; - // printf( "%f %f %f %f\n", object_pose_at_hit->Rot[0], object_pose_at_hit->Rot[1], - // object_pose_at_hit->Rot[2], object_pose_at_hit->Rot[3] ); - // printf( "%f %f %f // %f %f %f // %f\n", vector_from_center_of_object[0], - // vector_from_center_of_object[1], vector_from_center_of_object[2], correction_in_object_space[0], - // correction_in_object_space[1], correction_in_object_space[2], dist ); - scale3d(correction_in_object_space, correction_in_object_space, -dist); - add3d(new_vector_in_object_space, vector_from_center_of_object, correction_in_object_space); - - normalize3d(new_vector_in_object_space, new_vector_in_object_space); - - LinmathQuat corrective_quaternion; - quatfrom2vectors(corrective_quaternion, vector_from_center_of_object, new_vector_in_object_space); - quatrotateabout(correction, correction, corrective_quaternion); - // printf( "%f -> %f %f %f => %f %f %f [%f %f %f %f]\n", dist, vector_from_center_of_object[0], - // vector_from_center_of_object[1], vector_from_center_of_object[2], - // correction_in_object_space[0], correction_in_object_space[1], correction_in_object_space[2], - // corrective_quaternion[0],corrective_quaternion[1],corrective_quaternion[1],corrective_quaternion[3]); + + //First, check to see if this hit is a sensor that is facing the lighthouse. + { + LinmathPoint3d vector_to_lighthouse; + sub3d( vector_to_lighthouse, lhp->Pos, object_pose_at_hit->Pos ); //Get vector in world space. + normalize3d( vector_to_lighthouse, vector_to_lighthouse ); + quatrotatevector( vector_to_lighthouse, world_to_object_space, vector_to_lighthouse ); + float facingness = dot3d( sensornormal, vector_to_lighthouse ); + if( facingness < 0 ) + { + //This is an impossible sensor hit. + so->PoseConfidence *= 0.8; + + //If our pose confidence is low, apply a torque. + if( so->PoseConfidence < 0.6 ) + { + LinmathPoint3d rotateaxis; + cross3d( rotateaxis, vector_to_lighthouse, sensornormal ); + LinmathQuat correction; + quatfromaxisangle(correction, rotateaxis, facingness*.2 ); + quatrotateabout(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot, correction); + quatnormalize(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot); + normal_faults ++; + } + } + } + + //Apply the normal tug. + { + + FLT correction_in_object_space[3]; // The amount across the surface of the object the rotation + // should happen. + + quatrotatevector(correction_in_object_space, world_to_object_space, normal); + dist *= CORRECT_ROTATION_COEFFICIENT; + if (dist > ROTATIONAL_CORRECTION_MAXFORCE) + dist = ROTATIONAL_CORRECTION_MAXFORCE; + if (dist < -ROTATIONAL_CORRECTION_MAXFORCE) + dist = -ROTATIONAL_CORRECTION_MAXFORCE; + + // Now, we have a "tug" vector in object-local space. Need to apply the torque. + FLT vector_from_center_of_object[3]; + normalize3d(vector_from_center_of_object, sensor_inpos); + // scale3d(vector_from_center_of_object, sensor_inpos, 10.0 ); + // vector_from_center_of_object[2]*=-1; + // vector_from_center_of_object[1]*=-1; + // vector_from_center_of_object[0]*=-1; + // vector_from_center_of_object + scale3d(vector_from_center_of_object, vector_from_center_of_object, 1); + + FLT new_vector_in_object_space[3]; + // printf( "%f %f %f %f\n", object_pose_at_hit->Rot[0], object_pose_at_hit->Rot[1], + // object_pose_at_hit->Rot[2], object_pose_at_hit->Rot[3] ); + // printf( "%f %f %f // %f %f %f // %f\n", vector_from_center_of_object[0], + // vector_from_center_of_object[1], vector_from_center_of_object[2], correction_in_object_space[0], + // correction_in_object_space[1], correction_in_object_space[2], dist ); + scale3d(correction_in_object_space, correction_in_object_space, -dist); + add3d(new_vector_in_object_space, vector_from_center_of_object, correction_in_object_space); + + normalize3d(new_vector_in_object_space, new_vector_in_object_space); + + LinmathQuat corrective_quaternion; + quatfrom2vectors(corrective_quaternion, vector_from_center_of_object, new_vector_in_object_space); + quatrotateabout(correction, correction, corrective_quaternion); + } + } // printf( "Applying: %f %f %f %f\n", correction[0], correction[1], correction[2], correction[3] ); // Apply our corrective quaternion to the output. @@ -420,8 +473,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { LinmathPoint3d MixedPosition = { 0, 0, 0 }; int l = 0, a = 0; if( lhid == 0 && axis == 0 ) for( l = 0; l < NUM_LIGHTHOUSES; l++ ) for( a = 0; a < 2; a++ ) dd->MixingConfidence[l][a] -= 0.1; - -#if 0 for( l = 0; l < NUM_LIGHTHOUSES; l++ ) for( a = 0; a < 2; a++ ) { LinmathPoint3d MixThis = { 0, 0, 0 }; @@ -433,13 +484,14 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { //printf( "%f ", Confidence ); } scale3d( MixedPosition, MixedPosition, 1./MixedAmount ); +#if 0 printf( "Reprojection disagreements:" ); -#endif for( l = 0; l < NUM_LIGHTHOUSES; l++ ) for( a = 0; a < 2; a++ ) { printf( "%f ", dist3d( dd->MixingPositions[l][a], MixedPosition ) ); } printf( "\n" ); +#endif //printf( "%f\n", MixedAmount ); SurvivePose object_pose_out; @@ -457,6 +509,15 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { // PoserData_poser_pose_func(pd, so, &dd->tracker.pose); dd->ptsweep = 0; + + if( validpoints > 1 && applied_corrections > 1 && !normal_faults) + { + so->PoseConfidence += (1-so->PoseConfidence)*.05; + } + else if( validpoints > 1 && so->PoseConfidence < 0.5 && !normal_faults ) + { + so->PoseConfidence += (1-so->PoseConfidence)*.05; + } } dd->sweepaxis = l->acode & 1; -- cgit v1.2.3 From 663198c1d4adeba3a5df5d008d8416b2f26f3a39 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 24 Jun 2018 00:29:17 -0400 Subject: Significant improvements to the charles refine. --- src/poser_charlesrefine.c | 227 +++++++++++++++++++++++++++++++--------------- 1 file changed, 152 insertions(+), 75 deletions(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index 1b392a3..09e6bbf 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -1,5 +1,3 @@ -// Driver works, but you _must_ start it near the origin looking in +Z. - #include #include #include @@ -15,6 +13,30 @@ #define MAX_PT_PER_SWEEP SENSORS_PER_OBJECT + + +// Tunable parameters: +#define MIN_HIT_QUALITY 0.5 // Determines which hits to cull. +#define HIT_QUALITY_BASELINE \ + 0.0001 // Determines which hits to cull. Actually SQRT(baseline) if 0.0001, it is really 1cm + +#define CORRECT_LATERAL_POSITION_COEFFICIENT 0.7 // Explodes if you exceed 1.0 (Normally 0.7 for snappy non-IMU response) +#define CORRECT_TELESCOPTION_COEFFICIENT 7.00 // Converges even as high as 10.0 and doesn't explode. (Normally 7.0 for non-IMU respone) +#define CORRECT_ROTATION_COEFFICIENT \ + 0.2 // This starts to fall apart above 5.0, but for good reason. It is amplified by the number of points seen. +#define ROTATIONAL_CORRECTION_MAXFORCE 0.01 +#define MINIMUM_CONFIDENCE_TO_CORRECT_POSITION 0.2 + + +#define POSE_CONFIDENCE_FOR_HANDLING_LINEAR_IMU 0.4 //0.9 + + +#define MAX_JUMP_DISTANCE 1000 //0.4 + + +//Grand todo: +// Update global "Up" vector from LH's PoV based on "Up" from the HMD. + typedef struct { int sweepaxis; int sweeplh; @@ -25,8 +47,18 @@ typedef struct { SurvivePose object_pose_at_hit[MAX_PT_PER_SWEEP]; uint8_t sensor_ids[MAX_PT_PER_SWEEP]; + LinmathPoint3d imuvel; + LinmathPoint3d imu_accel_zero; + LinmathQuat imu_up_correct; + LinmathPoint3d MixingPositions[NUM_LIGHTHOUSES][2]; - SurvivePose InteralPoseUsedForCalc; //Super high speed vibratey and terrible. + LinmathPoint3d mixed_output; + + //Super high speed vibratey and terrible. + //Also, big deal: this does NOT have the "re-righting" vector + //from the accelerometer applied to it. + SurvivePose InteralPoseUsedForCalc; + FLT MixingConfidence[NUM_LIGHTHOUSES][2]; FLT last_angle_lh_axis[NUM_LIGHTHOUSES][2]; int ptsweep; @@ -44,6 +76,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { SurvivePose object_pose_out; memcpy(&object_pose_out, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); memcpy(&dd->InteralPoseUsedForCalc, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); + memcpy(&dd->imu_up_correct, &LinmathQuat_Identity, sizeof(LinmathQuat_Identity) ); so->PoseConfidence = 0.0; PoserData_poser_pose_func(pd, so, &object_pose_out); } @@ -51,49 +84,104 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { SurviveSensorActivations *scene = &so->activations; switch (pd->pt) { case POSERDATA_IMU: { + float imu_time = 1./ so->imu_freq; // Really should use this... PoserDataIMU *imuData = (PoserDataIMU *)pd; + SurvivePose object_pose_out; + LinmathQuat object_to_world_with_imu_up_correct; + LinmathQuat world_space_to_object_space_quat; - //TODO: Actually do Madgwick's algorithm - LinmathQuat applymotion; - const SurvivePose * object_pose = &so->OutPose; - imuData->gyro[0] *= 1./so->imu_freq; - imuData->gyro[1] *= 1./so->imu_freq; - imuData->gyro[2] *= 1./so->imu_freq; - quatfromeuler( applymotion, imuData->gyro ); - //printf( "%f %f %f\n", imuData->gyro [0], imuData->gyro [1], imuData->gyro [2] ); - - LinmathQuat InvertQuat; - quatgetreciprocal(InvertQuat, object_pose->Rot); - - //Apply a tiny tug to re-right headset based on the gravity vector. - LinmathVec3d reright = { 0, 0, 1 }; - LinmathVec3d normup; - normalize3d( normup, imuData->accel ); - LinmathVec3d correct_diff; - quatrotatevector(reright, InvertQuat, reright); - sub3d( correct_diff, normup, reright ); - scale3d( correct_diff, correct_diff, -0.001 ); //This is the coefficient applying the drag. - add3d( correct_diff, correct_diff, reright ); - LinmathQuat reright_quat; - normalize3d( correct_diff, correct_diff ); - quatfrom2vectors( reright_quat, reright, correct_diff ); + quatrotateabout( object_to_world_with_imu_up_correct, dd->InteralPoseUsedForCalc.Rot, dd->imu_up_correct ); + quatgetreciprocal(world_space_to_object_space_quat, object_to_world_with_imu_up_correct ); + { + LinmathQuat applymotion; + imuData->gyro[0] *= imu_time; + imuData->gyro[1] *= imu_time; + imuData->gyro[2] *= imu_time; + quatfromeuler( applymotion, imuData->gyro ); + + quatrotateabout(object_pose_out.Rot, dd->InteralPoseUsedForCalc.Rot, applymotion ); //Contribution from Gyro + quatnormalize(object_pose_out.Rot, object_pose_out.Rot); + quatcopy( dd->InteralPoseUsedForCalc.Rot, object_pose_out.Rot); + } - SurvivePose object_pose_out; - quatrotateabout(object_pose_out.Rot, object_pose->Rot, applymotion ); //Contribution from Gyro - quatrotateabout(object_pose_out.Rot, object_pose_out.Rot, reright_quat); //Contribution from Accelerometer - quatnormalize(object_pose_out.Rot, object_pose_out.Rot); + //This will be overwritten by the accelerometer updates. + //We do this here in case we want to use it later. + copy3d( object_pose_out.Pos, dd->InteralPoseUsedForCalc.Pos ); + // Do accelerometer based stuff. + if( so->PoseConfidence > POSE_CONFIDENCE_FOR_HANDLING_LINEAR_IMU ) { - copy3d( object_pose_out.Pos, object_pose->Pos ); - PoserData_poser_pose_func(pd, so, &object_pose_out); - quatcopy( dd->InteralPoseUsedForCalc.Rot, object_pose_out.Rot); + //Step 1: Use the accelerometer's "up" to figure out how we can re-right world space to be the correct "up" vector. + //Apply a tiny tug to the imu_up_correct with the up vector.. + { + LinmathVec3d reright = { 0, 0, 1 }; + LinmathVec3d normup; + normalize3d( normup, imuData->accel ); + LinmathVec3d correct_diff; + quatrotatevector(reright, world_space_to_object_space_quat, reright); + sub3d( correct_diff, normup, reright ); + scale3d( correct_diff, correct_diff, -0.001 ); //This is the coefficient applying the drag. XXX THIS MUST CHANGE. + add3d( correct_diff, correct_diff, reright ); + normalize3d( correct_diff, correct_diff ); + LinmathQuat reright_quat; + quatfrom2vectors( reright_quat, reright, correct_diff ); + //Push to correct "Up" a little bit. + quatrotateabout(dd->imu_up_correct, dd->imu_up_correct, reright_quat); + quatnormalize(dd->imu_up_correct, dd->imu_up_correct); + } + + //Update position as a function from the IMU... + if( 0 ) { + LinmathVec3d expected_up = { 0, 0, 1 }; + LinmathVec3d acceleration; + scale3d( acceleration, imuData->accel, 1.0 ); + quatrotatevector( acceleration, dd->imu_up_correct, acceleration ); + + printf( "ACCEL %f %f %f\n", acceleration[0], acceleration[1], acceleration[2] ); + sub3d( acceleration, acceleration, dd->imu_accel_zero ); //IMU Accel Zero is in object-local space. + + quatrotatevector( acceleration, dd->InteralPoseUsedForCalc.Rot, acceleration ); + + printf( "ACCEL %f %f %f %f %f %f %f %f %f\n", acceleration[0],acceleration[1],acceleration[2], expected_up[0], expected_up[1], expected_up[2], + dd->imu_accel_zero[0], dd->imu_accel_zero[1], dd->imu_accel_zero[2]); + + sub3d( acceleration, acceleration, expected_up ); + + scale3d( acceleration, acceleration, 9.8 * imu_time ); + + //Acceleration is now in global space. - //PoserDataIMU *imu = (PoserDataIMU *)pd; - //survive_imu_tracker_integrate(so, &dd->tracker, imu); - //PoserData_poser_pose_func(pd, so, &dd->tracker.pose); + add3d( dd->imuvel, dd->imuvel, acceleration ); + + //IMUVel is the estimated object motion, in world space, but it will be pulled in the direction of the + //Faulty IMU bias. + + LinmathVec3d updatepos; + scale3d( updatepos, dd->imuvel, 1.0 ); + scale3d( updatepos, updatepos, imu_time ); + + + //printf( "ACCEL: %10f %10f %10f %10f %10f %10f %10f %10f %10f\n", + // acceleration[0], acceleration[1], acceleration[2], + // dd->imuvel[0],dd->imuvel[1],dd->imuvel[2], + // dd->imu_accel_zero[0], dd->imu_accel_zero[1], dd->imu_accel_zero[2] ); + + //Tricky, tug the imuvel toward zero otherwise it will contine to drift. + scale3d( dd->imuvel, dd->imuvel, 0.9999 ); + + //Update actual location. + add3d( dd->InteralPoseUsedForCalc.Pos, dd->InteralPoseUsedForCalc.Pos, updatepos ); + add3d( dd->mixed_output, dd->mixed_output, updatepos ); + + } + } + + copy3d( object_pose_out.Pos, dd->mixed_output ); + quatrotateabout( object_pose_out.Rot, object_pose_out.Rot, dd->imu_up_correct ); + PoserData_poser_pose_func(pd, so, &object_pose_out); return 0; } @@ -217,18 +305,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { FLT vec_correct[3] = {0., 0., 0.}; FLT avgang = 0.0; -// Tunable parameters: -#define MIN_HIT_QUALITY 0.5 // Determines which hits to cull. -#define HIT_QUALITY_BASELINE \ - 0.0001 // Determines which hits to cull. Actually SQRT(baseline) if 0.0001, it is really 1cm - -#define CORRECT_LATERAL_POSITION_COEFFICIENT 0.7 // Explodes if you exceed 1.0 -#define CORRECT_TELESCOPTION_COEFFICIENT 7.00 // Converges even as high as 10.0 and doesn't explode. -#define CORRECT_ROTATION_COEFFICIENT \ - 0.2 // This starts to fall apart above 5.0, but for good reason. It is amplified by the number of points seen. -#define ROTATIONAL_CORRECTION_MAXFORCE 0.01 -#define MINIMUM_CONFIDENCE_TO_CORRECT_POSITION 0.3 - // Step 1: Determine standard of deviation, and average in order to // drop points that are likely in error. { @@ -262,6 +338,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { avgerr /= validpoints; } + // Step 2: Determine average lateral error. // We can actually always perform this operation. Even with only one point. if ( so->PoseConfidence > MINIMUM_CONFIDENCE_TO_CORRECT_POSITION ) @@ -290,7 +367,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { // If calculated error is unexpectedly high, then we should probably // Not apply the transform. - if( ( magnitude3d( avg_err ) < 0.4 || so->PoseConfidence < 0.6 ) ) + if( ( magnitude3d( avg_err ) < MAX_JUMP_DISTANCE || so->PoseConfidence < 0.8 ) ) { scale3d(avg_err, avg_err, -CORRECT_LATERAL_POSITION_COEFFICIENT); add3d(vec_correct, vec_correct, avg_err); @@ -330,7 +407,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { zoom *= CORRECT_TELESCOPTION_COEFFICIENT; //Don't apply completely wild zoom's unless our confidence is awful. - if( ( zoom < 0.4 || so->PoseConfidence < 0.6 ) && ( so->PoseConfidence > 0.3 ) ) + if( ( zoom < MAX_JUMP_DISTANCE || so->PoseConfidence < 0.8 ) ) { FLT veccamalong[3]; sub3d(veccamalong, lh_pose->Pos, dd->InteralPoseUsedForCalc.Pos); @@ -346,28 +423,24 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } -#if 0 - LinmathPoint3d LastDelta; - sub3d( LastDelta, dd->MixingPositions[lhid][axis], dd->InteralPoseUsedForCalc.Pos ); - //Compare with "vec_correct" - - LinmathPoint3d DeltaDelta; - sub3d( DeltaDelta, vec_correct, LastDelta ); - - - //SurvivePose object_pose_out; - - memcpy( dd->MixingPositions[lhid][axis], vec_correct, sizeof( vec_correct ) ); + //Tricky: Update position here, and back-correct imuvel based on correction. + if( 0 ) { //XXX XXX TODO Position update + LinmathPoint3d vecc; + scale3d( vecc, vec_correct, 0.01 ); + add3d( dd->imuvel, dd->imuvel, vecc ); - LinmathPoint3d system_average_adjust = { 0, 0, 0 }; - - printf( "%f %f %f + %f %f %f\n", vec_correct[0], vec_correct[1], vec_correct[2], dd->InteralPoseUsedForCalc.Pos[0], dd->InteralPoseUsedForCalc.Pos[1], dd->InteralPoseUsedForCalc.Pos[2] ); - -#endif - add3d(dd->InteralPoseUsedForCalc.Pos, vec_correct, dd->InteralPoseUsedForCalc.Pos); + if( so->PoseConfidence > POSE_CONFIDENCE_FOR_HANDLING_LINEAR_IMU ) + { + scale3d( vecc, vec_correct, .01 ); + LinmathQuat world_to_object_space; + quatgetreciprocal(world_to_object_space, dd->InteralPoseUsedForCalc.Rot); + quatrotatevector( vecc, world_to_object_space, vecc ); + add3d( dd->imu_accel_zero, dd->imu_accel_zero, vecc ); + printf( "ACCELV: %f %f %f %f %f %f\n", vecc[0], vecc[1], vecc[2], dd->imu_accel_zero[0], dd->imu_accel_zero[1], dd->imu_accel_zero[2] ); + } + } - //XXX TODO - // ?: Fuse accelerometer. + add3d( dd->InteralPoseUsedForCalc.Pos, vec_correct, dd->InteralPoseUsedForCalc.Pos); // Stage 4: "Tug" on the rotation of the object, from all of the sensor's pov. // If we were able to determine likliehood of a hit in the sweep instead of afterward @@ -398,13 +471,13 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { normalize3d( vector_to_lighthouse, vector_to_lighthouse ); quatrotatevector( vector_to_lighthouse, world_to_object_space, vector_to_lighthouse ); float facingness = dot3d( sensornormal, vector_to_lighthouse ); - if( facingness < 0 ) + if( facingness < -.1 ) { //This is an impossible sensor hit. so->PoseConfidence *= 0.8; //If our pose confidence is low, apply a torque. - if( so->PoseConfidence < 0.6 ) + if( so->PoseConfidence < 0.8 ) { LinmathPoint3d rotateaxis; cross3d( rotateaxis, vector_to_lighthouse, sensornormal ); @@ -497,6 +570,9 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { SurvivePose object_pose_out; quatcopy(object_pose_out.Rot, dd->InteralPoseUsedForCalc.Rot ); copy3d( object_pose_out.Pos, MixedPosition ); + + copy3d( dd->mixed_output, object_pose_out.Pos ); + quatrotateabout( object_pose_out.Rot, object_pose_out.Rot, dd->imu_up_correct ); PoserData_poser_pose_func(pd, so, &object_pose_out); } // FLT var_meters = 0.5; @@ -512,11 +588,12 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { if( validpoints > 1 && applied_corrections > 1 && !normal_faults) { - so->PoseConfidence += (1-so->PoseConfidence)*.05; + so->PoseConfidence += (1-so->PoseConfidence)*.04; } else if( validpoints > 1 && so->PoseConfidence < 0.5 && !normal_faults ) { - so->PoseConfidence += (1-so->PoseConfidence)*.05; + printf( "Push\n" ); + so->PoseConfidence += (1-so->PoseConfidence)*.01; } } -- cgit v1.2.3 From fe153d9def29387f4ad9712bd364bf8d9fdc5776 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 24 Jun 2018 06:32:29 +0000 Subject: some more tweaks to the charlesrefine poser --- src/poser_charlesrefine.c | 58 ++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 31 deletions(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index 09e6bbf..dbc7087 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -21,19 +21,15 @@ 0.0001 // Determines which hits to cull. Actually SQRT(baseline) if 0.0001, it is really 1cm #define CORRECT_LATERAL_POSITION_COEFFICIENT 0.7 // Explodes if you exceed 1.0 (Normally 0.7 for snappy non-IMU response) -#define CORRECT_TELESCOPTION_COEFFICIENT 7.00 // Converges even as high as 10.0 and doesn't explode. (Normally 7.0 for non-IMU respone) +#define CORRECT_TELESCOPTION_COEFFICIENT 7.0 // Converges even as high as 10.0 and doesn't explode. (Normally 7.0 for non-IMU respone) #define CORRECT_ROTATION_COEFFICIENT \ 0.2 // This starts to fall apart above 5.0, but for good reason. It is amplified by the number of points seen. #define ROTATIONAL_CORRECTION_MAXFORCE 0.01 -#define MINIMUM_CONFIDENCE_TO_CORRECT_POSITION 0.2 +#define MINIMUM_CONFIDENCE_TO_CORRECT_POSITION 0.02 // 0.2 +#define POSE_CONFIDENCE_FOR_HANDLING_LINEAR_IMU .9 //0.9 +#define MAX_JUMP_DISTANCE 0.5 //0.4 -#define POSE_CONFIDENCE_FOR_HANDLING_LINEAR_IMU 0.4 //0.9 - - -#define MAX_JUMP_DISTANCE 1000 //0.4 - - //Grand todo: // Update global "Up" vector from LH's PoV based on "Up" from the HMD. @@ -123,64 +119,64 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { LinmathVec3d correct_diff; quatrotatevector(reright, world_space_to_object_space_quat, reright); sub3d( correct_diff, normup, reright ); - scale3d( correct_diff, correct_diff, -0.001 ); //This is the coefficient applying the drag. XXX THIS MUST CHANGE. + scale3d( correct_diff, correct_diff, -0.01 ); //This is the coefficient applying the drag. XXX THIS MUST CHANGE. add3d( correct_diff, correct_diff, reright ); normalize3d( correct_diff, correct_diff ); LinmathQuat reright_quat; quatfrom2vectors( reright_quat, reright, correct_diff ); //Push to correct "Up" a little bit. - quatrotateabout(dd->imu_up_correct, dd->imu_up_correct, reright_quat); - quatnormalize(dd->imu_up_correct, dd->imu_up_correct); + + + quatrotateabout(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot, reright_quat); + + //quatrotateabout(dd->imu_up_correct, dd->imu_up_correct, reright_quat); + //quatnormalize(dd->imu_up_correct, dd->imu_up_correct); } //Update position as a function from the IMU... - if( 0 ) { + if(0 ) { LinmathVec3d expected_up = { 0, 0, 1 }; LinmathVec3d acceleration; scale3d( acceleration, imuData->accel, 1.0 ); - quatrotatevector( acceleration, dd->imu_up_correct, acceleration ); - - printf( "ACCEL %f %f %f\n", acceleration[0], acceleration[1], acceleration[2] ); + //quatrotatevector( acceleration, dd->imu_up_correct, acceleration ); sub3d( acceleration, acceleration, dd->imu_accel_zero ); //IMU Accel Zero is in object-local space. - quatrotatevector( acceleration, dd->InteralPoseUsedForCalc.Rot, acceleration ); - - printf( "ACCEL %f %f %f %f %f %f %f %f %f\n", acceleration[0],acceleration[1],acceleration[2], expected_up[0], expected_up[1], expected_up[2], - dd->imu_accel_zero[0], dd->imu_accel_zero[1], dd->imu_accel_zero[2]); - sub3d( acceleration, acceleration, expected_up ); - scale3d( acceleration, acceleration, 9.8 * imu_time ); + LinmathVec3d recalv; + scale3d( recalv, acceleration, 0.01 ); + LinmathQuat invrr; + quatgetreciprocal( invrr, dd->InteralPoseUsedForCalc.Rot ); + quatrotatevector( recalv, invrr, recalv ); + add3d( dd->imu_accel_zero, dd->imu_accel_zero, recalv ); - //Acceleration is now in global space. + printf( "%s %f %f %f %f %f %f\n", so->codename, dd->imu_accel_zero[0], dd->imu_accel_zero[1], dd->imu_accel_zero[2], acceleration[0], acceleration[1], acceleration[2] ); + scale3d( acceleration, acceleration, 9.8 * imu_time ); add3d( dd->imuvel, dd->imuvel, acceleration ); //IMUVel is the estimated object motion, in world space, but it will be pulled in the direction of the //Faulty IMU bias. LinmathVec3d updatepos; + scale3d( updatepos, dd->imuvel, 1.0 ); scale3d( updatepos, updatepos, imu_time ); - - //printf( "ACCEL: %10f %10f %10f %10f %10f %10f %10f %10f %10f\n", - // acceleration[0], acceleration[1], acceleration[2], - // dd->imuvel[0],dd->imuvel[1],dd->imuvel[2], - // dd->imu_accel_zero[0], dd->imu_accel_zero[1], dd->imu_accel_zero[2] ); - //Tricky, tug the imuvel toward zero otherwise it will contine to drift. scale3d( dd->imuvel, dd->imuvel, 0.9999 ); //Update actual location. add3d( dd->InteralPoseUsedForCalc.Pos, dd->InteralPoseUsedForCalc.Pos, updatepos ); add3d( dd->mixed_output, dd->mixed_output, updatepos ); - } } + quatnormalize(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot); + quatnormalize(dd->imu_up_correct, dd->imu_up_correct); copy3d( object_pose_out.Pos, dd->mixed_output ); quatrotateabout( object_pose_out.Rot, object_pose_out.Rot, dd->imu_up_correct ); + quatnormalize( object_pose_out.Rot, object_pose_out.Rot ); PoserData_poser_pose_func(pd, so, &object_pose_out); return 0; @@ -465,7 +461,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { quatgetreciprocal(world_to_object_space, object_pose_at_hit->Rot); //First, check to see if this hit is a sensor that is facing the lighthouse. - { + if( so->PoseConfidence < 0.9 ) { LinmathPoint3d vector_to_lighthouse; sub3d( vector_to_lighthouse, lhp->Pos, object_pose_at_hit->Pos ); //Get vector in world space. normalize3d( vector_to_lighthouse, vector_to_lighthouse ); @@ -573,6 +569,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { copy3d( dd->mixed_output, object_pose_out.Pos ); quatrotateabout( object_pose_out.Rot, object_pose_out.Rot, dd->imu_up_correct ); + quatnormalize( object_pose_out.Rot, object_pose_out.Rot ); PoserData_poser_pose_func(pd, so, &object_pose_out); } // FLT var_meters = 0.5; @@ -592,7 +589,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } else if( validpoints > 1 && so->PoseConfidence < 0.5 && !normal_faults ) { - printf( "Push\n" ); so->PoseConfidence += (1-so->PoseConfidence)*.01; } } -- cgit v1.2.3 From 8ae8f5aa50ef7472a486ec6f3688e7dfb0c9dcab Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 24 Jun 2018 20:23:34 -0400 Subject: Refactor --- src/poser_charlesrefine.c | 342 +++++++++++++++++++++++++++------------------- 1 file changed, 204 insertions(+), 138 deletions(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index dbc7087..3e09925 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -21,7 +21,7 @@ 0.0001 // Determines which hits to cull. Actually SQRT(baseline) if 0.0001, it is really 1cm #define CORRECT_LATERAL_POSITION_COEFFICIENT 0.7 // Explodes if you exceed 1.0 (Normally 0.7 for snappy non-IMU response) -#define CORRECT_TELESCOPTION_COEFFICIENT 7.0 // Converges even as high as 10.0 and doesn't explode. (Normally 7.0 for non-IMU respone) +#define CORRECT_TELESCOPTION_COEFFICIENT 7.0f // Converges even as high as 10.0 and doesn't explode. (Normally 7.0 for non-IMU respone) #define CORRECT_ROTATION_COEFFICIENT \ 0.2 // This starts to fall apart above 5.0, but for good reason. It is amplified by the number of points seen. #define ROTATIONAL_CORRECTION_MAXFORCE 0.01 @@ -43,9 +43,10 @@ typedef struct { SurvivePose object_pose_at_hit[MAX_PT_PER_SWEEP]; uint8_t sensor_ids[MAX_PT_PER_SWEEP]; - LinmathPoint3d imuvel; - LinmathPoint3d imu_accel_zero; - LinmathQuat imu_up_correct; +// LinmathPoint3d imuvel; +// LinmathPoint3d imu_accel_zero; +// int did_zero_imu; +// LinmathPoint3d imu_up_correct; LinmathPoint3d MixingPositions[NUM_LIGHTHOUSES][2]; LinmathPoint3d mixed_output; @@ -64,6 +65,43 @@ typedef struct { SurvivePose * lastlhp; } CharlesPoserData; + +void AdjustRotation( SurviveObject *so, LinmathQuat adjustment, int is_imu, int is_coarse ) +{ + CharlesPoserData *dd = so->PoserData; + + quatrotateabout(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot, adjustment ); + quatnormalize(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot); + + //XXX TODO: Calibrate the gyroscope using the lightcap. + + //Always update the accelerometer zero based on the gyro. + //quatrotatevector( dd->imu_accel_zero, applygyro, dd->imu_accel_zero ); + //Always update the system-corrective quat based on the gyro. + //quatrotateabout( dd->imu_up_correct, dd->imu_up_correct, applygyro ); +} + +void AdjustPosition( SurviveObject * so, LinmathPoint3d adjustment, int is_imu ) +{ + CharlesPoserData *dd = so->PoserData; + + add3d( dd->InteralPoseUsedForCalc.Pos, adjustment, dd->InteralPoseUsedForCalc.Pos); + add3d( dd->mixed_output, adjustment, dd->mixed_output); +} + +//Emits "dd->mixed_output" for position and dd->InteralPoseUsedForCalc.Rot for rotation. +void EmitPose( SurviveObject *so, PoserData *pd ) +{ + CharlesPoserData *dd = so->PoserData; + + SurvivePose object_pose_out; + copy3d( object_pose_out.Pos, dd->mixed_output ); + quatcopy( object_pose_out.Rot, dd->InteralPoseUsedForCalc.Rot ); + PoserData_poser_pose_func(pd, so, &object_pose_out); +} + + + int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { CharlesPoserData *dd = so->PoserData; if (!dd) @@ -72,7 +110,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { SurvivePose object_pose_out; memcpy(&object_pose_out, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); memcpy(&dd->InteralPoseUsedForCalc, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); - memcpy(&dd->imu_up_correct, &LinmathQuat_Identity, sizeof(LinmathQuat_Identity) ); + //memcpy(&dd->imu_up_correct, &LinmathQuat_Identity, sizeof(LinmathQuat_Identity) ); so->PoseConfidence = 0.0; PoserData_poser_pose_func(pd, so, &object_pose_out); } @@ -87,26 +125,26 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { LinmathQuat object_to_world_with_imu_up_correct; LinmathQuat world_space_to_object_space_quat; - quatrotateabout( object_to_world_with_imu_up_correct, dd->InteralPoseUsedForCalc.Rot, dd->imu_up_correct ); - quatgetreciprocal(world_space_to_object_space_quat, object_to_world_with_imu_up_correct ); - + //quatrotateabout( object_to_world_with_imu_up_correct, dd->InteralPoseUsedForCalc.Rot, dd->imu_up_correct ); + //quatgetreciprocal(world_space_to_object_space_quat, object_to_world_with_imu_up_correct ); { - LinmathQuat applymotion; + LinmathQuat applygyro; imuData->gyro[0] *= imu_time; imuData->gyro[1] *= imu_time; imuData->gyro[2] *= imu_time; - quatfromeuler( applymotion, imuData->gyro ); - - quatrotateabout(object_pose_out.Rot, dd->InteralPoseUsedForCalc.Rot, applymotion ); //Contribution from Gyro - quatnormalize(object_pose_out.Rot, object_pose_out.Rot); - quatcopy( dd->InteralPoseUsedForCalc.Rot, object_pose_out.Rot); + quatfromeuler( applygyro, imuData->gyro ); + AdjustRotation( so, applygyro, 1, 0 ); } + EmitPose( so, pd ); + +#if 0 //This will be overwritten by the accelerometer updates. //We do this here in case we want to use it later. copy3d( object_pose_out.Pos, dd->InteralPoseUsedForCalc.Pos ); + // Do accelerometer based stuff. if( so->PoseConfidence > POSE_CONFIDENCE_FOR_HANDLING_LINEAR_IMU ) { @@ -119,22 +157,43 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { LinmathVec3d correct_diff; quatrotatevector(reright, world_space_to_object_space_quat, reright); sub3d( correct_diff, normup, reright ); - scale3d( correct_diff, correct_diff, -0.01 ); //This is the coefficient applying the drag. XXX THIS MUST CHANGE. + scale3d( correct_diff, correct_diff, -0.001 ); //This is the coefficient applying the drag. XXX THIS MUST CHANGE. add3d( correct_diff, correct_diff, reright ); normalize3d( correct_diff, correct_diff ); LinmathQuat reright_quat; quatfrom2vectors( reright_quat, reright, correct_diff ); //Push to correct "Up" a little bit. - - quatrotateabout(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot, reright_quat); + //Do this if we want to use the IMU's up to help out the libsurvive estimate of "up" + // quatrotateabout(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot, reright_quat); - //quatrotateabout(dd->imu_up_correct, dd->imu_up_correct, reright_quat); - //quatnormalize(dd->imu_up_correct, dd->imu_up_correct); + // quatrotateabout(dd->imu_up_correct, dd->imu_up_correct, reright_quat); + // quatnormalize(dd->imu_up_correct, dd->imu_up_correct); } + //Update position as a function from the IMU... - if(0 ) { + if( 1 ) { + LinmathVec3d acceleration; + scale3d( acceleration, imuData->accel, 1.0 ); + + if( !dd->did_zero_imu ) + { + copy3d( dd->imu_accel_zero, acceleration ); + dd->did_zero_imu = 1; + } + else + { + LinmathVec3d recalingval; + scale3d( recalingval, acceleration, 0.0001 ); + scale3d( dd->imu_accel_zero, dd->imu_accel_zero, 0.9999 ); + add3d( dd->imu_accel_zero, dd->imu_accel_zero, recalingval ); + } + + sub3d( acceleration, acceleration, dd->imu_accel_zero ); + scale3d( acceleration, acceleration, 9.8 * imu_time ); + printf( "ACCEL %f %f %f\n", PFTHREE( acceleration ) ); +#if 0 LinmathVec3d expected_up = { 0, 0, 1 }; LinmathVec3d acceleration; scale3d( acceleration, imuData->accel, 1.0 ); @@ -169,6 +228,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { //Update actual location. add3d( dd->InteralPoseUsedForCalc.Pos, dd->InteralPoseUsedForCalc.Pos, updatepos ); add3d( dd->mixed_output, dd->mixed_output, updatepos ); +#endif } } @@ -178,7 +238,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { quatrotateabout( object_pose_out.Rot, object_pose_out.Rot, dd->imu_up_correct ); quatnormalize( object_pose_out.Rot, object_pose_out.Rot ); PoserData_poser_pose_func(pd, so, &object_pose_out); - +#endif return 0; } case POSERDATA_LIGHT: { @@ -298,127 +358,131 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { int validpoints = 0; int ptvalid[MAX_PT_PER_SWEEP]; FLT avgerr = 0.0; - FLT vec_correct[3] = {0., 0., 0.}; FLT avgang = 0.0; - // Step 1: Determine standard of deviation, and average in order to - // drop points that are likely in error. { - // Calculate average - FLT avgerr_orig = 0.0; - FLT stddevsq = 0.0; - for (i = 0; i < pts; i++) - avgerr_orig += dd->quantity_errors[i]; - avgerr_orig /= pts; - - // Calculate standard of deviation. - for (i = 0; i < pts; i++) { - FLT diff = dd->quantity_errors[i] - avgerr_orig; - stddevsq += diff * diff; - } - stddevsq /= pts; - - for (i = 0; i < pts; i++) { - FLT err = dd->quantity_errors[i]; - FLT diff = err - avgerr_orig; - diff *= diff; - int isptvalid = (diff * MIN_HIT_QUALITY <= stddevsq + HIT_QUALITY_BASELINE) ? 1 : 0; - ptvalid[i] = isptvalid; - if (isptvalid) { - avgang += dd->angles_at_pts[i]; - avgerr += err; - validpoints++; + FLT vec_correct[3] = {0., 0., 0.}; + // Step 1: Determine standard of deviation, and average in order to + // drop points that are likely in error. + { + // Calculate average + FLT avgerr_orig = 0.0; + FLT stddevsq = 0.0; + for (i = 0; i < pts; i++) + avgerr_orig += dd->quantity_errors[i]; + avgerr_orig /= pts; + + // Calculate standard of deviation. + for (i = 0; i < pts; i++) { + FLT diff = dd->quantity_errors[i] - avgerr_orig; + stddevsq += diff * diff; + } + stddevsq /= pts; + + for (i = 0; i < pts; i++) { + FLT err = dd->quantity_errors[i]; + FLT diff = err - avgerr_orig; + diff *= diff; + int isptvalid = (diff * MIN_HIT_QUALITY <= stddevsq + HIT_QUALITY_BASELINE) ? 1 : 0; + ptvalid[i] = isptvalid; + if (isptvalid) { + avgang += dd->angles_at_pts[i]; + avgerr += err; + validpoints++; + } } + avgang /= validpoints; + avgerr /= validpoints; } - avgang /= validpoints; - avgerr /= validpoints; - } - // Step 2: Determine average lateral error. - // We can actually always perform this operation. Even with only one point. - if ( so->PoseConfidence > MINIMUM_CONFIDENCE_TO_CORRECT_POSITION ) - { - FLT avg_err[3] = {0, 0, 0}; // Positional error. - for (i = 0; i < pts; i++) { - if (!ptvalid[i]) - continue; - FLT *nrm = dd->normal_at_errors[i]; - FLT err = dd->quantity_errors[i]; - avg_err[0] = avg_err[0] + nrm[0] * err; - avg_err[1] = avg_err[1] + nrm[1] * err; - avg_err[2] = avg_err[2] + nrm[2] * err; - } + // Step 2: Determine average lateral error. + // We can actually always perform this operation. Even with only one point. + if ( so->PoseConfidence > MINIMUM_CONFIDENCE_TO_CORRECT_POSITION ) + { + FLT avg_err[3] = {0, 0, 0}; // Positional error. + for (i = 0; i < pts; i++) { + if (!ptvalid[i]) + continue; + FLT *nrm = dd->normal_at_errors[i]; + FLT err = dd->quantity_errors[i]; + avg_err[0] = avg_err[0] + nrm[0] * err; + avg_err[1] = avg_err[1] + nrm[1] * err; + avg_err[2] = avg_err[2] + nrm[2] * err; + } - // NOTE: The "avg_err" is not geometrically centered. This is actually - // probably okay, since if you have sevearl data points to one side, you - // can probably trust that more. - scale3d(avg_err, avg_err, 1. / validpoints); + // NOTE: The "avg_err" is not geometrically centered. This is actually + // probably okay, since if you have sevearl data points to one side, you + // can probably trust that more. + scale3d(avg_err, avg_err, 1. / validpoints); - // We have "Average error" now. A vector in worldspace. - // This can correct for lateral error, but not distance from camera. + // We have "Average error" now. A vector in worldspace. + // This can correct for lateral error, but not distance from camera. - // XXX TODO: Should we check to see if we only have one or - // two points to make sure the error on this isn't unusually high? - // If calculated error is unexpectedly high, then we should probably - // Not apply the transform. + // XXX TODO: Should we check to see if we only have one or + // two points to make sure the error on this isn't unusually high? + // If calculated error is unexpectedly high, then we should probably + // Not apply the transform. - if( ( magnitude3d( avg_err ) < MAX_JUMP_DISTANCE || so->PoseConfidence < 0.8 ) ) - { - scale3d(avg_err, avg_err, -CORRECT_LATERAL_POSITION_COEFFICIENT); - add3d(vec_correct, vec_correct, avg_err); - applied_corrections++; - } - else - { - so->PoseConfidence *= 0.9; + if( ( magnitude3d( avg_err ) < MAX_JUMP_DISTANCE || so->PoseConfidence < 0.8 ) ) + { + scale3d(avg_err, avg_err, -CORRECT_LATERAL_POSITION_COEFFICIENT); + add3d(vec_correct, vec_correct, avg_err); + applied_corrections++; + } + else + { + so->PoseConfidence *= 0.9; + } } - } - // Step 3: Control telecoption from lighthouse. - // we need to find out what the weighting is to determine "zoom" - if (validpoints > 1 && so->PoseConfidence > MINIMUM_CONFIDENCE_TO_CORRECT_POSITION ) // Can't correct "zoom" with only one point. - { - FLT zoom = 0.0; - FLT rmsang = 0.0; - for (i = 0; i < pts; i++) { - if (!ptvalid[i]) - continue; - FLT delang = dd->angles_at_pts[i] - avgang; - FLT delerr = dd->quantity_errors[i] - avgerr; - if (axis) - delang *= -1; // Flip sign on alternate axis because it's measured backwards. - zoom += delerr * delang; - rmsang += delang * delang; - } + // Step 3: Control telecoption from lighthouse. + // we need to find out what the weighting is to determine "zoom" + if (validpoints > 1 && so->PoseConfidence > MINIMUM_CONFIDENCE_TO_CORRECT_POSITION ) // Can't correct "zoom" with only one point. + { + FLT zoom = 0.0; + FLT rmsang = 0.0; + for (i = 0; i < pts; i++) { + if (!ptvalid[i]) + continue; + FLT delang = dd->angles_at_pts[i] - avgang; + FLT delerr = dd->quantity_errors[i] - avgerr; + if (axis) + delang *= -1; // Flip sign on alternate axis because it's measured backwards. + zoom += delerr * delang; + rmsang += delang * delang; + } - // Control into or outof lighthouse. - // XXX Check to see if we need to sqrt( the rmsang), need to check convergance behavior close to - // lighthouse. - // This is a questionable step. - zoom /= sqrt(rmsang); + // Control into or outof lighthouse. + // XXX Check to see if we need to sqrt( the rmsang), need to check convergance behavior close to + // lighthouse. + // This is a questionable step. + zoom /= sqrt(rmsang); - zoom *= CORRECT_TELESCOPTION_COEFFICIENT; + zoom *= CORRECT_TELESCOPTION_COEFFICIENT; - //Don't apply completely wild zoom's unless our confidence is awful. - if( ( zoom < MAX_JUMP_DISTANCE || so->PoseConfidence < 0.8 ) ) - { - FLT veccamalong[3]; - sub3d(veccamalong, lh_pose->Pos, dd->InteralPoseUsedForCalc.Pos); - normalize3d(veccamalong, veccamalong); - scale3d(veccamalong, veccamalong, zoom); - add3d(vec_correct, veccamalong, vec_correct); - applied_corrections++; - } - else - { - so->PoseConfidence *= 0.9; + //Don't apply completely wild zoom's unless our confidence is awful. + if( ( zoom < MAX_JUMP_DISTANCE || so->PoseConfidence < 0.8 ) ) + { + FLT veccamalong[3]; + sub3d(veccamalong, lh_pose->Pos, dd->InteralPoseUsedForCalc.Pos); + normalize3d(veccamalong, veccamalong); + scale3d(veccamalong, veccamalong, zoom); + add3d(vec_correct, veccamalong, vec_correct); + applied_corrections++; + } + else + { + so->PoseConfidence *= 0.9; + } } + AdjustPosition( so, vec_correct, 0 ); } +#if 0 //Tricky: Update position here, and back-correct imuvel based on correction. if( 0 ) { //XXX XXX TODO Position update LinmathPoint3d vecc; @@ -431,12 +495,12 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { LinmathQuat world_to_object_space; quatgetreciprocal(world_to_object_space, dd->InteralPoseUsedForCalc.Rot); quatrotatevector( vecc, world_to_object_space, vecc ); - add3d( dd->imu_accel_zero, dd->imu_accel_zero, vecc ); - printf( "ACCELV: %f %f %f %f %f %f\n", vecc[0], vecc[1], vecc[2], dd->imu_accel_zero[0], dd->imu_accel_zero[1], dd->imu_accel_zero[2] ); + //add3d( dd->imu_accel_zero, dd->imu_accel_zero, vecc ); + //printf( "ACCELV: %f %f %f %f %f %f\n", vecc[0], vecc[1], vecc[2], dd->imu_accel_zero[0], dd->imu_accel_zero[1], dd->imu_accel_zero[2] ); } } +#endif - add3d( dd->InteralPoseUsedForCalc.Pos, vec_correct, dd->InteralPoseUsedForCalc.Pos); // Stage 4: "Tug" on the rotation of the object, from all of the sensor's pov. // If we were able to determine likliehood of a hit in the sweep instead of afterward @@ -460,7 +524,9 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { LinmathQuat world_to_object_space; quatgetreciprocal(world_to_object_space, object_pose_at_hit->Rot); - //First, check to see if this hit is a sensor that is facing the lighthouse. + //4A: First, check to see if this hit is a sensor that is facing the lighthouse. + //This is for coarse corrections early on in the calibration. + //If one of these happens it means the orientation/pose is totally impossible. if( so->PoseConfidence < 0.9 ) { LinmathPoint3d vector_to_lighthouse; sub3d( vector_to_lighthouse, lhp->Pos, object_pose_at_hit->Pos ); //Get vector in world space. @@ -479,9 +545,8 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { cross3d( rotateaxis, vector_to_lighthouse, sensornormal ); LinmathQuat correction; quatfromaxisangle(correction, rotateaxis, facingness*.2 ); - quatrotateabout(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot, correction); - quatnormalize(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot); normal_faults ++; + AdjustRotation( so, correction, 0, 1 ); } } } @@ -528,14 +593,12 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } // printf( "Applying: %f %f %f %f\n", correction[0], correction[1], correction[2], correction[3] ); // Apply our corrective quaternion to the output. - quatrotateabout(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot, correction); - quatnormalize(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot); + AdjustRotation( so, correction, 0, 0 ); } memcpy( dd->MixingPositions[lhid][axis], dd->InteralPoseUsedForCalc.Pos, sizeof( dd->InteralPoseUsedForCalc.Pos ) ); dd->MixingConfidence[lhid][axis] = (validpoints)?((validpoints>1)?1.0:0.5):0; - //Box filter all of the guesstimations, and emit the new guess. { FLT MixedAmount = 0; @@ -552,7 +615,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { MixedAmount += Confidence; //printf( "%f ", Confidence ); } - scale3d( MixedPosition, MixedPosition, 1./MixedAmount ); + scale3d( dd->mixed_output, MixedPosition, 1./MixedAmount ); #if 0 printf( "Reprojection disagreements:" ); for( l = 0; l < NUM_LIGHTHOUSES; l++ ) for( a = 0; a < 2; a++ ) @@ -561,16 +624,19 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } printf( "\n" ); #endif + EmitPose( so, pd ); //printf( "%f\n", MixedAmount ); - SurvivePose object_pose_out; - quatcopy(object_pose_out.Rot, dd->InteralPoseUsedForCalc.Rot ); - copy3d( object_pose_out.Pos, MixedPosition ); - - copy3d( dd->mixed_output, object_pose_out.Pos ); - quatrotateabout( object_pose_out.Rot, object_pose_out.Rot, dd->imu_up_correct ); - quatnormalize( object_pose_out.Rot, object_pose_out.Rot ); - PoserData_poser_pose_func(pd, so, &object_pose_out); + + // SurvivePose object_pose_out; + // quatcopy(object_pose_out.Rot, dd->InteralPoseUsedForCalc.Rot ); + // copy3d( object_pose_out.Pos, MixedPosition ); + + // copy3d( dd->mixed_output, object_pose_out.Pos ); + // quatrotateabout( object_pose_out.Rot, object_pose_out.Rot, dd->imu_up_correct ); + // quatnormalize( object_pose_out.Rot, object_pose_out.Rot ); + // PoserData_poser_pose_func(pd, so, &object_pose_out); + } // FLT var_meters = 0.5; // FLT error = 0.00001; -- cgit v1.2.3 From ae8c269a9760cfd3bf7727485506df5ad2aacc69 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 24 Jun 2018 20:34:38 -0400 Subject: Remove unused code. --- src/poser_charlesrefine.c | 185 +--------------------------------------------- 1 file changed, 1 insertion(+), 184 deletions(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index 3e09925..5375d9c 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -43,11 +43,6 @@ typedef struct { SurvivePose object_pose_at_hit[MAX_PT_PER_SWEEP]; uint8_t sensor_ids[MAX_PT_PER_SWEEP]; -// LinmathPoint3d imuvel; -// LinmathPoint3d imu_accel_zero; -// int did_zero_imu; -// LinmathPoint3d imu_up_correct; - LinmathPoint3d MixingPositions[NUM_LIGHTHOUSES][2]; LinmathPoint3d mixed_output; @@ -61,7 +56,6 @@ typedef struct { int ptsweep; SurviveIMUTracker tracker; - SurvivePose * lastlhp; } CharlesPoserData; @@ -110,7 +104,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { SurvivePose object_pose_out; memcpy(&object_pose_out, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); memcpy(&dd->InteralPoseUsedForCalc, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); - //memcpy(&dd->imu_up_correct, &LinmathQuat_Identity, sizeof(LinmathQuat_Identity) ); + memcpy(&dd->imu_up_correct, &LinmathPoint3d_Identity, sizeof(LinmathPoint3d_Identity) ); so->PoseConfidence = 0.0; PoserData_poser_pose_func(pd, so, &object_pose_out); } @@ -125,9 +119,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { LinmathQuat object_to_world_with_imu_up_correct; LinmathQuat world_space_to_object_space_quat; - //quatrotateabout( object_to_world_with_imu_up_correct, dd->InteralPoseUsedForCalc.Rot, dd->imu_up_correct ); - //quatgetreciprocal(world_space_to_object_space_quat, object_to_world_with_imu_up_correct ); - { LinmathQuat applygyro; imuData->gyro[0] *= imu_time; @@ -138,107 +129,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } EmitPose( so, pd ); - -#if 0 - //This will be overwritten by the accelerometer updates. - //We do this here in case we want to use it later. - copy3d( object_pose_out.Pos, dd->InteralPoseUsedForCalc.Pos ); - - - // Do accelerometer based stuff. - if( so->PoseConfidence > POSE_CONFIDENCE_FOR_HANDLING_LINEAR_IMU ) { - - //Step 1: Use the accelerometer's "up" to figure out how we can re-right world space to be the correct "up" vector. - //Apply a tiny tug to the imu_up_correct with the up vector.. - { - LinmathVec3d reright = { 0, 0, 1 }; - LinmathVec3d normup; - normalize3d( normup, imuData->accel ); - LinmathVec3d correct_diff; - quatrotatevector(reright, world_space_to_object_space_quat, reright); - sub3d( correct_diff, normup, reright ); - scale3d( correct_diff, correct_diff, -0.001 ); //This is the coefficient applying the drag. XXX THIS MUST CHANGE. - add3d( correct_diff, correct_diff, reright ); - normalize3d( correct_diff, correct_diff ); - LinmathQuat reright_quat; - quatfrom2vectors( reright_quat, reright, correct_diff ); - //Push to correct "Up" a little bit. - - //Do this if we want to use the IMU's up to help out the libsurvive estimate of "up" - // quatrotateabout(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot, reright_quat); - - // quatrotateabout(dd->imu_up_correct, dd->imu_up_correct, reright_quat); - // quatnormalize(dd->imu_up_correct, dd->imu_up_correct); - } - - - //Update position as a function from the IMU... - if( 1 ) { - LinmathVec3d acceleration; - scale3d( acceleration, imuData->accel, 1.0 ); - - if( !dd->did_zero_imu ) - { - copy3d( dd->imu_accel_zero, acceleration ); - dd->did_zero_imu = 1; - } - else - { - LinmathVec3d recalingval; - scale3d( recalingval, acceleration, 0.0001 ); - scale3d( dd->imu_accel_zero, dd->imu_accel_zero, 0.9999 ); - add3d( dd->imu_accel_zero, dd->imu_accel_zero, recalingval ); - } - - sub3d( acceleration, acceleration, dd->imu_accel_zero ); - scale3d( acceleration, acceleration, 9.8 * imu_time ); - printf( "ACCEL %f %f %f\n", PFTHREE( acceleration ) ); -#if 0 - LinmathVec3d expected_up = { 0, 0, 1 }; - LinmathVec3d acceleration; - scale3d( acceleration, imuData->accel, 1.0 ); - //quatrotatevector( acceleration, dd->imu_up_correct, acceleration ); - sub3d( acceleration, acceleration, dd->imu_accel_zero ); //IMU Accel Zero is in object-local space. - quatrotatevector( acceleration, dd->InteralPoseUsedForCalc.Rot, acceleration ); - sub3d( acceleration, acceleration, expected_up ); - - LinmathVec3d recalv; - scale3d( recalv, acceleration, 0.01 ); - LinmathQuat invrr; - quatgetreciprocal( invrr, dd->InteralPoseUsedForCalc.Rot ); - quatrotatevector( recalv, invrr, recalv ); - add3d( dd->imu_accel_zero, dd->imu_accel_zero, recalv ); - - printf( "%s %f %f %f %f %f %f\n", so->codename, dd->imu_accel_zero[0], dd->imu_accel_zero[1], dd->imu_accel_zero[2], acceleration[0], acceleration[1], acceleration[2] ); - - scale3d( acceleration, acceleration, 9.8 * imu_time ); - add3d( dd->imuvel, dd->imuvel, acceleration ); - - //IMUVel is the estimated object motion, in world space, but it will be pulled in the direction of the - //Faulty IMU bias. - - LinmathVec3d updatepos; - - scale3d( updatepos, dd->imuvel, 1.0 ); - scale3d( updatepos, updatepos, imu_time ); - - //Tricky, tug the imuvel toward zero otherwise it will contine to drift. - scale3d( dd->imuvel, dd->imuvel, 0.9999 ); - - //Update actual location. - add3d( dd->InteralPoseUsedForCalc.Pos, dd->InteralPoseUsedForCalc.Pos, updatepos ); - add3d( dd->mixed_output, dd->mixed_output, updatepos ); -#endif - } - } - - quatnormalize(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot); - quatnormalize(dd->imu_up_correct, dd->imu_up_correct); - copy3d( object_pose_out.Pos, dd->mixed_output ); - quatrotateabout( object_pose_out.Rot, object_pose_out.Rot, dd->imu_up_correct ); - quatnormalize( object_pose_out.Rot, object_pose_out.Rot ); - PoserData_poser_pose_func(pd, so, &object_pose_out); -#endif return 0; } case POSERDATA_LIGHT: { @@ -257,30 +147,18 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { dd->sweeplh = lhid; - // FOR NOW, drop LH1. - // if( lhid == 1 ) break; - - // const FLT * sensor_normal = &so->sensor_normals[senid*3]; - // FLT sensor_normal_worldspace[3]; - // ApplyPoseToPoint(sensor_normal_worldspace, object_pose, sensor_inpos); - const FLT *sensor_inpos = &so->sensor_locations[senid * 3]; FLT sensor_position_worldspace[3]; // XXX Once I saw this get pretty wild (When in playback) // I had to invert the values of sensor_inpos. Not sure why. ApplyPoseToPoint(sensor_position_worldspace, &dd->InteralPoseUsedForCalc, sensor_inpos); - // printf( "%f %f %f == > %f %f %f\n", sensor_inpos[0], sensor_inpos[1], sensor_inpos[2], - // sensor_position_worldspace[0], sensor_position_worldspace[1], sensor_position_worldspace[2] ); - // = sensor position, relative to lighthouse center. FLT sensorpos_rel_lh[3]; sub3d(sensorpos_rel_lh, sensor_position_worldspace, lhp->Pos); // Next, define a normal in global space of the plane created by the sweep hit. // Careful that this must be normalized. FLT sweep_normal[3]; - - FLT inangles[2]; FLT outangles[2]; inangles[axis] = inangle; @@ -482,25 +360,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } -#if 0 - //Tricky: Update position here, and back-correct imuvel based on correction. - if( 0 ) { //XXX XXX TODO Position update - LinmathPoint3d vecc; - scale3d( vecc, vec_correct, 0.01 ); - add3d( dd->imuvel, dd->imuvel, vecc ); - - if( so->PoseConfidence > POSE_CONFIDENCE_FOR_HANDLING_LINEAR_IMU ) - { - scale3d( vecc, vec_correct, .01 ); - LinmathQuat world_to_object_space; - quatgetreciprocal(world_to_object_space, dd->InteralPoseUsedForCalc.Rot); - quatrotatevector( vecc, world_to_object_space, vecc ); - //add3d( dd->imu_accel_zero, dd->imu_accel_zero, vecc ); - //printf( "ACCELV: %f %f %f %f %f %f\n", vecc[0], vecc[1], vecc[2], dd->imu_accel_zero[0], dd->imu_accel_zero[1], dd->imu_accel_zero[2] ); - } - } -#endif - // Stage 4: "Tug" on the rotation of the object, from all of the sensor's pov. // If we were able to determine likliehood of a hit in the sweep instead of afterward @@ -566,20 +425,9 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { // Now, we have a "tug" vector in object-local space. Need to apply the torque. FLT vector_from_center_of_object[3]; - normalize3d(vector_from_center_of_object, sensor_inpos); - // scale3d(vector_from_center_of_object, sensor_inpos, 10.0 ); - // vector_from_center_of_object[2]*=-1; - // vector_from_center_of_object[1]*=-1; - // vector_from_center_of_object[0]*=-1; - // vector_from_center_of_object scale3d(vector_from_center_of_object, vector_from_center_of_object, 1); FLT new_vector_in_object_space[3]; - // printf( "%f %f %f %f\n", object_pose_at_hit->Rot[0], object_pose_at_hit->Rot[1], - // object_pose_at_hit->Rot[2], object_pose_at_hit->Rot[3] ); - // printf( "%f %f %f // %f %f %f // %f\n", vector_from_center_of_object[0], - // vector_from_center_of_object[1], vector_from_center_of_object[2], correction_in_object_space[0], - // correction_in_object_space[1], correction_in_object_space[2], dist ); scale3d(correction_in_object_space, correction_in_object_space, -dist); add3d(new_vector_in_object_space, vector_from_center_of_object, correction_in_object_space); @@ -591,7 +439,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } } - // printf( "Applying: %f %f %f %f\n", correction[0], correction[1], correction[2], correction[3] ); // Apply our corrective quaternion to the output. AdjustRotation( so, correction, 0, 0 ); } @@ -616,37 +463,8 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { //printf( "%f ", Confidence ); } scale3d( dd->mixed_output, MixedPosition, 1./MixedAmount ); -#if 0 - printf( "Reprojection disagreements:" ); - for( l = 0; l < NUM_LIGHTHOUSES; l++ ) for( a = 0; a < 2; a++ ) - { - printf( "%f ", dist3d( dd->MixingPositions[l][a], MixedPosition ) ); - } - printf( "\n" ); -#endif EmitPose( so, pd ); - - //printf( "%f\n", MixedAmount ); - - // SurvivePose object_pose_out; - // quatcopy(object_pose_out.Rot, dd->InteralPoseUsedForCalc.Rot ); - // copy3d( object_pose_out.Pos, MixedPosition ); - - // copy3d( dd->mixed_output, object_pose_out.Pos ); - // quatrotateabout( object_pose_out.Rot, object_pose_out.Rot, dd->imu_up_correct ); - // quatnormalize( object_pose_out.Rot, object_pose_out.Rot ); - // PoserData_poser_pose_func(pd, so, &object_pose_out); - } - // FLT var_meters = 0.5; - // FLT error = 0.00001; - // FLT var_quat = error + .05; - // FLT var[7] = {error * var_meters, error * var_meters, error * var_meters, error * var_quat, - // error * var_quat, error * var_quat, error * var_quat}; - // - // survive_imu_tracker_integrate_observation(so, l->timecode, &dd->tracker, &object_pose_out, var); - // PoserData_poser_pose_func(pd, so, &dd->tracker.pose); - dd->ptsweep = 0; if( validpoints > 1 && applied_corrections > 1 && !normal_faults) @@ -660,7 +478,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } dd->sweepaxis = l->acode & 1; - // printf( "SYNC %d %p\n", l->acode, dd ); break; } case POSERDATA_FULL_SCENE: { -- cgit v1.2.3 From 6b10746b801169439f9337383f394e9cddfc9108 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 24 Jun 2018 20:39:04 -0400 Subject: Fix refactor --- src/poser_charlesrefine.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index 5375d9c..dea67c6 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -104,7 +104,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { SurvivePose object_pose_out; memcpy(&object_pose_out, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); memcpy(&dd->InteralPoseUsedForCalc, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); - memcpy(&dd->imu_up_correct, &LinmathPoint3d_Identity, sizeof(LinmathPoint3d_Identity) ); + //memcpy(&dd->imu_up_correct, &LinmathQuat_Identity, sizeof(LinmathQuat_Identity) ); so->PoseConfidence = 0.0; PoserData_poser_pose_func(pd, so, &object_pose_out); } @@ -143,7 +143,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { FLT inangle = ld->angle; int sensor_id = ld->sensor_id; int axis = dd->sweepaxis; - //const SurvivePose *object_pose = &so->OutPose; dd->sweeplh = lhid; @@ -227,8 +226,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { int lhid = dd->sweeplh; int axis = dd->sweepaxis; int pts = dd->ptsweep; - //const SurvivePose *object_pose = - // &so->OutPose; // XXX TODO Should pull pose from approximate time when LHs were scanning it. BaseStationData *bsd = &so->ctx->bsd[lhid]; SurvivePose *lh_pose = &bsd->Pose; @@ -359,8 +356,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { AdjustPosition( so, vec_correct, 0 ); } - - // Stage 4: "Tug" on the rotation of the object, from all of the sensor's pov. // If we were able to determine likliehood of a hit in the sweep instead of afterward // we would actually be able to perform this on a per-hit basis. @@ -425,6 +420,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { // Now, we have a "tug" vector in object-local space. Need to apply the torque. FLT vector_from_center_of_object[3]; + normalize3d(vector_from_center_of_object, sensor_inpos); scale3d(vector_from_center_of_object, vector_from_center_of_object, 1); FLT new_vector_in_object_space[3]; @@ -439,7 +435,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } } - // Apply our corrective quaternion to the output. AdjustRotation( so, correction, 0, 0 ); } @@ -464,7 +459,9 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } scale3d( dd->mixed_output, MixedPosition, 1./MixedAmount ); EmitPose( so, pd ); + } + dd->ptsweep = 0; if( validpoints > 1 && applied_corrections > 1 && !normal_faults) @@ -478,6 +475,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } dd->sweepaxis = l->acode & 1; + // printf( "SYNC %d %p\n", l->acode, dd ); break; } case POSERDATA_FULL_SCENE: { -- cgit v1.2.3 From adae79a87e31fa8c6cebfa44da42e8a24ad1dd11 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 24 Jun 2018 22:07:14 -0400 Subject: Integrate the accelerometer even if not perfectly. --- src/poser_charlesrefine.c | 84 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 15 deletions(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index dea67c6..de732fe 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -20,8 +20,11 @@ #define HIT_QUALITY_BASELINE \ 0.0001 // Determines which hits to cull. Actually SQRT(baseline) if 0.0001, it is really 1cm -#define CORRECT_LATERAL_POSITION_COEFFICIENT 0.7 // Explodes if you exceed 1.0 (Normally 0.7 for snappy non-IMU response) -#define CORRECT_TELESCOPTION_COEFFICIENT 7.0f // Converges even as high as 10.0 and doesn't explode. (Normally 7.0 for non-IMU respone) +#define LIGHTCAP_DESCALE 0.5 //DO NOT EXCEED 0.7 + +#define CORRECT_LATERAL_POSITION_COEFFICIENT LIGHTCAP_DESCALE // Explodes if you exceed 1.0 (Normally 0.7 for snappy non-IMU response) +#define CORRECT_TELESCOPTION_COEFFICIENT (10.f*LIGHTCAP_DESCALE) // Converges even as high as 10.0 and doesn't explode. (Normally 7.0 for non-IMU respone) + #define CORRECT_ROTATION_COEFFICIENT \ 0.2 // This starts to fall apart above 5.0, but for good reason. It is amplified by the number of points seen. #define ROTATIONAL_CORRECTION_MAXFORCE 0.01 @@ -57,30 +60,43 @@ typedef struct { SurviveIMUTracker tracker; SurvivePose * lastlhp; + + + //Additional flags, used when we start to try to use the accelerometer + LinmathPoint3d average_accelerometer_up_vector_in_world_space; + LinmathPoint3d velocity_according_to_accelerometer; } CharlesPoserData; void AdjustRotation( SurviveObject *so, LinmathQuat adjustment, int is_imu, int is_coarse ) { CharlesPoserData *dd = so->PoserData; - + //LinmathQuat invert_adjust; + //quatgetreciprocal( invert_adjust, adjustment ); quatrotateabout(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot, adjustment ); quatnormalize(dd->InteralPoseUsedForCalc.Rot, dd->InteralPoseUsedForCalc.Rot); - //XXX TODO: Calibrate the gyroscope using the lightcap. - - //Always update the accelerometer zero based on the gyro. - //quatrotatevector( dd->imu_accel_zero, applygyro, dd->imu_accel_zero ); - //Always update the system-corrective quat based on the gyro. - //quatrotateabout( dd->imu_up_correct, dd->imu_up_correct, applygyro ); } -void AdjustPosition( SurviveObject * so, LinmathPoint3d adjustment, int is_imu ) +void AdjustPosition( SurviveObject * so, LinmathPoint3d adjustment, int is_imu, float descale ) { CharlesPoserData *dd = so->PoserData; add3d( dd->InteralPoseUsedForCalc.Pos, adjustment, dd->InteralPoseUsedForCalc.Pos); add3d( dd->mixed_output, adjustment, dd->mixed_output); + + if( descale > 0.0001 ) + { + LinmathPoint3d backflow; + scale3d( backflow, adjustment, 1./descale ); + CharlesPoserData *dd = so->PoserData; + //scale3d( dd->velocity_according_to_accelerometer, dd->velocity_according_to_accelerometer, 0.9 ); + + //XXX XXX XXX BIG TODO!!! If we are updating based on lightcap, we should back-adjust the acceleration. + //Also, figure out how to dampen velocity. + add3d( dd->velocity_according_to_accelerometer, dd->velocity_according_to_accelerometer, backflow ); + } + } //Emits "dd->mixed_output" for position and dd->InteralPoseUsedForCalc.Rot for rotation. @@ -90,7 +106,16 @@ void EmitPose( SurviveObject *so, PoserData *pd ) SurvivePose object_pose_out; copy3d( object_pose_out.Pos, dd->mixed_output ); + + //average_accelerometer_up_vector_in_world_space should be "up" + LinmathVec3d true_up = { 0, 0, 1 }; + LinmathVec3d dist_up; + normalize3d( dist_up, dd->average_accelerometer_up_vector_in_world_space ); //NOTE: Average vector probably won't be normalized. + LinmathQuat adjustment_from_rerighting_up; + quatfrom2vectors( adjustment_from_rerighting_up, dist_up, true_up ); + quatcopy( object_pose_out.Rot, dd->InteralPoseUsedForCalc.Rot ); + quatrotateabout( object_pose_out.Rot, adjustment_from_rerighting_up, dd->InteralPoseUsedForCalc.Rot ); PoserData_poser_pose_func(pd, so, &object_pose_out); } @@ -104,7 +129,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { SurvivePose object_pose_out; memcpy(&object_pose_out, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); memcpy(&dd->InteralPoseUsedForCalc, &LinmathPose_Identity, sizeof(LinmathPose_Identity)); - //memcpy(&dd->imu_up_correct, &LinmathQuat_Identity, sizeof(LinmathQuat_Identity) ); so->PoseConfidence = 0.0; PoserData_poser_pose_func(pd, so, &object_pose_out); } @@ -115,9 +139,6 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { float imu_time = 1./ so->imu_freq; // Really should use this... PoserDataIMU *imuData = (PoserDataIMU *)pd; - SurvivePose object_pose_out; - LinmathQuat object_to_world_with_imu_up_correct; - LinmathQuat world_space_to_object_space_quat; { LinmathQuat applygyro; @@ -128,6 +149,39 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { AdjustRotation( so, applygyro, 1, 0 ); } + { + LinmathPoint3d rotated_out; + quatrotatevector( rotated_out, dd->InteralPoseUsedForCalc.Rot, imuData->accel ); + + if( so->PoseConfidence > 0.9999 ) + { + LinmathPoint3d correction; + + //XXX Danger, will robinson. + //We are doing an IIR on the acceleration. Tests have shown THIS IS BAD. We should try to correct based on the lightcap data. + scale3d( dd->average_accelerometer_up_vector_in_world_space, dd->average_accelerometer_up_vector_in_world_space, .9999 ); + scale3d( correction, rotated_out, .0001 ); + add3d( dd->average_accelerometer_up_vector_in_world_space, dd->average_accelerometer_up_vector_in_world_space, correction ); + + LinmathPoint3d deviation; + sub3d( deviation, rotated_out, dd->average_accelerometer_up_vector_in_world_space ); + + LinmathPoint3d acc; + scale3d( acc, deviation, 9.8*imu_time ); + add3d( dd->velocity_according_to_accelerometer, acc, dd->velocity_according_to_accelerometer ); + scale3d( dd->velocity_according_to_accelerometer, dd->velocity_according_to_accelerometer, .999 ); //XXX Danger! We are doing an IIR on velocity. This is dangerous. + + LinmathPoint3d posdiff; + scale3d( posdiff, dd->velocity_according_to_accelerometer, imu_time ); + AdjustPosition( so, posdiff, 1, 0 ); + } + else + { + copy3d( dd->average_accelerometer_up_vector_in_world_space, rotated_out ); + scale3d( dd->velocity_according_to_accelerometer, dd->velocity_according_to_accelerometer, 0 ); + } + } + EmitPose( so, pd ); return 0; } @@ -353,7 +407,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { so->PoseConfidence *= 0.9; } } - AdjustPosition( so, vec_correct, 0 ); + AdjustPosition( so, vec_correct, 0, (applied_corrections==2)?LIGHTCAP_DESCALE:0 ); } // Stage 4: "Tug" on the rotation of the object, from all of the sensor's pov. -- cgit v1.2.3 From 07196617669b844cbc4b15fbdaa5d0d1de6c7508 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Mon, 25 Jun 2018 02:30:08 +0000 Subject: nerf motion a little more. --- src/poser_charlesrefine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index de732fe..4e6e34f 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -159,8 +159,8 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { //XXX Danger, will robinson. //We are doing an IIR on the acceleration. Tests have shown THIS IS BAD. We should try to correct based on the lightcap data. - scale3d( dd->average_accelerometer_up_vector_in_world_space, dd->average_accelerometer_up_vector_in_world_space, .9999 ); - scale3d( correction, rotated_out, .0001 ); + scale3d( dd->average_accelerometer_up_vector_in_world_space, dd->average_accelerometer_up_vector_in_world_space, .999 ); + scale3d( correction, rotated_out, .001 ); add3d( dd->average_accelerometer_up_vector_in_world_space, dd->average_accelerometer_up_vector_in_world_space, correction ); LinmathPoint3d deviation; -- cgit v1.2.3 From fc9bdfa45e8ad1e4eeefc272db077a25af542a82 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Mon, 25 Jun 2018 00:56:58 -0400 Subject: Add blacklisting of devices, as well as improve feedback algorithm for charlesrefine. --- src/poser_charlesrefine.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index 4e6e34f..a55bc97 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -20,7 +20,7 @@ #define HIT_QUALITY_BASELINE \ 0.0001 // Determines which hits to cull. Actually SQRT(baseline) if 0.0001, it is really 1cm -#define LIGHTCAP_DESCALE 0.5 //DO NOT EXCEED 0.7 +#define LIGHTCAP_DESCALE 0.2 //DO NOT EXCEED 0.7 #define CORRECT_LATERAL_POSITION_COEFFICIENT LIGHTCAP_DESCALE // Explodes if you exceed 1.0 (Normally 0.7 for snappy non-IMU response) #define CORRECT_TELESCOPTION_COEFFICIENT (10.f*LIGHTCAP_DESCALE) // Converges even as high as 10.0 and doesn't explode. (Normally 7.0 for non-IMU respone) @@ -85,16 +85,15 @@ void AdjustPosition( SurviveObject * so, LinmathPoint3d adjustment, int is_imu, add3d( dd->InteralPoseUsedForCalc.Pos, adjustment, dd->InteralPoseUsedForCalc.Pos); add3d( dd->mixed_output, adjustment, dd->mixed_output); - if( descale > 0.0001 ) + if( descale > 0.0001 ) //Coming from lightcap. { LinmathPoint3d backflow; - scale3d( backflow, adjustment, 1./descale ); + scale3d( backflow, adjustment, 1.0/descale ); CharlesPoserData *dd = so->PoserData; - //scale3d( dd->velocity_according_to_accelerometer, dd->velocity_according_to_accelerometer, 0.9 ); - - //XXX XXX XXX BIG TODO!!! If we are updating based on lightcap, we should back-adjust the acceleration. - //Also, figure out how to dampen velocity. + //XXX TODO figure out how to dampen velocity. add3d( dd->velocity_according_to_accelerometer, dd->velocity_according_to_accelerometer, backflow ); + scale3d( backflow, backflow, .001 ); + add3d( dd->average_accelerometer_up_vector_in_world_space, dd->average_accelerometer_up_vector_in_world_space, backflow ); } } @@ -149,6 +148,9 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { AdjustRotation( so, applygyro, 1, 0 ); } + + printf( "ACCEL %f %f %f\n", PFTHREE( imuData->accel ) ); + { LinmathPoint3d rotated_out; quatrotatevector( rotated_out, dd->InteralPoseUsedForCalc.Rot, imuData->accel ); -- cgit v1.2.3 From a0f4e2b3265ae242772f7a69bf6e096a2def64b3 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Mon, 25 Jun 2018 01:06:08 -0400 Subject: Bump refine. --- src/poser_charlesrefine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index a55bc97..d0d5b17 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -149,7 +149,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { } - printf( "ACCEL %f %f %f\n", PFTHREE( imuData->accel ) ); + //printf( "ACCEL %f %f %f\n", PFTHREE( imuData->accel ) ); { LinmathPoint3d rotated_out; -- cgit v1.2.3 From 7a16dc316c23d55453174c56fbff89f043db3552 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Mon, 25 Jun 2018 05:56:05 +0000 Subject: add additional comments about where to go from here. --- src/poser_charlesrefine.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/poser_charlesrefine.c') diff --git a/src/poser_charlesrefine.c b/src/poser_charlesrefine.c index d0d5b17..e95b621 100644 --- a/src/poser_charlesrefine.c +++ b/src/poser_charlesrefine.c @@ -13,6 +13,11 @@ #define MAX_PT_PER_SWEEP SENSORS_PER_OBJECT +/* + More notes to self: + try updating expected lighthouse position against each lighthouse with imu data and don't tie them to each other. + +*/ // Tunable parameters: @@ -155,7 +160,7 @@ int PoserCharlesRefine(SurviveObject *so, PoserData *pd) { LinmathPoint3d rotated_out; quatrotatevector( rotated_out, dd->InteralPoseUsedForCalc.Rot, imuData->accel ); - if( so->PoseConfidence > 0.9999 ) + if( so->PoseConfidence > 0.6 ) { LinmathPoint3d correction; -- cgit v1.2.3