diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-12-06 08:10:27 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-12-06 08:11:01 +0100 |
commit | c804162354aabf6d9a6f0528cdb216c2203b760d (patch) | |
tree | d9f7c37f5d6f1293e2035aa05d41e89db44e9506 /logic/pipeline.cpp | |
parent | 8ca38ae2a9dc59ab61cb17ee5c550fd36f1fd050 (diff) |
logic/pipeline: center through arithmetic only
This is incorrect but people like it.
Diffstat (limited to 'logic/pipeline.cpp')
-rw-r--r-- | logic/pipeline.cpp | 51 |
1 files changed, 11 insertions, 40 deletions
diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index eb5ac17a..357b213c 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -292,26 +292,12 @@ void pipeline::set_center_pose(const Pose& value, bool own_center_logic) libs.pFilter->center(); if (own_center_logic) - { - scaled_state.inv_rot_center = rmat::eye(); - scaled_state.t_center = {}; - } + center = {}; else - { - scaled_state.inv_rot_center = scaled_state.rotation.t(); - scaled_state.t_center = (const double*)(value); - } + center = value; } } -void pipeline::store_tracker_pose(const Pose& value) -{ - // alas, this is poor man's gimbal lock "prevention" - // this is some kind of "canonical" representation, - // if we can even talk of one - scaled_state.rotation = euler_to_rmat(scale_inv_c * d2r * euler_t(&value[Yaw])); -} - Pose pipeline::clamp_value(Pose value) const { // hatire, udp, and freepie trackers can mess up here @@ -330,28 +316,14 @@ Pose pipeline::clamp_value(Pose value) const Pose pipeline::apply_center(Pose value) const { - euler_t T = euler_t(value) - scaled_state.t_center; - euler_t R = scale_c * rmat_to_euler(scaled_state.rotation * scaled_state.inv_rot_center); + // this is incorrect but people like it + value = value - center; - // XXX check these lines, it's been here forever - T = rel.rotate(euler_to_rmat(R), T, {}); - - for (int i = 0; i < 3; i++) - { + for (int i = 0; i < 6; i++) // don't invert after reltrans // inverting here doesn't break centering - - if (m(i+3).opts.invert) - R(i) = -R(i); if (m(i).opts.invert) - T(i) = -T(i); - } - - for (int i = 0; i < 3; i++) - { - value(i) = T(i); - value(i+3) = R(i) * r2d; - } + value(i) = -value(i); return value; } @@ -449,8 +421,6 @@ void pipeline::logic() value = clamp_value(value); { - store_tracker_pose(value); - maybe_enable_center_on_tracking_started(); set_center_pose(value, own_center_logic); value = apply_center(value); @@ -463,10 +433,11 @@ void pipeline::logic() ev.run_events(EV::ev_before_filter, value); // we must proceed with all the filtering since the filter // needs fresh values to prevent deconvergence - Pose tmp = maybe_apply_filter(value); - nan_check(tmp); - if (!center_ordered) - value = tmp; + if (center_ordered) + (void)maybe_apply_filter(value); + else + value = maybe_apply_filter(value); + nan_check(value); logger.write_pose(value); // "filtered" } |