From a015a5bc3631f813281c5af85a29b9d84a3eb924 Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Tue, 19 Dec 2017 23:30:52 -0700 Subject: Add support for using only 1 lighthouse Change adds a config option for the number of "active" lighthouses, which can be 1. Calibrate will run with a single lighthouse if the new config option LighthouseCount is set to 1. --- calibrate.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'calibrate.c') diff --git a/calibrate.c b/calibrate.c index 43643b3..8c56e43 100644 --- a/calibrate.c +++ b/calibrate.c @@ -14,6 +14,7 @@ struct SurviveContext * ctx; int quit = 0; +static LighthouseCount = 0; void HandleKey( int keycode, int bDown ) { @@ -343,6 +344,7 @@ void * SurviveThread(void *jnk) { ctx = survive_init( 0 ); + uint8_t i =0; for (i=0;i<32;++i) { sensor_name[i] = malloc(3); -- cgit v1.2.3 From 417ced84b51bfcc392f06a87a1328f679364fc38 Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Sat, 23 Dec 2017 12:49:42 -0700 Subject: Make Config Display a little more intuitive Changed the position markers to indicate +x as the "flagged" direction. Since the lighthouses face +x (based on arbitrary decision months ago), this makes their display more logical. --- calibrate.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'calibrate.c') diff --git a/calibrate.c b/calibrate.c index 88f8288..8fb0986 100644 --- a/calibrate.c +++ b/calibrate.c @@ -238,30 +238,30 @@ void DisplayPose(SurvivePose pose, size_t xResolution, size_t yResolution) yResolution -(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); } - // Small line to indicate (0,+y) + // Small line to indicate (+x,0) { FLT tmp1[3]; FLT tmp1out[3]; FLT tmp2[3]; FLT tmp2out[3]; - tmp1[1] = minRectSize + ((pose.Pos[2] * 40.0)); + tmp1[0] = minRectSize + ((pose.Pos[2] * 40.0)); tmp1[2] = 0; - tmp1[0] = tmp1[1] * 0.3; + tmp1[1] = tmp1[0] * 0.3; quatrotatevector(tmp1out, pose.Rot, tmp1); - tmp2[1] = minRectSize + ((pose.Pos[2] * 40.0)); + tmp2[0] = minRectSize + ((pose.Pos[2] * 40.0)); tmp2[2] = 0; - tmp2[0] = -(tmp1[1] * 0.3); + tmp2[1] = -(tmp1[0] * 0.3); quatrotatevector(tmp2out, pose.Rot, tmp2); CNFGTackSegment( (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp1out[0]), - yResolution -(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp1out[1]), + yResolution - (short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp1out[1]), (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp2out[0]), - yResolution -(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); + yResolution - (short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); } -- cgit v1.2.3 From ec564d70daa8c1a66018f9606b02b873ae792c84 Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Thu, 28 Dec 2017 08:03:37 -0700 Subject: Start work on determining rotation using quaternions only Rotation was previously approximated using axis/angle This change starts down the path of using quaternions exclusively. This change appears to give at least as good as answers as the axis/angle model in basic cases (also only tested with 1 lighthouse), but it is currently much slower and runs in unpredictable time. --- calibrate.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 8 deletions(-) (limited to 'calibrate.c') diff --git a/calibrate.c b/calibrate.c index 8fb0986..cfd3e17 100644 --- a/calibrate.c +++ b/calibrate.c @@ -207,9 +207,9 @@ void DisplayPose(SurvivePose pose, size_t xResolution, size_t yResolution) CNFGTackSegment( (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp1out[0]), - yResolution-(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp1out[1]), + (short)yResolution-(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp1out[1]), (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp2out[0]), - yResolution -(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); + (short)yResolution -(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); } // line for the (0,-y) to (0,+y)) @@ -233,11 +233,36 @@ void DisplayPose(SurvivePose pose, size_t xResolution, size_t yResolution) CNFGTackSegment( (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp1out[0]), - yResolution -(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp1out[1]), + (short)yResolution -(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp1out[1]), (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp2out[0]), - yResolution -(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); + (short)yResolution -(short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); } + // Small line to indicate (0,+y) + { + FLT tmp1[3]; + FLT tmp1out[3]; + FLT tmp2[3]; + FLT tmp2out[3]; + + tmp1[1] = minRectSize + ((pose.Pos[2] * 40.0)*1.3); + tmp1[2] = 0; + tmp1[0] = ((pose.Pos[2] * 40.0)) * 0.3; + + quatrotatevector(tmp1out, pose.Rot, tmp1); + + tmp2[1] = minRectSize + ((pose.Pos[2] * 40.0)*0.7); + tmp2[2] = 0; + tmp2[0] = -(((pose.Pos[2] * 40.0)) * 0.3); + + quatrotatevector(tmp2out, pose.Rot, tmp2); + + CNFGTackSegment( + (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp1out[0]), + (short)yResolution - (short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp1out[1]), + (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp2out[0]), + (short)yResolution - (short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); + } // Small line to indicate (+x,0) { FLT tmp1[3]; @@ -245,13 +270,38 @@ void DisplayPose(SurvivePose pose, size_t xResolution, size_t yResolution) FLT tmp2[3]; FLT tmp2out[3]; - tmp1[0] = minRectSize + ((pose.Pos[2] * 40.0)); + tmp1[0] = minRectSize + ((pose.Pos[2] * 40.0)*1.3); tmp1[2] = 0; tmp1[1] = tmp1[0] * 0.3; quatrotatevector(tmp1out, pose.Rot, tmp1); - tmp2[0] = minRectSize + ((pose.Pos[2] * 40.0)); + tmp2[0] = minRectSize + ((pose.Pos[2] * 40.0)*.7); + tmp2[2] = 0; + tmp2[1] = -(tmp1[0] * 0.3); + + quatrotatevector(tmp2out, pose.Rot, tmp2); + + CNFGTackSegment( + (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp1out[0]), + (short)yResolution - (short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp1out[1]), + (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp2out[0]), + (short)yResolution - (short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); + } + // Small line to indicate (+x,0) + { + FLT tmp1[3]; + FLT tmp1out[3]; + FLT tmp2[3]; + FLT tmp2out[3]; + + tmp1[0] = minRectSize + ((pose.Pos[2] * 40.0)*.7); + tmp1[2] = 0; + tmp1[1] = tmp1[0] * 0.3; + + quatrotatevector(tmp1out, pose.Rot, tmp1); + + tmp2[0] = minRectSize + ((pose.Pos[2] * 40.0)*1.3); tmp2[2] = 0; tmp2[1] = -(tmp1[0] * 0.3); @@ -259,9 +309,9 @@ void DisplayPose(SurvivePose pose, size_t xResolution, size_t yResolution) CNFGTackSegment( (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp1out[0]), - yResolution - (short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp1out[1]), + (short)yResolution - (short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp1out[1]), (short)(windowCenterX + (pose.Pos[0] * sizeScale) + tmp2out[0]), - yResolution - (short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); + (short)yResolution - (short)(windowCenterY + (pose.Pos[1] * sizeScale) + tmp2out[1])); } -- cgit v1.2.3 From c570809ce1d1cc1d30ef4db547e6388b3fd80ac1 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Mon, 15 Jan 2018 17:10:55 +0100 Subject: fix various -Wall warnings --- calibrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'calibrate.c') diff --git a/calibrate.c b/calibrate.c index cfd3e17..ff3b774 100644 --- a/calibrate.c +++ b/calibrate.c @@ -14,7 +14,7 @@ struct SurviveContext * ctx; int quit = 0; -static LighthouseCount = 0; +static int LighthouseCount = 0; void HandleKey( int keycode, int bDown ) { -- cgit v1.2.3