summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-09 11:39:46 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-09 11:39:46 +0200
commit40a00851315e193f19ab71e516fbb4c135f44f03 (patch)
tree132cbe200a185712b8c0af8f717c073e729b941f
parente52f4f6e9df4634c9f01b84c73e30c06ad5e6dc6 (diff)
logic/tracker: simplify
- no need to declare "inverts" as an array. it's used in only one place - class Pose is redundant, use an alias for Mat<...> - declare static constexpr const for logger stuff
-rw-r--r--opentrack-logic/tracker.cpp19
-rw-r--r--opentrack-logic/tracker.h19
2 files changed, 6 insertions, 32 deletions
diff --git a/opentrack-logic/tracker.cpp b/opentrack-logic/tracker.cpp
index f36591e4..746a29f4 100644
--- a/opentrack-logic/tracker.cpp
+++ b/opentrack-logic/tracker.cpp
@@ -115,15 +115,6 @@ constexpr double Tracker::c_div;
void Tracker::logic()
{
- bool inverts[6] = {
- m(0).opts.invert,
- m(1).opts.invert,
- m(2).opts.invert,
- m(3).opts.invert,
- m(4).opts.invert,
- m(5).opts.invert,
- };
-
using namespace euler;
Pose value, raw;
@@ -255,7 +246,7 @@ void Tracker::logic()
value(i) += m(i).opts.zero;
for (int i = 0; i < 6; i++)
- value(i) *= int(inverts[i]) * -2 + 1;
+ value(i) *= int(m(i).opts.invert) * -2 + 1;
if (zero_)
for (int i = 0; i < 6; i++)
@@ -314,13 +305,13 @@ void Tracker::run()
#endif
{
- const char* posechannels[6] = { "TX", "TY", "TZ", "Yaw", "Pitch", "Roll" };
- const char* datachannels[5] = { "dt", "raw", "corrected", "filtered", "mapped" };
+ static constexpr const char* posechannels[6] = { "TX", "TY", "TZ", "Yaw", "Pitch", "Roll" };
+ static constexpr const char* datachannels[5] = { "dt", "raw", "corrected", "filtered", "mapped" };
logger.write(datachannels[0]);
char buffer[128];
- for (int j = 1; j < 5; ++j)
+ for (unsigned j = 1; j < 5; ++j)
{
- for (int i = 0; i < 6; ++i)
+ for (unsigned i = 0; i < 6; ++i)
{
snprintf(buffer, 128, "%s%s", datachannels[j], posechannels[i]);
logger.write(buffer);
diff --git a/opentrack-logic/tracker.h b/opentrack-logic/tracker.h
index 09aca424..58b478bb 100644
--- a/opentrack-logic/tracker.h
+++ b/opentrack-logic/tracker.h
@@ -27,24 +27,7 @@
#include "export.hpp"
-class Pose
-{
-private:
- static constexpr double pi = OPENTRACK_PI;
- static constexpr double d2r = pi/180.0;
- static constexpr double r2d = 180./pi;
-
- double axes[6];
-public:
- Pose() : axes {0,0,0, 0,0,0} {}
- Pose(double x, double y, double z, double yaw, double pitch, double roll) : axes { x, y, z, yaw, pitch, roll } {}
-
- inline operator double*() { return axes; }
- inline operator const double*() const { return axes; }
-
- inline double& operator()(int i) { return axes[i]; }
- inline double operator()(int i) const { return axes[i]; }
-};
+using Pose = Mat<double, 6, 1>;
class OPENTRACK_LOGIC_EXPORT Tracker : private QThread
{