Skip to content

Alignment

function estimate_alignment

estimate_alignment(
    traj_from: trajectopy.core.trajectory.Trajectory,
    traj_to: trajectopy.core.trajectory.Trajectory,
    alignment_settings: trajectopy.core.settings.alignment.AlignmentSettings = AlignmentSettings(preprocessing=AlignmentPreprocessing(min_speed=0.0, time_start=0.0, time_end=0.0), estimation_settings=AlignmentEstimationSettings(trans_x=True, trans_y=True, trans_z=True, rot_x=True, rot_y=True, rot_z=True, scale=False, time_shift=False, use_x_speed=True, use_y_speed=True, use_z_speed=True, lever_x=False, lever_y=False, lever_z=False, sensor_rotation=False, auto_update=False), stochastics=AlignmentStochastics(std_xy_from=1.0, std_z_from=1.0, std_xy_to=1.0, std_z_to=1.0, std_roll_pitch=0.017453292519943295, std_yaw=0.017453292519943295, std_speed=1.0, error_probability=0.05, variance_estimation=False), metric_threshold=0.0001, time_threshold=0.0001),
    matching_settings: trajectopy.core.settings.matching.MatchingSettings = MatchingSettings(method=<MatchingMethod.INTERPOLATION: 'interpolation'>, max_time_diff=0.01, max_distance=0.0, k_nearest=10)
)  AlignmentResult

Aligns two trajectories

Performs a - Helmert - Leverarm - Time shift

estimation depending on the configuration. After this, the estimated parameters are applied to the 'traj_from' trajectory.

Args:

  • traj_from (Trajectory)
  • traj_to (Trajectory)
  • alignment_settings (AlignmentSettings, optional): Settings for the alignment process. Defaults to AlignmentSettings().
  • matching_settings (MatchingSettings, optional): Settings for the matching process. Defaults to MatchingSettings().

Returns:

  • AlignmentResult: Result of the alignment process

class AlignmentResult

Class to store the result of an alignment.

Attributes:

  • name (str): Name of the result.
  • position_parameters (AlignmentParameters): Estimated position alignment parameters.
  • rotation_parameters (SensorRotationParameters): Estimated rotation alignment parameters.
  • estimation_of (AlignmentEstimationSettings): Settings defining which parameters were estimated.
  • converged (bool): Whether the estimation converged.

method AlignmentResult.__init__

__init__(
    name: str = 'Alignment Result',
    position_parameters: trajectopy.core.alignment.parameters.AlignmentParameters = <factory>,
    rotation_parameters: trajectopy.core.alignment.parameters.SensorRotationParameters = <factory>,
    estimation_of: trajectopy.core.settings.alignment.AlignmentEstimationSettings = <factory>,
    converged: bool = True
)  None

classmethod AlignmentResult.from_file

from_file(filename: str)  AlignmentResult

Load the result from a file.

Args:

  • filename (str): Path to the file.

Returns:

  • AlignmentResult: The loaded result.

method AlignmentResult.to_file

to_file(filename: str)  None

Save the result to a file.

Args:

  • filename (str): Path to the file.

class AlignmentData

Class holding the observation data required for Alignment

Attributes:

  • traj_from (Trajectory): Source trajectory
  • traj_to (Trajectory): Target trajectory
  • alignment_settings (AlignmentSettings): Settings for the alignment
  • matching_settings (MatchingSettings): Settings for the matching

method AlignmentData.__init__

__init__(
    traj_from: trajectopy.core.trajectory.Trajectory,
    traj_to: trajectopy.core.trajectory.Trajectory,
    alignment_settings: trajectopy.core.settings.alignment.AlignmentSettings,
    matching_settings: trajectopy.core.settings.matching.MatchingSettings
)  None

property AlignmentData.est_euler_x


property AlignmentData.est_euler_y


property AlignmentData.est_euler_z


property AlignmentData.est_obs_vector


property AlignmentData.est_rpy_from


property AlignmentData.est_speed


property AlignmentData.est_speed_x


property AlignmentData.est_speed_y


property AlignmentData.est_speed_z


property AlignmentData.est_x_from


property AlignmentData.est_x_to


property AlignmentData.est_xyz_from


property AlignmentData.est_xyz_to


property AlignmentData.est_y_from


property AlignmentData.est_y_to


property AlignmentData.est_z_from


property AlignmentData.est_z_to


property AlignmentData.euler_x


property AlignmentData.euler_y


property AlignmentData.euler_z


property AlignmentData.group_stds

Returns the mean standard deviation for each group


property AlignmentData.num_obs_per_epoch

Returns the number of observations per epoch depending on the enabled estimation modes.


property AlignmentData.number_of_epochs


property AlignmentData.obs_vector


property AlignmentData.res_vector


property AlignmentData.rpy_from


property AlignmentData.sigma_ll


property AlignmentData.speed


property AlignmentData.speed_x


property AlignmentData.speed_y


property AlignmentData.speed_z


property AlignmentData.tstamps


property AlignmentData.var_vector


property AlignmentData.x_from


property AlignmentData.x_to


property AlignmentData.xyz_from


property AlignmentData.xyz_to


property AlignmentData.y_from


property AlignmentData.y_to


property AlignmentData.z_from


property AlignmentData.z_to


handler AlignmentData.observation_groups


handler AlignmentData.rpy_to


handler AlignmentData.thresholds


handler AlignmentData.variance_groups


method AlignmentData.build_obs_vector

build_obs_vector(
    xyz_from: numpy.ndarray,
    xyz_to: numpy.ndarray,
    rot_from: Optional[trajectopy.core.rotationset.RotationSet],
    speed: Optional[numpy.ndarray]
)  ndarray

Creates the observation vector required for the alignment adjustment.

Args:

  • xyz_from (np.ndarray): Positions to be aligned.
  • xyz_to (np.ndarray): Target Positions.
  • rpy_from (np.ndarray): The roll, pitch, and yaw angles of the platform. Those angles should describe the rotation of the body-fixed coordinate system with respect to the inertial coordinate system.

Returns:

  • np.ndarray: The observation vector required for the alignment adjustment.

method AlignmentData.build_res_vector

build_res_vector()  ndarray

method AlignmentData.build_var_vector

build_var_vector()  ndarray

Sets up the variance vector

Its size depends on whether the leverarm should be estimated or not. In this case, not only the source and the target positions are relevant but also the platform orientations. Also, when estimating the time shift, the platform speed is also considered.

Returns:

  • np.ndarray: variance vector

method AlignmentData.get_est_obs_group

get_est_obs_group(key: str)  Tuple[numpy.ndarray, ...]

method AlignmentData.get_obs_group

get_obs_group(key: str)  Tuple[numpy.ndarray, ...]

method AlignmentData.get_res_group

get_res_group(key: str)  Tuple[numpy.ndarray, ...]

method AlignmentData.get_var_group

get_var_group(key: str)  Tuple[numpy.ndarray, ...]

method AlignmentData.get_variance_estimation_subset

get_variance_estimation_subset(num_obs: int = 200)  AlignmentData

Returns a subset of the alignment data for variance estimation

This method will return a subset of the alignment data that contains 'num_obs' observations. The subset is selected by finding the epoch with the highest standard deviation of the observations. The idea is that a higher variance in the observations will lead to a better estimation of the variances.

The motivation behind this is that the variance estimation is memory and time consuming. Therefore, a subset of the observations is used for the estimation.

Args:

  • num_obs (int, optional): Subet size. Defaults to 200.

Returns:

  • AlignmentData: Cropped alignment data

method AlignmentData.set_obs_group

set_obs_group(key: str, values: numpy.ndarray)  None

method AlignmentData.set_res_group

set_res_group(key: str, values: numpy.ndarray)  None

method AlignmentData.set_var_group

set_var_group(key: str, values: numpy.ndarray)  None

method AlignmentData.setup

setup()  None

Prepare two trajectories for alignment.

This method will filter the trajectories by speed and resample both trajectories to the same sampling.