template<typename PoseType>
class gtsam::Interpolator< PoseType >
Interpolator for poses and velocities under a motion prior.
The Interpolator class provides routines to interpolate pose and velocity at arbitrary times between (or outside) estimated states. It encapsulates the motion model (WNOA by default) via function objects for transition, covariance and Jacobian computations. The class also computes conditional covariances for interpolated states when requested.
- Template Parameters
-
| PoseType | Pose group/type (e.g., Pose2, Pose3, or a vector-space pose) |
|
| | Interpolator (const VectorN &q_psd_diag, std::function< Matrix(double dt)> transitionFunction, std::function< Matrix(double dt, const VectorN &q_psd_diag)> covarianceFunction, std::function< Matrix(double dt, const VectorN &q_psd_diag)> inverseCovarianceFunction, std::function< Matrix(const std::pair< PoseType, VelocityType > &, const std::pair< PoseType, VelocityType > &, double)> computeJacobianPrev, std::function< Matrix(const std::pair< PoseType, VelocityType > &, const std::pair< PoseType, VelocityType > &, double)> computeJacobianNext) |
| | Construct an Interpolator with custom motion-model functions.
|
| | Interpolator (const VectorN &q_psd_diag) |
| | Default constructor using the WNOA motion model.
|
| PoseVel | interpolatePoseAndVelocity (const std::optional< TimestampedPoseVel > &Tvarpi_k, const std::optional< TimestampedPoseVel > &Tvarpi_kp1, double t_tau, OptionalMatrixVecType H=nullptr, const std::shared_ptr< Matrix > &mainSolveMarginalMatrix=nullptr, Matrix *covarianceOut=nullptr, const std::shared_ptr< const LambdaPsiMats > &LambdaPsiPreComp=nullptr, const std::shared_ptr< const LocalStateVecs > &localStateVecsPreComp=nullptr, const std::shared_ptr< const StateJacobians > &stateJacobiansPreComp=nullptr) const |
| | Interpolate the pose and velocity at time t_tau.
|
| Values | interpolatePosesAndVelocities (const NonlinearFactorGraph &mainSolveGraph, const Values &mainSolveSolution, const StateDataSet &mainSolveStates, const StateDataSet &interpolatedStates, std::shared_ptr< InterpCovarianceMap > covarianceMapOut=nullptr) const |
| | Interpolate multiple poses and velocities given a solved factor graph.
|
| Matrix2N | computeConditionalCov (const TimestampedPoseVel &pvk, const TimestampedPoseVel &pvkp1, const TimestampedPoseVel &pvtau, OptionalMatrixType Lambda=nullptr, OptionalMatrixType Psi=nullptr) const |
| | Compute the conditional covariance of the interpolated state.
|
| std::pair< Matrix, Matrix > | getLambdaPsi (double t_k, double t_kp1, double t_tau) const |
| | Compute interpolation matrices Lambda and Psi (WNOA-optimized).
|
| std::pair< Matrix, Matrix > | getLambdaPsiGeneral (double t_k, double t_kp1, double t_tau) const |
| | Compute interpolation matrices Lambda and Psi for a general motion model.
|
| LocalStateVecs | computeLocalStateVecs (const TimestampedPoseVel &pvk, const TimestampedPoseVel &pvkp1, StateJacobians *jacs=nullptr) const |
| | Compute the local state vectors (xi, xi_dot) for a pair of bordering states.
|
|
|
using | VelocityType = typename traits<PoseType>::TangentVector |
|
using | MatrixN = Eigen::Matrix<double, dim, dim> |
|
using | VectorN = Eigen::Matrix<double, dim, 1> |
|
using | Matrix2N = Eigen::Matrix<double, 2 * dim, 2 * dim> |
|
using | Vector2N = Eigen::Matrix<double, 2 * dim, 1> |
|
using | MatrixNx2N = Eigen::Matrix<double, dim, 2 * dim> |
|
| PoseVel | interpolateBoundaryLeft (const PoseVelocity< PoseType > &poseVel_k, OptionalMatrixVecType H=nullptr, const std::shared_ptr< Matrix > &mainSolveMarginalMatrix=nullptr, Matrix *covarianceOut=nullptr) const |
| | Interpolate pose and velocity at the left boundary.
|
| PoseVel | interpolateBoundaryRight (const PoseVelocity< PoseType > &poseVel_kp1, OptionalMatrixVecType H=nullptr, const std::shared_ptr< Matrix > &mainSolveMarginalMatrix=nullptr, Matrix *covarianceOut=nullptr) const |
| | Interpolate pose and velocity at the right boundary.
|
| PoseVel | extrapolatePoseAndVelocity (const PoseVelocity< PoseType > &poseVel, double t_diff, OptionalMatrixVecType H=nullptr, const std::shared_ptr< Matrix > &mainSolveMarginalMatrix=nullptr, Matrix *covarianceOut=nullptr) const |
| | Extrapolate pose and velocity from a border state.
|
| PoseVel | interpolatePoseAndVelocity_ (const TimestampedPoseVel &tPoseVel_k, const TimestampedPoseVel &tPoseVel_kp1, double t_tau, OptionalMatrixVecType H=nullptr, const std::shared_ptr< Matrix > &mainSolveMarginalMatrix=nullptr, Matrix *covarianceOut=nullptr, const std::shared_ptr< const LambdaPsiMats > &LambdaPsiPreComp=nullptr, const std::shared_ptr< const LocalStateVecs > &localStateVecsPreComp=nullptr, const std::shared_ptr< const StateJacobians > &stateJacobiansPreComp=nullptr) const |
| | Internal implementation that performs interpolation between two bordering states.
|
| void | formLocalStateAndJacobians_ (const TimestampedPoseVel &tPoseVel_k, const TimestampedPoseVel &tPoseVel_kp1, const std::shared_ptr< const LocalStateVecs > &localStateVecsPreComp, const std::shared_ptr< const StateJacobians > &stateJacobiansPreComp, VectorN *xi_dot_k, VectorN *xi_kp1, VectorN *xi_dot_kp1, StateJacobians *jacs=nullptr) const |
| | Step 1 of interpolatePoseAndVelocity: form local state vectors and optional local Jacobians.
|
| void | interpolateLocalState_ (double t_k, double t_kp1, double t_tau, const VectorN &xi_dot_k, const VectorN &xi_kp1, const VectorN &xi_dot_kp1, const std::shared_ptr< const LambdaPsiMats > &LambdaPsiPreComp, Matrix2N *Lambda, Matrix2N *Psi, VectorN *xi_tau, VectorN *xidot_tau) const |
| | Step 2 of interpolatePoseAndVelocity: interpolate local state using Lambda/Psi matrices.
|
| PoseVel | mapLocalStateToManifold_ (const PoseType &T_k, const VectorN &xi_tau, const VectorN &xidot_tau, MatrixN *right_jac_tau, MatrixN *dTtau_dTk=nullptr, MatrixN *dTtau_dxitau=nullptr) const |
| | Step 3 of interpolatePoseAndVelocity: map interpolated local state back to manifold.
|
| void | computeCompleteJacobians_ (const Matrix2N &Lambda, const Matrix2N &Psi, const VectorN &xidot_tau, const MatrixN &right_jac_tau, const MatrixN &dTtau_dTk, const MatrixN &dTtau_dxitau, const StateJacobians &jacs, OptionalMatrixVecType H) const |
| | Step 4 of interpolatePoseAndVelocity: compose full Jacobians with chain rule.
|
| void | computeInterpolationCovariance_ (const TimestampedPoseVel &tPoseVel_k, const TimestampedPoseVel &tPoseVel_kp1, const PoseVel &poseVel_tau, double t_tau, const Matrix2N &Lambda, const Matrix2N &Psi, const std::shared_ptr< Matrix > &mainSolveMarginalMatrix, Matrix *covarianceOut) const |
| | Step 5 of interpolatePoseAndVelocity: compute interpolated covariance when requested.
|
|
|
VectorN | q_psd_diag_ |
|
std::function< Matrix(double dt)> | transitionFunction_ |
|
std::function< Matrix(double dt, const VectorN &q_psd_diag)> | covarianceFunction_ |
|
std::function< Matrix(double dt, const VectorN &q_psd_diag)> | inverseCovarianceFunction_ |
|
std::function< Matrix(const std::pair< PoseType, VelocityType > &, const std::pair< PoseType, VelocityType > &, double)> | computeJacobianPrev_ |
|
std::function< Matrix(const std::pair< PoseType, VelocityType > &, const std::pair< PoseType, VelocityType > &, double)> | computeJacobianNext_ |
template<typename PoseType>
| void gtsam::Interpolator< PoseType >::formLocalStateAndJacobians_ |
( |
const TimestampedPoseVel & | tPoseVel_k, |
|
|
const TimestampedPoseVel & | tPoseVel_kp1, |
|
|
const std::shared_ptr< const LocalStateVecs > & | localStateVecsPreComp, |
|
|
const std::shared_ptr< const StateJacobians > & | stateJacobiansPreComp, |
|
|
VectorN * | xi_dot_k, |
|
|
VectorN * | xi_kp1, |
|
|
VectorN * | xi_dot_kp1, |
|
|
StateJacobians * | jacs = nullptr ) const |
|
protected |
Step 1 of interpolatePoseAndVelocity: form local state vectors and optional local Jacobians.
Computes \((\xi_k, \dot\xi_k, \xi_{k+1}, \dot\xi_{k+1})\) used by interpolation. Jacobian outputs are populated only when all Jacobian pointers are non-null.
- Parameters
-
| tPoseVel_k | Timestamped left border state. |
| tPoseVel_kp1 | Timestamped right border state. |
| localStateVecsPreComp | Optional precomputed local state vectors at the right border. |
| stateJacobiansPreComp | Optional precomputed local-to-global Jacobians. |
| xi_dot_k | Output local velocity vector at the left border. |
| xi_kp1 | Output local position vector at the right border. |
| xi_dot_kp1 | Output local velocity vector at the right border. |
| jacs | Optional output Jacobians for local state wrt bordering states. |
- Returns
- void
template<typename PoseType>
| Interpolator< PoseType >::PoseVel gtsam::Interpolator< PoseType >::interpolatePoseAndVelocity |
( |
const std::optional< TimestampedPoseVel > & | Tvarpi_k, |
|
|
const std::optional< TimestampedPoseVel > & | Tvarpi_kp1, |
|
|
double | t_tau, |
|
|
OptionalMatrixVecType | H = nullptr, |
|
|
const std::shared_ptr< Matrix > & | mainSolveMarginalMatrix = nullptr, |
|
|
Matrix * | covarianceOut = nullptr, |
|
|
const std::shared_ptr< const LambdaPsiMats > & | LambdaPsiPreComp = nullptr, |
|
|
const std::shared_ptr< const LocalStateVecs > & | localStateVecsPreComp = nullptr, |
|
|
const std::shared_ptr< const StateJacobians > & | stateJacobiansPreComp = nullptr ) const |
Interpolate the pose and velocity at time t_tau.
The function computes the interpolated pose and velocity at the requested time using the provided bordering (optional) timestamped states. When a border is missing, boundary or extrapolation logic is used.
This is the main workhorse function for interpolated factors, but is also used after the fact to compute interpolated values and covariances given a solved factor graph.
Optionally returns Jacobians (8 matrices) and the interpolated covariance when the main-solve marginals are provided.
- Parameters
-
| Tvarpi_k | Optional timestamped pose/velocity at left border t_k. |
| Tvarpi_kp1 | Optional timestamped pose/velocity at right border t_kp1. |
| t_tau | Interpolation time. |
| H | Optional output vector of Jacobian blocks (8 matrices). |
| mainSolveMarginalMatrix | Optional marginal covariance of bordering states from the main solve. |
| covarianceOut | Optional output pointer for the interpolated state's covariance (requires mainSolveMarginalMatrix). |
| LambdaPsiPreComp | Optional precomputed Lambda/Psi matrices to reuse work. |
| localStateVecsPreComp | Optional precomputed local state vectors (xi, xi_dot). |
| stateJacobiansPreComp | Optional precomputed local state->global state Jacobians. |
- Returns
- PoseVel Interpolated pose and velocity pair at t_tau.
template<typename PoseType>
| Interpolator< PoseType >::PoseVel gtsam::Interpolator< PoseType >::interpolatePoseAndVelocity_ |
( |
const TimestampedPoseVel & | tPoseVel_k, |
|
|
const TimestampedPoseVel & | tPoseVel_kp1, |
|
|
double | t_tau, |
|
|
OptionalMatrixVecType | H = nullptr, |
|
|
const std::shared_ptr< Matrix > & | mainSolveMarginalMatrix = nullptr, |
|
|
Matrix * | covarianceOut = nullptr, |
|
|
const std::shared_ptr< const LambdaPsiMats > & | LambdaPsiPreComp = nullptr, |
|
|
const std::shared_ptr< const LocalStateVecs > & | localStateVecsPreComp = nullptr, |
|
|
const std::shared_ptr< const StateJacobians > & | stateJacobiansPreComp = nullptr ) const |
|
protected |
Internal implementation that performs interpolation between two bordering states.
This function follows the interpolation logic outlined in Section 11.3.1 of (Barfoot 2024) and is used by the public interpolatePoseAndVelocity method after handling boundary/extrapolation cases.
This internal overload implements the core interpolation algorithm for a pair of timestamped bordering states and a target interpolation time. It supports optional precomputed helpers (Lambda/Psi matrices and local state vectors/Jacobians) to avoid redundant work when called in tight loops.
- Parameters
-
| tPoseVel_k | Timestamped pose/velocity at the left border. |
| tPoseVel_kp1 | Timestamped pose/velocity at the right border. |
| t_tau | Interpolation time. |
| H | Optional output pointer to a vector of Jacobian blocks. |
| mainSolveMarginalMatrix | Optional shared pointer to the main-solve marginal covariance. |
| covarianceOut | Optional output pointer for the resulting covariance matrix. |
| LambdaPsiPreComp | Optional precomputed Lambda/Psi matrices to reuse work. |
| localStateVecsPreComp | Optional precomputed local state vectors (xi, xi_dot). |
| stateJacobiansPreComp | Optional precomputed local->global Jacobians. |
- Returns
- PoseVel Interpolated pose and velocity at t_tau.