# Circle Misalignment

## Overview

Circle misalignment is a metric unique to MetriCal. It's an artifact of the way MetriCal bridges the two distinct modalities of camera (primarily 2D features and projection) and LiDAR (3D point clouds in Euclidean space).

The design of the circular target is the key. The target starts as a regular camera fiducial like a ChArUco board. That board is then sized into a circle of a known diameter and outlined with retroreflective material, like tape. This design allows both cameras and LiDAR to pick up the fiducial via its sensing modality.

There is one circle misalignment metric group for every circular target in use.

## Definition

Circle misalignment metrics contain the following fields:

Field | Type | Description |
---|---|---|

`metadata` | A common metadata object | The metadata associated with the point cloud this circle target was measured in. |

`object_space_id` | UUID | The UUID of the object space that was being observed. |

`measured_circle_center` | An array of 3 float values | The X/Y/Z coordinate of the center of the circle target, in the LiDAR coordinate frame |

`plane_inliers_x` | An array of floats | All X-coordinates of points contained within the circle target. |

`plane_inliers_y` | An array of floats | All Y-coordinates of points contained within the circle target. |

`plane_inliers_z` | An array of floats | All Z-coordinates of points contained within the circle target. |

`world_extrinsics_component_ids` | An array of UUIDs | The camera UUIDs for each world extrinsic in `world_extrinsics` |

`world_extrinsics` | An array of world extrinsics objects | The world pose (camera from object space) that correspond to each `circle_center_misalignment` |

`circle_center_misalignment` | An array of circle center coordinates | The errors between the circle center location estimated between each camera and the observed LiDAR |

`plane_inliers_distances` | An array of arrays of floats | The point-to-plane distances between the plane inlier points and the plane observed at a given world extrinsic. |

`plane_distance_rmse_per_we` | An array of floats | Similar to `plane_inliers_distances` but represents the RMSE of all plane inlier distances. |

`circle_center_rmse` | Float | The circle center misalignment RMSE over all world extrinsics. |

`plane_distance_rmse` | Float | The plane inlier distance RMSE over all world extrinsics. |

## Analysis

### The "Center"

Much of the circle misalignment metrics are about bridging the gap between the two modalities.

- The center of the circle in
*camera space*is the center of the ChArUco board, given its metric dimensions - The center of the circle in
*LiDAR space*is the centroid of the planar 2D circle fit from the points detected on the ring of retro-reflective tape.

The `measured_circle_center`

above is this LiDAR center; the `circle_center_misalignment`

is the
error between that LiDAR circle center and the circle center estimated from each camera. This might
seem straightforward, but there's a bit more to it than that.

Since there are no commonly observable features between cameras and LiDAR, MetriCal has to use a bit of math to make calibration work. Think of the object circle center as our origin; we'll call this $C^O$. The LiDAR circle center is that same point, but in the LiDAR coordinate frame:

$C^L = T^{L}_{O} \cdot C^O$...and every camera has its own estimate of the circle center w.r.t the camera board, $C^C$:

$C^C = T^{C}_{O} \cdot C^O$We can relate these centers to one another by using the extrinsics between LiDAR and Camera, $T^{L}_{C}$:

$\hat C^L = T^{L}_{C} \cdot C^C = T^{L}_{C} \cdot T^{C}_{O} \cdot C^O$With both $C^L$ and $\hat C^L$ in the LiDAR coordinate frame, we can calculate the error between the
two and get our `circle_center_misalignment`

:

$T^{C}_{O}$ is what is referred to when we say `world_extrinsics`

, and the
`world_extrinsics_component_ids`

designate what camera that extrinsic relates to. MetriCal
calculates these for every pair of synced camera-LiDAR observations.