Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
* -------------------------------------------------------------------------- */

/**
* @file EqVIOFilterExample.cpp
* @brief Run the EqVIOFilter on 10 seconds of the EuRoC MAV Vicon Room 1
* @file VioEqFExample.cpp
* @brief Run the VioEqF on 10 seconds of the EuRoC MAV Vicon Room 1
* dataset.
* @author Rohan Bansal
*/

#include <gtsam/slam/dataset.h>
#include <gtsam_unstable/examples/EqVIOReplayHelper.h>
#include <gtsam_unstable/examples/VioEqFReplayHelper.h>

#include <iomanip>
#include <iostream>
Expand All @@ -42,8 +42,8 @@ struct HardcodedGroundTruth {
};

/// Build runtime filter params from replay metadata with fallback defaults.
EqVIOFilterParams paramsFromMetadata(const replay::MetadataMap& metadata) {
EqVIOFilterParams params;
VioEqFParams paramsFromMetadata(const replay::MetadataMap& metadata) {
VioEqFParams params;
const auto setParam = [&metadata](double& field,
std::initializer_list<const char*> keys) {
for (const char* key : keys) {
Expand Down Expand Up @@ -155,13 +155,13 @@ int main() {

try {
const replay::MetadataMap metadata = replay::readReplayMetadata(csvPath);
const EqVIOFilterParams params = paramsFromMetadata(metadata);
const VioEqFParams params = paramsFromMetadata(metadata);
const double measurementNoiseVariance =
measurementNoiseVarianceFromMetadata(metadata);
const State xi0 = initialReferenceState(metadata);
const Matrix Sigma0 = initialCovarianceFromMetadata(metadata, xi0);

std::optional<EqVIOFilter> filter;
std::optional<VioEqF> filter;
auto camera = std::make_shared<CameraModel>(
Pose3::Identity(), Cal3_S2(1.0, 1.0, 0.0, 0.0, 0.0));

Expand Down Expand Up @@ -223,7 +223,7 @@ int main() {
printSummary(measurementNoiseVariance, currentTime, imuCount,
visionFrameCount, visionFeatureCount, finalEstimate);
} catch (const std::exception& e) {
std::cerr << "EqVIOFilterExample failed: " << e.what() << "\n";
std::cerr << "VioEqFExample failed: " << e.what() << "\n";
return 2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
* -------------------------------------------------------------------------- */

/**
* @file EqVIOReplayHelper.h
* @file VioEqFReplayHelper.h
* @brief Streaming CSV replay helpers for EqVIO examples.
* @author OpenAI Codex
*/

#pragma once

#include <gtsam_unstable/navigation/EqVIOFilter.h>
#include <gtsam_unstable/navigation/VioEqF.h>

#include <algorithm>
#include <array>
Expand Down Expand Up @@ -65,7 +65,7 @@ struct BufferedImuPropagation {

/// Format a consistent exception prefix for EqVIO replay helpers.
inline std::string formatReplayError(const std::string& detail) {
return "EqVIOReplay: " + detail;
return "VioEqFReplay: " + detail;
}

/// Trim leading/trailing ASCII whitespace.
Expand Down
132 changes: 7 additions & 125 deletions gtsam_unstable/geometry/ABCEquivariantFilter.h
Original file line number Diff line number Diff line change
@@ -1,140 +1,22 @@
/**
* @file ABCEquivariantFilter.h
* @brief Attitude-Bias-Calibration Equivariant Filter for state estimation
* @author Jennifer Oum
* @author Darshan Rajasekaran
* @author Rohan Bansal
* @author Frank Dellaert
* @date 2026
* @brief Forwarding header for AbcEqF.h.
*
* This file extends the EquivariantFilter class to provide a more user-friendly
* interface for the ABC Equivariant Filter. This class templates on the number
* of calibrated sensors N, abstracting away the details of the ABC system.
* @deprecated Include <gtsam_unstable/geometry/AbcEqF.h> and use abc::AbcEqF.
* Kept because gtsam/navigation/navigation_geometric.i and
* examples/AbcEquivariantFilterExample.cpp still use the old names.
*/

#pragma once

#include <gtsam/base/Matrix.h>
#include <gtsam/base/Vector.h>
#include <gtsam/base/VectorConstants.h>
#include <gtsam/geometry/Rot3.h>
#include <gtsam/geometry/Unit3.h>
#include <gtsam/navigation/EquivariantFilter.h>
#include <gtsam_unstable/geometry/ABC.h>
#include <gtsam_unstable/geometry/AbcEqF.h>

namespace gtsam {
namespace abc {

/**
* @class AbcEquivariantFilter
* @brief Equivariant Filter for Attitude-Bias-Calibration (ABC) estimation
*
* This class implements an equivariant filter for estimating:
* - Attitude (rotation): The orientation of the body frame relative to a
* reference frame
* - Bias: Gyroscope bias correction vector (3D)
* - Calibration: N sensor calibration rotation matrices
*
* The filter uses the ABC Lie group structure and equivariant dynamics to
* provide consistent state estimation. It inherits from EquivariantFilter
* and provides a simplified interface for ABC-specific operations.
*
* @tparam N Number of calibrated sensors (typically 1 or more)
*/
/// @deprecated Use AbcEqF.
template <size_t N>
class AbcEquivariantFilter
: public gtsam::EquivariantFilter<State<N>, Symmetry<N>> {
public:
using gtsam::EquivariantFilter<State<N>, Symmetry<N>>::update;

/**
* @brief Default constructor with identity initial covariance
*
* Initializes the filter with an identity state and identity covariance
* matrix of dimension (6 + 3*N) x (6 + 3*N), where 6 accounts for the
* attitude and bias parameters, and 3*N for N calibration parameters.
*/
AbcEquivariantFilter()
: AbcEquivariantFilter(Matrix::Identity(6 + 3 * N, 6 + 3 * N)) {}

/**
* @brief Construct filter with custom initial covariance
*
* Initializes the filter at the identity state with a specified initial
* covariance matrix on the manifold tangent space.
*
* @param Sigma0 Initial covariance matrix (6+3*N) x (6+3*N)
*/
explicit AbcEquivariantFilter(const Matrix& Sigma0)
: gtsam::EquivariantFilter<State<N>, Symmetry<N>>(State<N>::identity(),
Sigma0) {}

/**
* @brief Prediction step using gyroscope measurements
*
* Propagates the filter state forward in time using angular velocity
* measurements and process noise. This method uses the explicit Jacobian
* matrices (A and B) computed from the ABC dynamics.
*
* @param omega Angular velocity measurement (body frame, rad/s)
* @param inputCovariance Process noise covariance (6x6) for the input
* @param dt Time step (seconds)
*/
void predict(const Vector3& omega, const Matrix6& inputCovariance,
double dt) {
const Matrix Q = inputProcessNoise<N>(inputCovariance);
const Vector6 u = toInputVector(omega);
const Lift<N> lift_u(u);
const typename InputAction<N>::Orbit psi_u(u);

const Group<N> X_hat = this->groupEstimate();
const Matrix A = stateMatrixA<N>(psi_u, X_hat);
const Matrix B = inputMatrixB<N>(X_hat);
const Matrix Qc = B * Q * B.transpose();

this->template predictWithJacobian<2>(lift_u, A, Qc, dt);
}

/**
* @brief Measurement update using a direction observation
*
* Corrects the filter estimate using a direction measurement from a
* calibrated sensor. The measurement model assumes the sensor observes
* a known reference direction in the body frame.
*
* @param y Measured direction (unit vector in body frame)
* @param d Reference direction (unit vector in reference frame)
* @param R Measurement noise covariance (3x3)
* @param cal_idx Index of the calibrated sensor (0 to N-1), or -1 for
* uncalibrated measurements
*/
void update(const Unit3& y, const Unit3& d, const Matrix3& R, int cal_idx) {
const Innovation<N> innovation(y, d, cal_idx);
const Group<N> X_hat = this->groupEstimate();
const Matrix3 D = outputMatrixD<N>(X_hat, cal_idx);
const Matrix3 R_adjusted = D * R * D.transpose();
this->template update<Vector3>(innovation, Z_3x1, R_adjusted);
}

/**
* @brief Get current attitude estimate
* @return Current rotation estimate (body frame to reference frame)
*/
Rot3 attitude() const { return this->state().R; }

/**
* @brief Get current gyroscope bias estimate
* @return Current bias vector (rad/s)
*/
Vector3 bias() const { return this->state().b; }

/**
* @brief Get calibration estimate for a specific sensor
* @param i Sensor index (0 to N-1)
* @return Calibration rotation for sensor i
*/
Rot3 calibration(size_t i) const { return this->state().S[i]; }
};
using AbcEquivariantFilter = AbcEqF<N>;

} // namespace abc
} // namespace gtsam
138 changes: 138 additions & 0 deletions gtsam_unstable/geometry/AbcEqF.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/**
* @file AbcEqF.h
* @brief Attitude-Bias-Calibration Equivariant Filter for state estimation
* @author Jennifer Oum
* @author Darshan Rajasekaran
* @author Rohan Bansal
* @author Frank Dellaert
* @date 2026
*
* This file extends the EquivariantFilter class to provide a more user-friendly
* interface for the ABC Equivariant Filter. This class templates on the number
* of calibrated sensors N, abstracting away the details of the ABC system.
*/

#pragma once

#include <gtsam/base/Matrix.h>
#include <gtsam/base/Vector.h>
#include <gtsam/base/VectorConstants.h>
#include <gtsam/geometry/Rot3.h>
#include <gtsam/geometry/Unit3.h>
#include <gtsam/navigation/EquivariantFilter.h>
#include <gtsam_unstable/geometry/ABC.h>

namespace gtsam {
namespace abc {

/**
* @class AbcEqF
* @brief Equivariant Filter for Attitude-Bias-Calibration (ABC) estimation
*
* This class implements an equivariant filter for estimating:
* - Attitude (rotation): The orientation of the body frame relative to a
* reference frame
* - Bias: Gyroscope bias correction vector (3D)
* - Calibration: N sensor calibration rotation matrices
*
* The filter uses the ABC Lie group structure and equivariant dynamics to
* provide consistent state estimation. It inherits from EquivariantFilter
* and provides a simplified interface for ABC-specific operations.
*
* @tparam N Number of calibrated sensors (typically 1 or more)
*/
template <size_t N>
class AbcEqF : public gtsam::EquivariantFilter<State<N>, Symmetry<N>> {
public:
using gtsam::EquivariantFilter<State<N>, Symmetry<N>>::update;

/**
* @brief Default constructor with identity initial covariance
*
* Initializes the filter with an identity state and identity covariance
* matrix of dimension (6 + 3*N) x (6 + 3*N), where 6 accounts for the
* attitude and bias parameters, and 3*N for N calibration parameters.
*/
AbcEqF() : AbcEqF(Matrix::Identity(6 + 3 * N, 6 + 3 * N)) {}

/**
* @brief Construct filter with custom initial covariance
*
* Initializes the filter at the identity state with a specified initial
* covariance matrix on the manifold tangent space.
*
* @param Sigma0 Initial covariance matrix (6+3*N) x (6+3*N)
*/
explicit AbcEqF(const Matrix& Sigma0)
: gtsam::EquivariantFilter<State<N>, Symmetry<N>>(State<N>::identity(),
Sigma0) {}

/**
* @brief Prediction step using gyroscope measurements
*
* Propagates the filter state forward in time using angular velocity
* measurements and process noise. This method uses the explicit Jacobian
* matrices (A and B) computed from the ABC dynamics.
*
* @param omega Angular velocity measurement (body frame, rad/s)
* @param inputCovariance Process noise covariance (6x6) for the input
* @param dt Time step (seconds)
*/
void predict(const Vector3& omega, const Matrix6& inputCovariance,
double dt) {
const Matrix Q = inputProcessNoise<N>(inputCovariance);
const Vector6 u = toInputVector(omega);
const Lift<N> lift_u(u);
const typename InputAction<N>::Orbit psi_u(u);

const Group<N> X_hat = this->groupEstimate();
const Matrix A = stateMatrixA<N>(psi_u, X_hat);
const Matrix B = inputMatrixB<N>(X_hat);
const Matrix Qc = B * Q * B.transpose();

this->template predictWithJacobian<2>(lift_u, A, Qc, dt);
}

/**
* @brief Measurement update using a direction observation
*
* Corrects the filter estimate using a direction measurement from a
* calibrated sensor. The measurement model assumes the sensor observes
* a known reference direction in the body frame.
*
* @param y Measured direction (unit vector in body frame)
* @param d Reference direction (unit vector in reference frame)
* @param R Measurement noise covariance (3x3)
* @param cal_idx Index of the calibrated sensor (0 to N-1), or -1 for
* uncalibrated measurements
*/
void update(const Unit3& y, const Unit3& d, const Matrix3& R, int cal_idx) {
const Innovation<N> innovation(y, d, cal_idx);
const Group<N> X_hat = this->groupEstimate();
const Matrix3 D = outputMatrixD<N>(X_hat, cal_idx);
const Matrix3 R_adjusted = D * R * D.transpose();
this->template update<Vector3>(innovation, Z_3x1, R_adjusted);
}

/**
* @brief Get current attitude estimate
* @return Current rotation estimate (body frame to reference frame)
*/
Rot3 attitude() const { return this->state().R; }

/**
* @brief Get current gyroscope bias estimate
* @return Current bias vector (rad/s)
*/
Vector3 bias() const { return this->state().b; }

/**
* @brief Get calibration estimate for a specific sensor
* @param i Sensor index (0 to N-1)
* @return Calibration rotation for sensor i
*/
Rot3 calibration(size_t i) const { return this->state().S[i]; }
};

} // namespace abc
} // namespace gtsam
Loading
Loading