# HG changeset patch # User Paul Boddie # Date 1381767681 0 # Node ID ca7f7e9b8be5e34706695c22cb4ba90ed3bee3e5 # Parent 76d46d9d2322ba7b7b4097c25d2470dfdb58b391 Switched to using the dynamic field vector and the static y axis to produce the magnetic north vector, although it is unreliable, probably because of "soft iron distortion". diff -r 76d46d9d2322 -r ca7f7e9b8be5 main.c --- a/main.c Mon Oct 14 16:17:00 2013 +0000 +++ b/main.c Mon Oct 14 16:21:21 2013 +0000 @@ -37,7 +37,7 @@ vectorf _viewx, _viewy, _viewz, _accelerationD, _accelerationRD, - _fieldD; + _fieldD, _fieldN; /* Timekeeping. */ @@ -190,6 +190,8 @@ flush(); } + /* Additional textual output. */ + printf("Period? %d\n", imu_period); printf("Direction? %.4f\n", raddeg(direction)); printf("Elevation? %.4f (%.4f)\n", raddeg(elevation), raddeg(elevationA)); @@ -210,6 +212,7 @@ _accelerationD = accelerationD; _accelerationRD = accelerationRD; _fieldD = fieldD; + _fieldN = fieldN; pthread_mutex_unlock(&mutex); clear(); @@ -226,6 +229,11 @@ _fieldD.z *= 10; gui_point(&_viewx, &_viewy, &_viewz, &_fieldD, 0, 0, 255, 127); + _fieldN.x *= 10; + _fieldN.y *= 10; + _fieldN.z *= 10; + gui_point(&_viewx, &_viewy, &_viewz, &_fieldN, 255, 0, 0, 127); + flush(); gui_updated = now; diff -r 76d46d9d2322 -r ca7f7e9b8be5 measure.c --- a/measure.c Mon Oct 14 16:17:00 2013 +0000 +++ b/measure.c Mon Oct 14 16:21:21 2013 +0000 @@ -233,11 +233,11 @@ directionF0 = vectorf_direction(&field0); elevationF0 = vectorf_elevation(&field0); - /* Determine the east and north vectors using static field information. */ + /* Determine the east and north vectors using dynamic field information. */ - vectorf_cross(&accelerationRD, &fieldD0, &fieldE); + vectorf_cross(&viewy0, &fieldD, &fieldE); vectorf_normalise(&fieldE, &fieldE); - vectorf_cross(&fieldE, &accelerationRD, &fieldN); + vectorf_cross(&fieldE, &viewy0, &fieldN); } /* Subtract the constant background acceleration. */