Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c234b1b authored by Ytai Ben-Tsvi's avatar Ytai Ben-Tsvi
Browse files

Fix head-pose prediction bug and increase time

The pose processor works in "tick" time units, so the velocities
passed to it need to be scaled accordingly.

Also increase prediction time to 50ms (for now) to make it more
noticeable.

Test: Manual verification.
Change-Id: I842049f497cfc1824ee33f0bcc85349916b20bc3
parent cdd7a4c2
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -56,6 +56,16 @@ class Twist3f {
               mRotationalVelocity.isApprox(other.mRotationalVelocity, prec);
    }

    template<typename T>
    Twist3f operator*(const T& s) const {
        return Twist3f(mTranslationalVelocity * s, mRotationalVelocity * s);
    }

    template<typename T>
    Twist3f operator/(const T& s) const {
        return Twist3f(mTranslationalVelocity / s, mRotationalVelocity / s);
    }

  private:
    Eigen::Vector3f mTranslationalVelocity;
    Eigen::Vector3f mRotationalVelocity;
+3 −2
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ constexpr auto kRotationalDriftTimeConstant = 60s;
// twist (velocity). It should be set to a value that matches the characteristic durations of moving
// one's head. The higher we set this, the more latency we are able to reduce, but setting this too
// high will result in high prediction errors whenever the head accelerates (changes velocity).
constexpr auto kPredictionDuration = 10ms;
constexpr auto kPredictionDuration = 50ms;

// After losing this many consecutive samples from either sensor, we would treat the measurement as
// stale;
@@ -253,7 +253,8 @@ void SpatializerPoseController::onPose(int64_t timestamp, int32_t sensor, const
                                       const std::optional<Twist3f>& twist, bool isNewReference) {
    std::lock_guard lock(mMutex);
    if (sensor == mHeadSensor) {
        mProcessor->setWorldToHeadPose(timestamp, pose, twist.value_or(Twist3f()));
        mProcessor->setWorldToHeadPose(timestamp, pose,
                                       twist.value_or(Twist3f()) / kTicksPerSecond);
        if (isNewReference) {
            mProcessor->recenter(true, false);
        }