|
| 1 | +# pose_instability_detector |
| 2 | + |
| 3 | +The `pose_instability_detector` is a node designed to monitor the stability of `/localization/kinematic_state`, which is an output topic of the Extended Kalman Filter (EKF). |
| 4 | + |
| 5 | +This node triggers periodic timer callbacks to compare two poses: |
| 6 | + |
| 7 | +- The pose calculated by dead reckoning starting from the pose of `/localization/kinematic_state` obtained `timer_period` seconds ago. |
| 8 | +- The latest pose from `/localization/kinematic_state`. |
| 9 | + |
| 10 | +The results of this comparison are then output to the `/diagnostics` topic. |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +If this node outputs WARN messages to `/diagnostics`, it means that the EKF output is significantly different from the integrated twist values. |
| 17 | +In other words, WARN outputs indicate that the vehicle has moved to a place outside the expected range based on the twist values. |
| 18 | +This discrepancy suggests that there may be an issue with either the estimated pose or the input twist. |
| 19 | + |
| 20 | +The following diagram provides an overview of how the procedure looks like: |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +## Dead reckoning algorithm |
| 25 | + |
| 26 | +Dead reckoning is a method of estimating the position of a vehicle based on its previous position and velocity. |
| 27 | +The procedure for dead reckoning is as follows: |
| 28 | + |
| 29 | +1. Capture the necessary twist values from the `/input/twist` topic. |
| 30 | +2. Integrate the twist values to calculate the pose transition. |
| 31 | +3. Apply the pose transition to the previous pose to obtain the current pose. |
| 32 | + |
| 33 | +### Collecting twist values |
| 34 | + |
| 35 | +The `pose_instability_detector` node collects the twist values from the `~/input/twist` topic to perform dead reckoning. |
| 36 | +Ideally, `pose_instability_detector` needs the twist values between the previous pose and the current pose. |
| 37 | +Therefore, `pose_instability_detector` snips the twist buffer and apply interpolations and extrapolations to obtain the twist values at the desired time. |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +### Linear transition and angular transition |
| 42 | + |
| 43 | +After the twist values are collected, the node calculates the linear transition and angular transition based on the twist values and add them to the previous pose. |
| 44 | + |
| 45 | +## Threshold definition |
| 46 | + |
| 47 | +The `pose_instability_detector` node compares the pose calculated by dead reckoning with the latest pose from the EKF output. |
| 48 | +These two pose are ideally the same, but in reality, they are not due to the error in the twist values the pose observation. |
| 49 | +If these two poses are significantly different so that the absolute value exceeds the threshold, the node outputs a WARN message to the `/diagnostics` topic. |
| 50 | +There are six thresholds (x, y, z, roll, pitch, and yaw) to determine whether the poses are significantly different, and these thresholds are determined by the following subsections. |
| 51 | + |
| 52 | +### `diff_position_x` |
| 53 | + |
| 54 | +This threshold examines the difference in the longitudinal axis between the two poses, and check whether the vehicle goes beyond the expected error. |
| 55 | +This threshold is a sum of "maximum longitudinal error due to velocity scale factor error" and "pose estimation error tolerance". |
| 56 | + |
| 57 | +$$ |
| 58 | +\tau_x = v_{\rm max}\frac{\beta_v}{100} \Delta t + \epsilon_x\\ |
| 59 | +$$ |
| 60 | + |
| 61 | +| Symbol | Description | Unit | |
| 62 | +| ------------- | -------------------------------------------------------------------------------- | ----- | |
| 63 | +| $\tau_x$ | Threshold for the difference in the longitudinal axis | $m$ | |
| 64 | +| $v_{\rm max}$ | Maximum velocity | $m/s$ | |
| 65 | +| $\beta_v$ | Scale factor tolerance for the maximum velocity | $\%$ | |
| 66 | +| $\Delta t$ | Time interval | $s$ | |
| 67 | +| $\epsilon_x$ | Pose estimator (e. g. ndt_scan_matcher) error tolerance in the longitudinal axis | $m$ | |
| 68 | + |
| 69 | +### `diff_position_y` and `diff_position_z` |
| 70 | + |
| 71 | +These thresholds examine the difference in the lateral and vertical axes between the two poses, and check whether the vehicle goes beyond the expected error. |
| 72 | +The `pose_instability_detector` calculates the possible range where the vehicle goes, and get the maximum difference between the nominal dead reckoning pose and the maximum limit pose. |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +Addition to this, the `pose_instability_detector` node considers the pose estimation error tolerance to determine the threshold. |
| 77 | + |
| 78 | +$$ |
| 79 | +\tau_y = l + \epsilon_y |
| 80 | +$$ |
| 81 | + |
| 82 | +| Symbol | Description | Unit | |
| 83 | +| ------------ | ----------------------------------------------------------------------------------------------- | ---- | |
| 84 | +| $\tau_y$ | Threshold for the difference in the lateral axis | $m$ | |
| 85 | +| $l$ | Maximum lateral distance described in the image above (See the appendix how this is calculated) | $m$ | |
| 86 | +| $\epsilon_y$ | Pose estimator (e. g. ndt_scan_matcher) error tolerance in the lateral axis | $m$ | |
| 87 | + |
| 88 | +Note that `pose_instability_detector` sets the threshold for the vertical axis as the same as the lateral axis. Only the pose estimator error tolerance is different. |
| 89 | + |
| 90 | +### `diff_angle_x`, `diff_angle_y`, and `diff_angle_z` |
| 91 | + |
| 92 | +These thresholds examine the difference in the roll, pitch, and yaw angles between the two poses. |
| 93 | +This threshold is a sum of "maximum angular error due to velocity scale factor error and bias error" and "pose estimation error tolerance". |
| 94 | + |
| 95 | +$$ |
| 96 | +\tau_\phi = \tau_\theta = \tau_\psi = \left(\omega_{\rm max}\frac{\beta_\omega}{100} + b \right) \Delta t + \epsilon_\psi |
| 97 | +$$ |
| 98 | + |
| 99 | +| Symbol | Description | Unit | |
| 100 | +| ------------------ | ------------------------------------------------------------------------ | ------------- | |
| 101 | +| $\tau_\phi$ | Threshold for the difference in the roll angle | ${\rm rad}$ | |
| 102 | +| $\tau_\theta$ | Threshold for the difference in the pitch angle | ${\rm rad}$ | |
| 103 | +| $\tau_\psi$ | Threshold for the difference in the yaw angle | ${\rm rad}$ | |
| 104 | +| $\omega_{\rm max}$ | Maximum angular velocity | ${\rm rad}/s$ | |
| 105 | +| $\beta_\omega$ | Scale factor tolerance for the maximum angular velocity | $\%$ | |
| 106 | +| $b$ | Bias tolerance of the angular velocity | ${\rm rad}/s$ | |
| 107 | +| $\Delta t$ | Time interval | $s$ | |
| 108 | +| $\epsilon_\psi$ | Pose estimator (e. g. ndt_scan_matcher) error tolerance in the yaw angle | ${\rm rad}$ | |
| 109 | + |
| 110 | +## Parameters |
| 111 | + |
| 112 | +{{ json_to_markdown("localization/pose_instability_detector/schema/pose_instability_detector.schema.json") }} |
| 113 | + |
| 114 | +## Input |
| 115 | + |
| 116 | +| Name | Type | Description | |
| 117 | +| ------------------ | ---------------------------------------------- | --------------------- | |
| 118 | +| `~/input/odometry` | nav_msgs::msg::Odometry | Pose estimated by EKF | |
| 119 | +| `~/input/twist` | geometry_msgs::msg::TwistWithCovarianceStamped | Twist | |
| 120 | + |
| 121 | +## Output |
| 122 | + |
| 123 | +| Name | Type | Description | |
| 124 | +| ------------------- | ------------------------------------- | ----------- | |
| 125 | +| `~/debug/diff_pose` | geometry_msgs::msg::PoseStamped | diff_pose | |
| 126 | +| `/diagnostics` | diagnostic_msgs::msg::DiagnosticArray | Diagnostics | |
| 127 | + |
| 128 | +## Appendix |
| 129 | + |
| 130 | +On calculating the maximum lateral distance $l$, the `pose_instability_detector` node will estimate the following poses. |
| 131 | + |
| 132 | +| Pose | heading velocity $v$ | angular velocity $\omega$ | |
| 133 | +| ------------------------------- | ------------------------------------------------ | -------------------------------------------------------------- | |
| 134 | +| Nominal dead reckoning pose | $v_{\rm max}$ | $\omega_{\rm max}$ | |
| 135 | +| Dead reckoning pose of corner A | $\left(1+\frac{\beta_v}{100}\right) v_{\rm max}$ | $\left(1+\frac{\beta_\omega}{100}\right) \omega_{\rm max} + b$ | |
| 136 | +| Dead reckoning pose of corner B | $\left(1-\frac{\beta_v}{100}\right) v_{\rm max}$ | $\left(1+\frac{\beta_\omega}{100}\right) \omega_{\rm max} + b$ | |
| 137 | +| Dead reckoning pose of corner C | $\left(1-\frac{\beta_v}{100}\right) v_{\rm max}$ | $\left(1-\frac{\beta_\omega}{100}\right) \omega_{\rm max} - b$ | |
| 138 | +| Dead reckoning pose of corner D | $\left(1+\frac{\beta_v}{100}\right) v_{\rm max}$ | $\left(1-\frac{\beta_\omega}{100}\right) \omega_{\rm max} - b$ | |
| 139 | + |
| 140 | +Given a heading velocity $v$ and $\omega$, the 2D theoretical variation seen from the previous pose is calculated as follows: |
| 141 | + |
| 142 | +$$ |
| 143 | +\begin{align*} |
| 144 | +\left[ |
| 145 | + \begin{matrix} |
| 146 | + \Delta x\\ |
| 147 | + \Delta y |
| 148 | + \end{matrix} |
| 149 | +\right] |
| 150 | +&= |
| 151 | +\left[ |
| 152 | + \begin{matrix} |
| 153 | + \int_{0}^{\Delta t} v \cos(\omega t) dt\\ |
| 154 | + \int_{0}^{\Delta t} v \sin(\omega t) dt |
| 155 | + \end{matrix} |
| 156 | +\right] |
| 157 | +\\ |
| 158 | +&= |
| 159 | +\left[ |
| 160 | + \begin{matrix} |
| 161 | + \frac{v}{\omega} \sin(\omega \Delta t)\\ |
| 162 | + \frac{v}{\omega} \left(1 - \cos(\omega \Delta t)\right) |
| 163 | + \end{matrix} |
| 164 | +\right] |
| 165 | +\end{align*} |
| 166 | +$$ |
| 167 | + |
| 168 | +We calculate this variation for each corner and get the maximum value of the lateral distance $l$ by comparing the distance between the nominal dead reckoning pose and the corner poses. |
0 commit comments