Skip to content

Evaluation

evaluation

ate

ate(
    trajectory: Trajectory,
    other: Trajectory,
    processing_settings: ProcessingSettings = ProcessingSettings(),
    return_alignment: bool = False,
    align: bool = True,
) -> Union[ATEResult, Tuple[ATEResult, AlignmentResult]]

Computes the absolute trajectory error (ATE) between two trajectories.

The ATE is computed by first matching the estimated trajectory to the ground truth trajectory. Then, the alignment between the two trajectories is estimated. The estimated trajectory is aligned to the ground truth trajectory using the estimated alignment. Finally, the ATE is computed by comparing the aligned estimated trajectory to the ground truth trajectory.

Parameters:

  • trajectory (Trajectory) –

    Trajectory to be evaluated.

  • other (Trajectory) –

    Ground truth trajectory.

  • processing_settings (ProcessingSettings, default: ProcessingSettings() ) –

    Processing settings.

  • return_alignment (bool, default: False ) –

    Whether to return the alignment result. Defaults to False.

  • align (bool, default: True ) –

    Whether to perform alignment. Defaults to True.

Returns:

  • ATEResult ( Union[ATEResult, Tuple[ATEResult, AlignmentResult]] ) –

    Result of the ATE computation. If return_alignment is True, returns a tuple containing (ATEResult, AlignmentResult).

Source code in trajectopy\processing\evaluation.py
def ate(
    trajectory: Trajectory,
    other: Trajectory,
    processing_settings: settings.ProcessingSettings = settings.ProcessingSettings(),
    return_alignment: bool = False,
    align: bool = True,
) -> Union[ATEResult, Tuple[ATEResult, AlignmentResult]]:
    """Computes the absolute trajectory error (ATE) between two trajectories.

    The ATE is computed by first matching the estimated trajectory to the ground truth trajectory.
    Then, the alignment between the two trajectories is estimated. The estimated trajectory is
    aligned to the ground truth trajectory using the estimated alignment. Finally, the ATE is
    computed by comparing the aligned estimated trajectory to the ground truth trajectory.

    Args:
        trajectory (Trajectory): Trajectory to be evaluated.
        other (Trajectory): Ground truth trajectory.
        processing_settings (ProcessingSettings, optional): Processing settings.
        return_alignment (bool, optional): Whether to return the alignment result.
            Defaults to False.
        align (bool, optional): Whether to perform alignment. Defaults to True.

    Returns:
        ATEResult: Result of the ATE computation. If return_alignment is True, returns a tuple
            containing (ATEResult, AlignmentResult).
    """
    trajectory, other = match_trajectories(
        trajectory=trajectory, other=other, matching_settings=processing_settings.matching, inplace=False
    )

    if align:
        alignment = estimate_alignment(
            trajectory=trajectory,
            other=other,
            alignment_settings=processing_settings.alignment,
            matching_settings=processing_settings.matching,
        )
        trajectory_est_aligned = apply_alignment(trajectory, alignment_result=alignment, inplace=False)
    else:
        alignment = AlignmentResult()
        trajectory_est_aligned = trajectory

    return (
        (
            _compare_trajectories_absolute(other=other, trajectory=trajectory_est_aligned),
            alignment,
        )
        if return_alignment
        else _compare_trajectories_absolute(other=other, trajectory=trajectory_est_aligned)
    )

rpe

rpe(
    trajectory: Trajectory,
    other: Trajectory,
    processing_settings: ProcessingSettings = ProcessingSettings(),
) -> RPEResult

Computes the relative pose error (RPE) between two trajectories.

The RPE is computed by comparing the relative poses between the estimated and ground truth trajectories. The pose distances are either defined in meters or in seconds depending on the settings.

Parameters:

Returns:

  • RPEResult ( RPEResult ) –

    Result of the RPE computation.

Source code in trajectopy\processing\evaluation.py
def rpe(
    trajectory: Trajectory,
    other: Trajectory,
    processing_settings: settings.ProcessingSettings = settings.ProcessingSettings(),
) -> RPEResult:
    """Computes the relative pose error (RPE) between two trajectories.

    The RPE is computed by comparing the relative poses between the estimated and ground truth
    trajectories. The pose distances are either defined in meters or in seconds depending on
    the settings.

    Args:
        trajectory (Trajectory): Trajectory to be evaluated.
        other (Trajectory): Ground truth trajectory.
        processing_settings (ProcessingSettings, optional): Processing settings.

    Returns:
        RPEResult: Result of the RPE computation.
    """
    trajectory, other = match_trajectories(
        trajectory=trajectory, other=other, matching_settings=processing_settings.matching, inplace=False
    )
    return _compare_trajectories_relative(
        trajectory=trajectory,
        other=other,
        relative_comparison_settings=processing_settings.relative_comparison,
    )