summaryrefslogtreecommitdiffhomepage
path: root/logic
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-28 02:01:42 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-28 02:01:42 +0200
commitcca9299636ac2f2768256aef2d527d1be22b1616 (patch)
treeb887a9b0617d9e9fcb4820e6d5316dd80b84c178 /logic
parenteb24176b266e2406979ec4daf1c5ea73f356efef (diff)
logic/tracker: sanitize tracker's euler angles
Issue: #465 Reported-by: @topiq77
Diffstat (limited to 'logic')
-rw-r--r--logic/tracker.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/logic/tracker.cpp b/logic/tracker.cpp
index bfc95eed..325381ee 100644
--- a/logic/tracker.cpp
+++ b/logic/tracker.cpp
@@ -136,6 +136,16 @@ void Tracker::logic()
raw(i) = newpose(i);
}
+ // hatire, udp, and freepie trackers can mess up here
+ for (unsigned i = 3; i < 6; i++)
+ {
+ using std::fmod;
+ using std::copysign;
+
+ const double x = value(i);
+ value(i) = fmod(x + copysign(180, x), 360) - copysign(180, x);
+ }
+
logger.write_pose(raw); // raw
if (is_nan(raw))