diff --git a/libs/vr/libposepredictor/Android.bp b/libs/vr/libposepredictor/Android.bp
deleted file mode 100644
index 2f1d2f5..0000000
--- a/libs/vr/libposepredictor/Android.bp
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (C) 2008 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-sourceFiles = [
-    "predictor.cpp",
-    "buffered_predictor.cpp",
-    "linear_predictor.cpp",
-    "polynomial_predictor.cpp",
-    "dvr_pose_predictor.cpp",
-]
-
-includeFiles = [
-    "include",
-]
-
-staticLibraries = ["libvrsensor"]
-
-sharedLibraries = []
-
-headerLibraries = [ "libeigen" ]
-
-cc_library {
-    srcs: sourceFiles,
-    cflags: [
-      "-DLOG_TAG=\"libposepredictor\"",
-      "-DTRACE=0",
-    ],
-    export_include_dirs: includeFiles,
-    static_libs: staticLibraries,
-    shared_libs: sharedLibraries,
-    header_libs: headerLibraries,
-    export_header_lib_headers: headerLibraries,
-    name: "libposepredictor",
-}
-
-cc_test {
-    tags: ["optional"],
-    srcs: [
-        "predictor_tests.cpp",
-        "linear_predictor_tests.cpp",
-        "polynomial_predictor_tests.cpp",
-    ],
-
-    static_libs: ["libposepredictor"] + staticLibraries,
-    shared_libs: sharedLibraries,
-    name: "pose_predictor_tests",
-}
diff --git a/libs/vr/libposepredictor/buffered_predictor.cpp b/libs/vr/libposepredictor/buffered_predictor.cpp
deleted file mode 100644
index f3b41dc..0000000
--- a/libs/vr/libposepredictor/buffered_predictor.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <buffered_predictor.h>
-
-namespace posepredictor {
-
-BufferedPredictor::BufferedPredictor(size_t buffer_size) {
-  buffer_.resize(buffer_size);
-}
-
-void BufferedPredictor::BufferSample(const Pose& sample) {
-  const auto& prev_sample = buffer_[current_pose_index_];
-
-  // If we are updating a sample (the same time stamp), do not advance the
-  // counter.
-  if (sample.time_ns != prev_sample.time_ns) {
-    current_pose_index_ = (current_pose_index_ + 1) % buffer_.size();
-  }
-
-  buffer_[current_pose_index_] = sample;
-
-  // Make sure the subsequent orientations are the closest in quaternion space.
-  if (PrevSample(1).orientation.coeffs().dot(sample.orientation.coeffs()) < 0) {
-    // Flip the quaternion to be closest to the previous sample.
-    buffer_[current_pose_index_].orientation =
-        quat(-sample.orientation.w(), -sample.orientation.x(),
-             -sample.orientation.y(), -sample.orientation.z());
-  }
-
-  ++num_poses_added_;
-}
-
-const Pose& BufferedPredictor::PrevSample(size_t index) const {
-  // We must not request a pose too far in the past.
-  assert(index < buffer_.size());
-  return buffer_[(current_pose_index_ - index + buffer_.size()) %
-                 buffer_.size()];
-}
-
-}  // namespace posepredictor
diff --git a/libs/vr/libposepredictor/dvr_pose_predictor.cpp b/libs/vr/libposepredictor/dvr_pose_predictor.cpp
deleted file mode 100644
index 7f2ecc0..0000000
--- a/libs/vr/libposepredictor/dvr_pose_predictor.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-#include <private/dvr/dvr_pose_predictor.h>
-
-namespace android {
-namespace dvr {
-
-namespace {
-template <typename Vec3Type>
-float32x4_t FromVec3(const Vec3Type& from) {
-  return {static_cast<float>(from.x()), static_cast<float>(from.y()),
-          static_cast<float>(from.z()), 0};
-}
-
-template <typename QuatType>
-float32x4_t FromQuat(const QuatType& from) {
-  return {static_cast<float>(from.x()), static_cast<float>(from.y()),
-          static_cast<float>(from.z()), static_cast<float>(from.w())};
-}
-
-}  //  namespace
-
-void AddPredictorPose(posepredictor::Predictor* predictor,
-                      const posepredictor::vec3& start_t_head,
-                      const posepredictor::quat& start_q_head,
-                      int64_t pose_timestamp, DvrPoseAsync* out) {
-  // Feed the predictor.
-  predictor->Add(
-      posepredictor::Pose{pose_timestamp, start_t_head, start_q_head});
-
-  // Fill the output.
-  out->timestamp_ns = pose_timestamp;
-
-  out->translation = FromVec3(start_t_head);
-  out->orientation = FromQuat(start_q_head);
-
-  out->right_translation = out->translation;
-  out->right_orientation = out->orientation;
-
-  const auto velocity = predictor->PredictVelocity(pose_timestamp);
-
-  out->velocity = FromVec3(velocity.linear);
-  out->angular_velocity = FromVec3(velocity.angular);
-
-  out->flags = DVR_POSE_FLAG_HEAD | DVR_POSE_FLAG_VALID;
-  memset(out->pad, 0, sizeof(out->pad));
-}
-
-void PredictPose(const posepredictor::Predictor* predictor, int64_t left_ns,
-                 int64_t right_ns, DvrPoseAsync* out) {
-  const auto left_pose = predictor->Predict(left_ns);
-  const auto right_pose = predictor->Predict(right_ns);
-  const auto velocity = predictor->PredictVelocity((left_ns + right_ns) / 2);
-
-  // Fill the output.
-  out->timestamp_ns = left_ns;
-
-  out->translation = FromVec3(left_pose.position);
-  out->orientation = FromQuat(left_pose.orientation);
-
-  out->right_translation = FromVec3(right_pose.position);
-  out->right_orientation = FromQuat(right_pose.orientation);
-
-  out->velocity = FromVec3(velocity.linear);
-  out->angular_velocity = FromVec3(velocity.angular);
-
-  out->flags = DVR_POSE_FLAG_HEAD | DVR_POSE_FLAG_VALID;
-  memset(out->pad, 0, sizeof(out->pad));
-}
-
-}  //  dvr
-}  //  android
diff --git a/libs/vr/libposepredictor/include/buffered_predictor.h b/libs/vr/libposepredictor/include/buffered_predictor.h
deleted file mode 100644
index eab0150..0000000
--- a/libs/vr/libposepredictor/include/buffered_predictor.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef POSEPREDICTOR_BUFFERED_PREDICTOR_H_
-#define POSEPREDICTOR_BUFFERED_PREDICTOR_H_
-
-#include <vector>
-
-#include "predictor.h"
-
-namespace posepredictor {
-
-// Keeps the previous n poses around in a ring buffer.
-// The orientations are also unrolled so that a . b > 0 for two subsequent
-// quaternions a and b.
-class BufferedPredictor : public Predictor {
- public:
-  BufferedPredictor(size_t buffer_size);
-  ~BufferedPredictor() = default;
-
- protected:
-  // Add a pose sample into the buffer.
-  void BufferSample(const Pose& sample);
-
-  // Grab a previous sample.
-  // index = 0: last sample
-  // index = 1: the one before that
-  // ...
-  const Pose& PrevSample(size_t index) const;
-
-  // Where we keep the last n poses.
-  std::vector<Pose> buffer_;
-
-  // Where the last valid pose is in the buffer.
-  size_t current_pose_index_ = 0;
-
-  // The number of poses we have added.
-  size_t num_poses_added_ = 0;
-};
-
-}  // namespace posepredictor
-
-#endif  // POSEPREDICTOR_BUFFERED_PREDICTOR_H_
diff --git a/libs/vr/libposepredictor/include/linear_predictor.h b/libs/vr/libposepredictor/include/linear_predictor.h
deleted file mode 100644
index 0d17ec5..0000000
--- a/libs/vr/libposepredictor/include/linear_predictor.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef POSEPREDICTOR_LINEAR_POSE_PREDICTOR_H_
-#define POSEPREDICTOR_LINEAR_POSE_PREDICTOR_H_
-
-#include "predictor.h"
-
-namespace posepredictor {
-
-// This class makes a linear prediction using the last two samples we received.
-class LinearPosePredictor : public Predictor {
- public:
-  LinearPosePredictor() = default;
-
-  // Add a new sample.
-  void Add(const Pose& sample) override;
-
-  // Predict using the last two samples.
-  Pose Predict(int64_t time_ns) const override;
-
-  // Just copy the velocity over.
-  Velocity PredictVelocity(int64_t time_ns) const override;
-
- private:
-  // The index of the last sample we received.
-  size_t current_index_ = 0;
-
-  // The previous two samples.
-  Pose samples_[2];
-
-  // Experimental
-  bool forward_predict_angular_speed_ = false;
-
-  // Transient variables updated when a sample is added.
-  vec3 velocity_ = vec3::Zero();
-  vec3 rotational_velocity_ = vec3::Zero();
-  vec3 rotational_axis_ = vec3::Zero();
-  real last_angular_speed_ = 0;
-  real angular_speed_ = 0;
-  real angular_accel_ = 0;
-};
-
-}  // namespace posepredictor
-
-#endif  // POSEPREDICTOR_LINEAR_POSE_PREDICTOR_H_
diff --git a/libs/vr/libposepredictor/include/polynomial_predictor.h b/libs/vr/libposepredictor/include/polynomial_predictor.h
deleted file mode 100644
index 4b8d51b..0000000
--- a/libs/vr/libposepredictor/include/polynomial_predictor.h
+++ /dev/null
@@ -1,168 +0,0 @@
-#ifndef POSEPREDICTOR_POLYNOMIAL_POSE_PREDICTOR_H_
-#define POSEPREDICTOR_POLYNOMIAL_POSE_PREDICTOR_H_
-
-#include <vector>
-
-#include <Eigen/Dense>
-
-#include "buffered_predictor.h"
-
-namespace posepredictor {
-
-// Make a polynomial prediction of the form
-// y = coefficients_[0] + coefficients_[1] * t + coefficients_[2] * t^2 + ...
-// where t is time and y is the position and orientation.
-// We recompute the coefficients whenever we add a new sample using
-// training_window previous samples.
-template <size_t PolynomialDegree, size_t TrainingWindow>
-class PolynomialPosePredictor : public BufferedPredictor {
- public:
-  PolynomialPosePredictor(real regularization = 1e-9)
-      : BufferedPredictor(TrainingWindow), regularization_(regularization) {
-    static_assert(TrainingWindow >= PolynomialDegree + 1,
-                  "Underconstrained polynomial regressor");
-  }
-
-  ~PolynomialPosePredictor() = default;
-
-  // We convert pose samples into a vector for matrix arithmetic using this
-  // mapping.
-  enum Components {
-    kPositionX = 0,
-    kPositionY,
-    kPositionZ,
-    kOrientationX,
-    kOrientationY,
-    kOrientationZ,
-    kOrientationW,
-    kNumComponents
-  };
-
-  // Add a new sample.
-  void Add(const Pose& sample) override {
-    // Add the sample to the ring buffer.
-    BufferedPredictor::BufferSample(sample);
-
-    Eigen::Matrix<real, TrainingWindow, kNumComponents> values;
-
-    // Get the pose samples into matrices for fitting.
-    real t_vector[TrainingWindow];
-    for (size_t i = 0; i < TrainingWindow; ++i) {
-      const auto& prev_sample = PrevSample(i);
-
-      t_vector[i] = NsToT(prev_sample.time_ns);
-
-      // Save the values we will be fitting to at each sample time.
-      values(i, kPositionX) = prev_sample.position.x();
-      values(i, kPositionY) = prev_sample.position.y();
-      values(i, kPositionZ) = prev_sample.position.z();
-      values(i, kOrientationX) = prev_sample.orientation.x();
-      values(i, kOrientationY) = prev_sample.orientation.y();
-      values(i, kOrientationZ) = prev_sample.orientation.z();
-      values(i, kOrientationW) = prev_sample.orientation.w();
-    }
-
-    // Some transient matrices for solving for coefficient matrix.
-    Eigen::Matrix<real, PolynomialDegree + 1, PolynomialDegree + 1> M;
-    Eigen::Matrix<real, PolynomialDegree + 1, 1> d;
-    Eigen::Matrix<real, PolynomialDegree + 1, 1> p;
-
-    // Create a polynomial fit for each component.
-    for (size_t component = 0; component < kNumComponents; ++component) {
-      // A = [ 1 t t^2 ... ]'
-      // x = [ coefficients[0] coefficients[1] .... ]'
-      // b = [ position.x ]'
-      // We would like to solve A' x + regularization * I = b'
-      // given the samples we have in our training window.
-      //
-      // The loop below will compute:
-      // M = A' * A
-      // d = A' * b
-      // so we can solve M * coefficients + regularization * I = b
-
-      M.setIdentity();
-      d.setZero();
-      p[0] = 1;
-
-      // M = regularization * I
-      M = M * regularization_;
-
-      // Accumulate the poses in the training window.
-      for (size_t i = 0; i < TrainingWindow; ++i) {
-        // Compute the polynomial at this sample.
-        for (size_t j = 1; j <= PolynomialDegree; ++j) {
-          p[j] = p[j - 1] * t_vector[i];
-        }
-
-        // Accumulate the left and right hand sides.
-        M = M + p * p.transpose();
-        d = d + p * values(i, component);
-      }
-
-      // M is symmetric, positive semi-definite.
-      // Note: This is not the most accurate solver out there but is fast.
-      coefficients_.row(component) = Eigen::LLT<Eigen::MatrixXd>(M).solve(d);
-    }
-  }
-
-  // Predict using the polynomial coefficients.
-  Pose Predict(int64_t time_ns) const override {
-    // Predict the left side.
-    const auto components = SamplePolynomial(time_ns);
-
-    return {time_ns,
-            vec3(components[kPositionX], components[kPositionY],
-                 components[kPositionZ]),
-            quat(components[kOrientationW], components[kOrientationX],
-                 components[kOrientationY], components[kOrientationZ])
-                .normalized()};
-  }
-
- private:
-  // Evaluate the polynomial at a particular time.
-  Eigen::Matrix<real, kNumComponents, 1> SamplePolynomial(
-      int64_t time_ns) const {
-    const auto t = NsToT(time_ns);
-    Eigen::Matrix<real, PolynomialDegree + 1, 1> polynomial;
-    real current_polynomial = t;
-
-    // Compute polynomial = [ 1 t t^2 ... ]
-    polynomial[0] = 1;
-    for (size_t degree = 1; degree <= PolynomialDegree;
-         ++degree, current_polynomial *= t) {
-      polynomial[degree] = polynomial[degree - 1] * t;
-    }
-
-    // The coefficients_ = [ numComponents x (polynomial degree + 1) ].
-    return coefficients_ * polynomial;
-  }
-
-  // Convert a time in nanoseconds to t.
-  // We could use the seconds as t but this would create make it more difficult
-  // to tweak the regularization amount. So we subtract the last sample time so
-  // the scale of the regularization constant doesn't change as a function of
-  // time.
-  real NsToT(int64_t time_ns) const {
-    return NsToSeconds(time_ns - buffer_[current_pose_index_].time_ns);
-  }
-
-  // The ridge regularization constant.
-  real regularization_;
-
-  // This is where we store the polynomial coefficients.
-  Eigen::Matrix<real, kNumComponents, PolynomialDegree + 1> coefficients_;
-};
-
-// Some common polynomial types.
-extern template class PolynomialPosePredictor<1, 2>;
-extern template class PolynomialPosePredictor<2, 3>;
-extern template class PolynomialPosePredictor<3, 4>;
-extern template class PolynomialPosePredictor<4, 5>;
-
-using QuadricPosePredictor = PolynomialPosePredictor<2, 3>;
-using CubicPosePredictor = PolynomialPosePredictor<3, 4>;
-using QuarticPosePredictor = PolynomialPosePredictor<4, 5>;
-
-}  // namespace posepredictor
-
-#endif  // POSEPREDICTOR_POLYNOMIAL_POSE_PREDICTOR_H_
diff --git a/libs/vr/libposepredictor/include/predictor.h b/libs/vr/libposepredictor/include/predictor.h
deleted file mode 100644
index 78db272..0000000
--- a/libs/vr/libposepredictor/include/predictor.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef POSEPREDICTOR_POSE_PREDICTOR_H_
-#define POSEPREDICTOR_POSE_PREDICTOR_H_
-
-#include <Eigen/Core>
-#include <Eigen/Geometry>
-
-// This is the only file you need to include for pose prediction.
-
-namespace posepredictor {
-
-// The precision for the predictor.
-// TODO(okana): double precision is probably not necessary.
-typedef double real;
-
-using vec3 = Eigen::Matrix<real, 3, 1>;
-using quat = Eigen::Quaternion<real>;
-
-// Encapsulates a pose sample.
-struct Pose {
-  int64_t time_ns = 0;
-  vec3 position = vec3::Zero();
-  quat orientation = quat::Identity();
-};
-
-// Encapsulates the derivative at a time.
-struct Velocity {
-  vec3 linear = vec3::Zero();
-  vec3 angular = vec3::Zero();
-};
-
-// The preset types we support.
-enum class PredictorType { Linear, Quadric, Cubic };
-
-// This is an abstract base class for prediction 6dof pose given
-// a set of samples.
-class Predictor {
- public:
-  Predictor() = default;
-  virtual ~Predictor() = default;
-
-  // The nanoseconds to use for finite differencing.
-  static constexpr int64_t kFiniteDifferenceNs = 100;
-
-  // Instantiate a new pose predictor for a type.
-  static std::unique_ptr<Predictor> Create(PredictorType type);
-
-  // Compute the angular velocity from orientation start_orientation to
-  // end_orientation in delta_time.
-  static vec3 AngularVelocity(const quat& start_orientation,
-                              const quat& end_orientation, real delta_time);
-
-  // Add a pose sample coming from the sensors.
-  virtual void Add(const Pose& sample) = 0;
-
-  // Make a pose prediction for at specific time.
-  virtual Pose Predict(int64_t time_ns) const = 0;
-
-  // Evaluate velocity at a particular time.
-  // The default implementation uses finite differencing.
-  virtual Velocity PredictVelocity(int64_t time_ns) const;
-
-  // Helpers
-  static real NsToSeconds(int64_t time_ns) {
-    return static_cast<real>(time_ns / 1e9);
-  }
-  static int64_t SecondsToNs(real seconds) {
-    return static_cast<int64_t>(seconds * 1e9);
-  }
-};
-
-}  // namespace posepredictor
-
-#endif  // POSEPREDICTOR_POSE_PREDICTOR_H_
diff --git a/libs/vr/libposepredictor/include/private/dvr/dvr_pose_predictor.h b/libs/vr/libposepredictor/include/private/dvr/dvr_pose_predictor.h
deleted file mode 100644
index bd2dcbc..0000000
--- a/libs/vr/libposepredictor/include/private/dvr/dvr_pose_predictor.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef ANDROID_DVR_POSE_PREDICTOR_H_
-#define ANDROID_DVR_POSE_PREDICTOR_H_
-
-#include <dvr/pose_client.h>
-#include <predictor.h>
-
-// Some shim functions for connecting dvr to pose predictor.
-
-namespace android {
-namespace dvr {
-
-// Feed a pose to the predictor.
-void AddPredictorPose(posepredictor::Predictor* predictor,
-                      const posepredictor::vec3& start_t_head,
-                      const posepredictor::quat& start_q_head,
-                      int64_t pose_timestamp, DvrPoseAsync* out);
-
-// Make a prediction for left and right eyes.
-void PredictPose(const posepredictor::Predictor* predictor, int64_t left_ns,
-                 int64_t right_ns, DvrPoseAsync* out);
-
-}  // namespace dvr
-}  // namespace android
-
-#endif  // ANDROID_DVR_POSE_PREDICTOR_H_
diff --git a/libs/vr/libposepredictor/linear_predictor.cpp b/libs/vr/libposepredictor/linear_predictor.cpp
deleted file mode 100644
index 6f924dc..0000000
--- a/libs/vr/libposepredictor/linear_predictor.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-#include <linear_predictor.h>
-
-namespace posepredictor {
-
-using AngleAxis = Eigen::AngleAxis<real>;
-
-void LinearPosePredictor::Add(const Pose& sample) {
-  // If we are receiving a new sample, move the index to the next item.
-  // If the time stamp is the same as the last frame, we will just overwrite
-  // it with the new data.
-  if (sample.time_ns != samples_[current_index_].time_ns) {
-    current_index_ ^= 1;
-  }
-
-  // Save the sample.
-  samples_[current_index_] = sample;
-
-  // The previous sample we received.
-  const auto& previous_sample = samples_[current_index_ ^ 1];
-
-  // Ready to compute velocities.
-  const auto pose_delta_time =
-      NsToSeconds(sample.time_ns - previous_sample.time_ns);
-
-  if (pose_delta_time > 0.0) {
-    velocity_ = (sample.position - previous_sample.position) / pose_delta_time;
-    rotational_velocity_ = Predictor::AngularVelocity(
-        previous_sample.orientation, sample.orientation, pose_delta_time);
-  } else {
-    velocity_ = vec3::Zero();
-    rotational_velocity_ = vec3::Zero();
-  }
-
-  // Temporary experiment with acceleration estimate.
-  angular_speed_ = rotational_velocity_.norm();
-  angular_accel_ = 0.0;
-  if (forward_predict_angular_speed_) {
-    angular_accel_ =
-        pose_delta_time > 0.0
-            ? (angular_speed_ - last_angular_speed_) / pose_delta_time
-            : 0.0;
-  }
-  last_angular_speed_ = angular_speed_;
-
-  rotational_axis_ = vec3(0.0, 1.0, 0.0);
-  if (angular_speed_ > 0.0) {
-    rotational_axis_ = rotational_velocity_ / angular_speed_;
-  }
-}
-
-Pose LinearPosePredictor::Predict(int64_t time_ns) const {
-  const auto& sample = samples_[current_index_];
-
-  const auto dt = NsToSeconds(time_ns - sample.time_ns);
-
-  // Temporary forward prediction code.
-  auto angle = angular_speed_ * dt;
-  if (__builtin_expect(forward_predict_angular_speed_, 0)) {
-    angle += 0.5 * angular_accel_ * dt * dt;
-  }
-
-  return {time_ns, sample.position + velocity_ * dt,
-          sample.orientation * quat(AngleAxis(angle, rotational_axis_))};
-}
-
-Velocity LinearPosePredictor::PredictVelocity(int64_t /* time_ns */) const {
-  return {velocity_, rotational_velocity_};
-}
-
-}  // namespace posepredictor
diff --git a/libs/vr/libposepredictor/linear_predictor_tests.cpp b/libs/vr/libposepredictor/linear_predictor_tests.cpp
deleted file mode 100644
index d94aa2d..0000000
--- a/libs/vr/libposepredictor/linear_predictor_tests.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-#include <gtest/gtest.h>
-
-#include <linear_predictor.h>
-
-namespace posepredictor {
-
-namespace {
-
-// For comparing expected and actual.
-constexpr real kAbsErrorTolerance = 1e-5;
-
-// The default rotation axis we will be using.
-const vec3 kRotationAxis = vec3(1, 4, 3).normalized();
-
-// Linearly interpolate between a and b.
-vec3 lerp(const vec3& a, const vec3& b, real t) { return (b - a) * t + a; }
-
-// Linearly interpolate between two angles and return the resulting rotation as
-// a quaternion (around the kRotationAxis).
-quat qlerp(real angle1, real angle2, real t) {
-  return quat(
-      Eigen::AngleAxis<real>((angle2 - angle1) * t + angle1, kRotationAxis));
-}
-
-// Compare two positions.
-void TestPosition(const vec3& expected, const vec3& actual) {
-  for (int i = 0; i < 3; ++i) {
-    EXPECT_NEAR(expected[i], actual[i], kAbsErrorTolerance);
-  }
-}
-
-// Compare two orientations.
-void TestOrientation(const quat& expected, const quat& actual) {
-  // abs(expected.dot(actual)) > 1-eps
-  EXPECT_GE(std::abs(actual.coeffs().dot(expected.coeffs())), 0.99);
-}
-}
-
-// Test the extrapolation from two samples.
-TEST(LinearPosePredictorTest, Extrapolation) {
-  LinearPosePredictor predictor;
-
-  // We wil extrapolate linearly from [position|orientation] 1 -> 2.
-  const vec3 position1(0, 0, 0);
-  const vec3 position2(1, 2, 3);
-  const real angle1 = M_PI * 0.3;
-  const real angle2 = M_PI * 0.5;
-  const quat orientation1(Eigen::AngleAxis<real>(angle1, kRotationAxis));
-  const quat orientation2(Eigen::AngleAxis<real>(angle2, kRotationAxis));
-  const int64_t t1_ns = 0;           //< First sample time stamp
-  const int64_t t2_ns = 10;          //< The second sample time stamp
-  const int64_t eval_left_ns = 23;   //< The eval time for left
-  const int64_t eval_right_ns = 31;  //< The eval time for right
-  Pose start_pose, end_pose, extrapolated_pose;
-
-  predictor.Add(Pose{
-      .position = position1, .orientation = orientation1, .time_ns = t1_ns});
-
-  predictor.Add(Pose{
-      .position = position2, .orientation = orientation2, .time_ns = t2_ns});
-
-  // Extrapolate from t1 - t2 to eval_[left/right].
-  extrapolated_pose = predictor.Predict(eval_left_ns);
-
-  // The interpolation factors for left and right.
-  const auto left_t = (eval_left_ns - t1_ns) / static_cast<real>(t2_ns - t1_ns);
-  EXPECT_EQ(2.3, left_t);
-
-  TestPosition(lerp(position1, position2, left_t), extrapolated_pose.position);
-
-  TestOrientation(qlerp(angle1, angle2, left_t), extrapolated_pose.orientation);
-
-  extrapolated_pose = predictor.Predict(eval_right_ns);
-
-  const auto right_t =
-      (eval_right_ns - t1_ns) / static_cast<real>(t2_ns - t1_ns);
-  EXPECT_EQ(3.1, right_t);
-
-  TestPosition(lerp(position1, position2, right_t), extrapolated_pose.position);
-
-  TestOrientation(qlerp(angle1, angle2, right_t),
-                  extrapolated_pose.orientation);
-}
-
-// Test three samples, where the last two samples have the same timestamp.
-TEST(LinearPosePredictorTest, DuplicateSamples) {
-  LinearPosePredictor predictor;
-
-  const vec3 position1(0, 0, 0);
-  const vec3 position2(1, 2, 3);
-  const vec3 position3(2, 2, 3);
-  const real angle1 = M_PI * 0.3;
-  const real angle2 = M_PI * 0.5;
-  const real angle3 = M_PI * 0.65;
-  const quat orientation1(Eigen::AngleAxis<real>(angle1, kRotationAxis));
-  const quat orientation2(Eigen::AngleAxis<real>(angle2, kRotationAxis));
-  const quat orientation3(Eigen::AngleAxis<real>(angle3, kRotationAxis));
-  const int64_t t1_ns = 0;
-  const int64_t t2_ns = 10;
-  const int64_t eval_left_ns = 27;
-  const int64_t eval_right_ns = 31;
-  Pose extrapolated_pose;
-
-  predictor.Add(Pose{
-      .position = position1, .orientation = orientation1, .time_ns = t1_ns});
-
-  predictor.Add(Pose{
-      .position = position2, .orientation = orientation2, .time_ns = t2_ns});
-
-  {
-    // Extrapolate from t1 - t2 to eval_[left/right].
-    extrapolated_pose = predictor.Predict(eval_left_ns);
-
-    // The interpolation factors for left and right.
-    const auto left_t =
-        (eval_left_ns - t1_ns) / static_cast<real>(t2_ns - t1_ns);
-
-    // Test the result.
-    TestPosition(lerp(position1, position2, left_t),
-                 extrapolated_pose.position);
-
-    TestOrientation(qlerp(angle1, angle2, left_t),
-                    extrapolated_pose.orientation);
-
-    extrapolated_pose = predictor.Predict(eval_right_ns);
-
-    const auto right_t =
-        (eval_right_ns - t1_ns) / static_cast<real>(t2_ns - t1_ns);
-
-    TestPosition(lerp(position1, position2, right_t),
-                 extrapolated_pose.position);
-
-    TestOrientation(qlerp(angle1, angle2, right_t),
-                    extrapolated_pose.orientation);
-  }
-
-  // Sending a duplicate sample here.
-  predictor.Add(Pose{
-      .position = position3, .orientation = orientation3, .time_ns = t2_ns});
-
-  {
-    // Extrapolate from t1 - t2 to eval_[left/right].
-    extrapolated_pose = predictor.Predict(eval_left_ns);
-
-    // The interpolation factors for left and right.
-    const auto left_t =
-        (eval_left_ns - t1_ns) / static_cast<real>(t2_ns - t1_ns);
-
-    TestPosition(lerp(position1, position3, left_t),
-                 extrapolated_pose.position);
-
-    TestOrientation(qlerp(angle1, angle3, left_t),
-                    extrapolated_pose.orientation);
-
-    extrapolated_pose = predictor.Predict(eval_right_ns);
-
-    const auto right_t =
-        (eval_right_ns - t1_ns) / static_cast<real>(t2_ns - t1_ns);
-
-    // Test the result.
-
-    TestPosition(lerp(position1, position3, right_t),
-                 extrapolated_pose.position);
-
-    TestOrientation(qlerp(angle1, angle3, right_t),
-                    extrapolated_pose.orientation);
-  }
-}
-
-}  // namespace posepredictor
diff --git a/libs/vr/libposepredictor/polynomial_predictor.cpp b/libs/vr/libposepredictor/polynomial_predictor.cpp
deleted file mode 100644
index 98fd28a..0000000
--- a/libs/vr/libposepredictor/polynomial_predictor.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <polynomial_predictor.h>
-
-namespace posepredictor {
-
-// Instantiate the common polynomial types.
-template class PolynomialPosePredictor<1, 2>;
-template class PolynomialPosePredictor<2, 3>;
-template class PolynomialPosePredictor<3, 4>;
-template class PolynomialPosePredictor<4, 5>;
-
-}  // namespace posepredictor
diff --git a/libs/vr/libposepredictor/polynomial_predictor_tests.cpp b/libs/vr/libposepredictor/polynomial_predictor_tests.cpp
deleted file mode 100644
index 88cb2b9..0000000
--- a/libs/vr/libposepredictor/polynomial_predictor_tests.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-#include <gtest/gtest.h>
-
-#include <polynomial_predictor.h>
-
-namespace posepredictor {
-
-namespace {
-
-// For comparing expected and actual.
-constexpr real kAbsErrorTolerance = 1e-5;
-
-// Test the linear extrapolation from two samples.
-TEST(PolynomialPosePredictor, Linear) {
-  // Degree = 1, simple line, passing through two points.
-  // Note the regularization is 0 so we expect the exact fit.
-  PolynomialPosePredictor<1, 2> predictor(0);
-
-  // Add two samples.
-  predictor.Add(
-      Pose{.position = {0, 0, 0}, .orientation = {0, 0, 0, 1}, .time_ns = 0});
-
-  predictor.Add(
-      Pose{.position = {1, 2, 3}, .orientation = {0, 0, 0, 1}, .time_ns = 10});
-
-  Pose predicted_pose;
-
-  predicted_pose = predictor.Predict(20);
-
-  // Check the x,y,z components for the expected translation.
-  EXPECT_NEAR(predicted_pose.position[0], 2, kAbsErrorTolerance);
-  EXPECT_NEAR(predicted_pose.position[1], 4, kAbsErrorTolerance);
-  EXPECT_NEAR(predicted_pose.position[2], 6, kAbsErrorTolerance);
-
-  predicted_pose = predictor.Predict(30);
-  EXPECT_NEAR(predicted_pose.position[0], 3, kAbsErrorTolerance);
-  EXPECT_NEAR(predicted_pose.position[1], 6, kAbsErrorTolerance);
-  EXPECT_NEAR(predicted_pose.position[2], 9, kAbsErrorTolerance);
-}
-
-// Test the degree two polynomial fit.
-TEST(PolynomialPosePredictor, Quadric) {
-  // Degree = 2, need three samples to fit a polynomial.
-  // Note the regularization is 0 so we expect the exact fit.
-  PolynomialPosePredictor<2, 3> predictor(0);
-
-  // Add three samples.
-  predictor.Add(
-      Pose{.position = {1, 2, 3}, .orientation = {0, 0, 0, 1}, .time_ns = 0});
-
-  predictor.Add(
-      Pose{.position = {0, 0, 0}, .orientation = {0, 0, 0, 1}, .time_ns = 10});
-
-  predictor.Add(
-      Pose{.position = {1, 2, 3}, .orientation = {0, 0, 0, 1}, .time_ns = 20});
-
-  // The expected polynomials for x/y/z.
-
-  // x:  0.01 * t^2 - 0.2 * t + 1
-  const auto x = [](auto t) { return 0.01 * t * t - 0.2 * t + 1; };
-
-  // y:  0.02 * t^2 - 0.4 * t + 2
-  const auto y = [](auto t) { return 0.02 * t * t - 0.4 * t + 2; };
-
-  // z:  0.03 * t^2 - 0.6 * t + 3
-  const auto z = [](auto t) { return 0.03 * t * t - 0.6 * t + 3; };
-
-  Pose predicted_pose;
-  predicted_pose = predictor.Predict(40);
-
-  // Check the x,y,z components for the expected translation.
-  EXPECT_NEAR(predicted_pose.position[0], x(40), kAbsErrorTolerance);
-  EXPECT_NEAR(predicted_pose.position[1], y(40), kAbsErrorTolerance);
-  EXPECT_NEAR(predicted_pose.position[2], z(40), kAbsErrorTolerance);
-
-  predicted_pose = predictor.Predict(50);
-  EXPECT_NEAR(predicted_pose.position[0], x(50), kAbsErrorTolerance);
-  EXPECT_NEAR(predicted_pose.position[1], y(50), kAbsErrorTolerance);
-  EXPECT_NEAR(predicted_pose.position[2], z(50), kAbsErrorTolerance);
-}
-
-// Test the degree two polynomial fit with degenerate input.
-//
-// The input samples all lie in a line which would normally make our system
-// degenerate. We will rely on the regularization term to recover the linear
-// solution in a quadric predictor.
-TEST(PolynomialPosePredictor, QuadricDegenate) {
-  // Degree = 2, need three samples to fit a polynomial.
-  // Note that we are using the default regularization term here.
-  // We cannot use 0 regularizer since the input is degenerate.
-  PolynomialPosePredictor<2, 3> predictor(1e-20);
-
-  // Add three samples.
-  predictor.Add(
-      Pose{.position = {0, 0, 0}, .orientation = {0, 0, 0, 1}, .time_ns = 0});
-
-  predictor.Add(
-      Pose{.position = {1, 2, 3}, .orientation = {0, 0, 0, 1}, .time_ns = 10});
-
-  predictor.Add(
-      Pose{.position = {2, 4, 6}, .orientation = {0, 0, 0, 1}, .time_ns = 20});
-
-  Pose predicted_pose;
-
-  predicted_pose = predictor.Predict(30);
-
-  // Check the x,y,z components for the expected translation.
-  // We are using a higher error threshold since this is now approximate.
-  EXPECT_NEAR(predicted_pose.position[0], 3, 0.001);
-  EXPECT_NEAR(predicted_pose.position[1], 6, 0.001);
-  EXPECT_NEAR(predicted_pose.position[2], 9, 0.001);
-
-  predicted_pose = predictor.Predict(40);
-  EXPECT_NEAR(predicted_pose.position[0], 4, 0.001);
-  EXPECT_NEAR(predicted_pose.position[1], 8, 0.001);
-  EXPECT_NEAR(predicted_pose.position[2], 12, 0.001);
-}
-
-}  // namespace
-
-}  // namespace posepredictor
diff --git a/libs/vr/libposepredictor/predictor.cpp b/libs/vr/libposepredictor/predictor.cpp
deleted file mode 100644
index beba156..0000000
--- a/libs/vr/libposepredictor/predictor.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <linear_predictor.h>
-#include <polynomial_predictor.h>
-#include <predictor.h>
-
-namespace posepredictor {
-
-vec3 Predictor::AngularVelocity(const quat& a, const quat& b, real delta_time) {
-  const auto delta_q = a.inverse() * b;
-  // Check that delta_q.w() == 1, Eigen doesn't respect this convention. If
-  // delta_q.w() == -1, we'll get the opposite velocity.
-  return 2.0 * (delta_q.w() < 0 ? static_cast<vec3>(-delta_q.vec()) : delta_q.vec()) / delta_time;
-}
-
-Velocity Predictor::PredictVelocity(int64_t time_ns) const {
-  const auto a = Predict(time_ns - kFiniteDifferenceNs);
-  const auto b = Predict(time_ns + kFiniteDifferenceNs);
-  const auto delta_time = NsToSeconds(2 * kFiniteDifferenceNs);
-
-  return {(b.position - a.position) / delta_time,
-          AngularVelocity(a.orientation, b.orientation, delta_time)};
-}
-
-// The factory method.
-std::unique_ptr<Predictor> Predictor::Create(PredictorType type) {
-  switch (type) {
-    case PredictorType::Linear:
-      return std::make_unique<LinearPosePredictor>();
-    case PredictorType::Quadric:
-      return std::make_unique<QuadricPosePredictor>();
-    case PredictorType::Cubic:
-      return std::make_unique<CubicPosePredictor>();
-  }
-}
-}  // namespace posepredictor
diff --git a/libs/vr/libposepredictor/predictor_tests.cpp b/libs/vr/libposepredictor/predictor_tests.cpp
deleted file mode 100644
index e84a93a..0000000
--- a/libs/vr/libposepredictor/predictor_tests.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <gtest/gtest.h>
-
-#include <predictor.h>
-
-namespace posepredictor {
-
-namespace {
-
-// For comparing expected and actual.
-constexpr real kAbsErrorTolerance = 1e-4;
-
-// Test the angular velocity computation from two orientations.
-TEST(PosePredictor, AngularVelocity) {
-  // Some random rotation axis we will rotate around.
-  const vec3 kRotationAxis = vec3(1, 2, 3).normalized();
-
-  // Some random angle we will be rotating by.
-  const real kRotationAngle = M_PI / 30;
-
-  // Random start orientation we are currently at.
-  const quat kStartOrientation = quat(5, 3, 4, 1).normalized();
-
-  // The orientation we will end up at.
-  const quat kEndOrientation =
-      kStartOrientation *
-      quat(Eigen::AngleAxis<real>(kRotationAngle, kRotationAxis));
-
-  // The delta time for going from start orientation to end.
-  const real kDeltaTime = 1.0;
-
-  // Compute the angular velocity from start orientation to end.
-  const auto angularVelocity = Predictor::AngularVelocity(
-      kStartOrientation, kEndOrientation, kDeltaTime);
-
-  // Extract the axis and the angular speed.
-  const auto angularSpeed = angularVelocity.norm();
-  const auto rotationAxis = angularVelocity.normalized();
-
-  // The speed must match.
-  EXPECT_NEAR(angularSpeed, kRotationAngle / kDeltaTime, kAbsErrorTolerance);
-
-  // The rotation axis must match.
-  EXPECT_NEAR(rotationAxis[0], kRotationAxis[0], kAbsErrorTolerance);
-  EXPECT_NEAR(rotationAxis[1], kRotationAxis[1], kAbsErrorTolerance);
-  EXPECT_NEAR(rotationAxis[2], kRotationAxis[2], kAbsErrorTolerance);
-}
-
-}  // namespace
-
-}  // namespace posepredictor
