DavenportQMethod

giant.stellar_opnav.estimators:

class giant.stellar_opnav.estimators.DavenportQMethod(target_frame_directions=None, base_frame_directions=None, weighted_estimation=False, weights=1)[source]

This class estimates the rotation quaternion that best aligns unit vectors from one frame with unit vectors in another frame using Davenport’s Q-Method solution to Wahba’s problem.

This class is relatively easy to use. When you initialize the class, simply specify the target_frame_directions unit vectors (\(\textbf{a}_i\) from the estimators documentation) as a 3xn array of vectors (each column is a vector) and the base_frame_directions unit vectors (\(\textbf{b}_i\) from the estimators documentation) as a 3xn array of vectors (each column is a vector). Here the target_frame_directions unit vectors are expressed in the end frame (the frame you want to rotate to) and the base_frame_directions unit vectors are expressed in the starting frame (the frame you want to rotate from). You can also leave these inputs to be None and then set the attributes directly. Each column of target_frame_directions and base_frame_directions should correspond to each other as a pair (i.e. column 1 in target_frame_directions is paired with column ` in base_frame_directions.

Optionally, either at initialization or by setting the attributes, you can set the weighted_estimation and weights values to specify whether to use weighted estimation or not, and what weights to use if you are using weighted estimation. When performing weighted estimation you should set weighted_estimation to True and specify weights to be a length n array of the weights to apply to each unit vector pair.

Once the appropriate values are set, the estimate() method can be called to compute the attitude quaternion that best aligns the two frames. When the estimate() method completes, the solved for rotation can be found as an Rotation object in the rotation attribute of the class. In addition, the formal post fit covariance matrix of the estimate can be found in the post_fit_covariance attribute. Note that as will all attitude quaternions, the post fit covariance matrix will be rank deficient since there are only 3 true degrees of freedom.

A description of the math behind the DavenportQMethod Solution can be found here.

Parameters:
  • target_frame_directions (ndarray) – A 3xn array of unit vectors expressed in the camera frame

  • base_frame_directions (ndarray) – A 3xn array of unit vectors expressed in the catalogue frame corresponding the the target_frame_directions unit vectors

  • weighted_estimation (bool) – A flag specifying whether to weight the estimation routine by unit vector pairs

  • weights (ndarray) – The weights to apply to the unit vectors if the weighted_estimation flag is set to True.

target_frame_directions: ndarray

The unit vectors in the target frame as a 3xn array (\(\mathbf{a}_i\)).

Each column should represent the pair of the corresponding column in base_frame_directions.

base_frame_directions: ndarray

The unit vectors in the base frame as a 3xn array (\(\mathbf{b}_i\)).

Each column should represent the pair of the corresponding column in target_frame_directions.

weights: ndarray

A length n array of the weights to apply if weighted_estimation is True. (\(w_i\))

Each element should represent the pair of the corresponding column in target_frame_directions and base_frame_directions.

weighted_estimation: bool

A flag specifying whether to use weights in the estimation of the rotation.

rotation: Rotation | None

The solved for rotation that best aligns the base_frame_directions and target_frame_directions after calling estimate().

This rotation goes go from the base frame to the target frame.

If estimate() has not been called yet then this will be set to None.

property post_fit_covariance: ndarray

This returns the post-fit covariance after calling the estimate method as a 4x4 numpy array.

This should be only be called after the estimate method has been called, otherwise it raises a ValueError

Summary of Methods

compute_residuals

This method computes the residuals between the aligned unit vectors according to Wahba's problem definitions.

estimate

This method solves for the rotation matrix that best aligns the unit vectors in base_frame_directions with the unit vectors in target_frame_directions using Davenport's Q-Method solution to Wahba's Problem.