pub struct Variable<M: LieGroup> {
pub value: M,
pub fixed_indices: HashSet<usize>,
pub bounds: HashMap<usize, (f64, f64)>,
pub covariance: Option<Mat<f64>>,
}Expand description
Generic Variable struct that uses static dispatch with any manifold type.
This struct represents optimization variables that live on manifolds and provides type-safe operations for updating variables with tangent space perturbations.
§Type Parameters
M- The manifold type that implements the LieGroup trait
§Examples
use apex_solver::core::variable::Variable;
use apex_solver::manifold::se2::SE2;
use apex_solver::manifold::rn::Rn;
// Create a Variable for SE2 manifold
let se2_value = SE2::from_xy_angle(1.0, 2.0, 0.5);
let se2_var = Variable::new(se2_value);
// Create a Variable for Euclidean space
let rn_value = Rn::from_vec(vec![1.0, 2.0, 3.0]);
let rn_var = Variable::new(rn_value);Fields§
§value: MThe manifold value
fixed_indices: HashSet<usize>Indices that should remain fixed during optimization
bounds: HashMap<usize, (f64, f64)>Bounds constraints on the tangent space representation
covariance: Option<Mat<f64>>Covariance matrix in the tangent space (uncertainty estimation)
This is None if covariance has not been computed.
When present, it’s a square matrix of size tangent_dim x tangent_dim
representing the uncertainty in the optimized variable’s tangent space.
For example, for SE3 this would be a 6×6 matrix representing uncertainty in [translation_x, translation_y, translation_z, rotation_x, rotation_y, rotation_z].
Implementations§
Source§impl<M> Variable<M>
impl<M> Variable<M>
Sourcepub fn get_size(&self) -> usize
pub fn get_size(&self) -> usize
Get the degrees of freedom (tangent space dimension) of the variable.
This returns the dimension of the tangent space, which is the number of parameters that can be optimized for this manifold type.
§Returns
The tangent space dimension (degrees of freedom)
Sourcepub fn plus(&self, tangent: &M::TangentVector) -> M
pub fn plus(&self, tangent: &M::TangentVector) -> M
Plus operation: apply tangent space perturbation to the manifold value.
This method takes a tangent vector and returns a new manifold value by applying the manifold’s plus operation (typically the exponential map).
§Arguments
tangent- The tangent vector to apply as a perturbation
§Returns
A new manifold value after applying the tangent perturbation
§Examples
use apex_solver::core::variable::Variable;
use apex_solver::manifold::se2::{SE2, SE2Tangent};
use nalgebra as na;
let se2_value = SE2::from_xy_angle(1.0, 2.0, 0.0);
let variable = Variable::new(se2_value);
// Create a tangent vector: [dx, dy, dtheta]
let tangent = SE2Tangent::from(na::DVector::from(vec![0.1, 0.1, 0.1]));
let new_value = variable.plus(&tangent);Sourcepub fn minus(&self, other: &Self) -> M::TangentVector
pub fn minus(&self, other: &Self) -> M::TangentVector
Minus operation: compute tangent space difference between two manifold values.
This method computes the tangent vector that would transform this variable’s value to the other variable’s value using the manifold’s minus operation (typically the logarithmic map).
§Arguments
other- The other variable to compute the difference to
§Returns
A tangent vector representing the difference in tangent space
§Examples
use apex_solver::core::variable::Variable;
use apex_solver::manifold::se2::SE2;
let se2_1 = SE2::from_xy_angle(2.0, 3.0, 0.5);
let se2_2 = SE2::from_xy_angle(1.0, 2.0, 0.0);
let var1 = Variable::new(se2_1);
let var2 = Variable::new(se2_2);
let difference = var1.minus(&var2);Sourcepub fn get_covariance(&self) -> Option<&Mat<f64>>
pub fn get_covariance(&self) -> Option<&Mat<f64>>
Get the covariance matrix for this variable (if computed).
Returns None if covariance has not been computed.
§Returns
Reference to the covariance matrix in tangent space
Sourcepub fn set_covariance(&mut self, cov: Mat<f64>)
pub fn set_covariance(&mut self, cov: Mat<f64>)
Set the covariance matrix for this variable.
The covariance matrix should be square with dimension equal to the tangent space dimension of this variable.
§Arguments
cov- Covariance matrix in tangent space
Sourcepub fn clear_covariance(&mut self)
pub fn clear_covariance(&mut self)
Clear the covariance matrix.
Trait Implementations§
Auto Trait Implementations§
impl<M> Freeze for Variable<M>where
M: Freeze,
impl<M> RefUnwindSafe for Variable<M>where
M: RefUnwindSafe,
impl<M> Send for Variable<M>where
M: Send,
impl<M> Sync for Variable<M>where
M: Sync,
impl<M> Unpin for Variable<M>where
M: Unpin,
impl<M> UnwindSafe for Variable<M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.