> For the complete documentation index, see [llms.txt](https://docs.andymark.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.andymark.com/frc-electronics/can-sensors/can-lidar-am-5684/validation.md).

# Validation

How to decide whether a CAN Lidar reading is suitable for robot logic

The CAN Lidar reports more than distance. Check status, signal strength, ambient light, timestamps, and application history before using a measurement for autonomous or closed-loop decisions.

{% hint style="warning" %}
The numerical thresholds below are starting points for characterization, not guaranteed acceptance limits. Establish final thresholds with the real target, distance, angle, lighting, timing budget, and mounting.
{% endhint %}

## Data available

Each measurement includes:

* Distance in millimeters
* Status code
* Flags
* Measurement timestamp
* Peak signal in centi-MCPS
* Ambient light in centi-MCPS
* Debug-data timestamp

## 1. Check communication and freshness

Before evaluating distance:

* Confirm the expected device is present at the configured CAN ID.
* Confirm timestamps continue to advance.
* Treat repeated, stale, or timed-out data as invalid.
* Verify that the main and debug data correspond closely enough in time for the application.

## 2. Check the status code

| Status | Meaning         | Recommended treatment                         |
| ------ | --------------- | --------------------------------------------- |
| 0      | Range valid     | Continue validation                           |
| 1      | Sigma fail      | Reject                                        |
| 2      | Signal fail     | Reject                                        |
| 4      | Phase fail      | Reject                                        |
| 5      | Hardware fail   | Reject and investigate                        |
| 7      | Wrap target     | Use only with application-specific validation |
| 8      | Processing fail | Reject                                        |

Status 0 is preferred. Status 7 indicates a weak or near-limit condition and should not be treated as equally trustworthy without testing.

## 3. Evaluate peak signal

Peak signal describes the returned optical signal. Higher values generally indicate a stronger return.

A useful initial characterization band is:

| Peak signal                 | Starting interpretation |
| --------------------------- | ----------------------- |
| Greater than 300 centi-MCPS | Strong                  |
| 150–300 centi-MCPS          | Moderate                |
| Less than 150 centi-MCPS    | Weak                    |

Do not use these bands as universal limits. Record how the value changes with the actual target and range.

## 4. Evaluate ambient light

Higher ambient values indicate more background optical energy and can reduce margin, especially at longer distances. A value below 100 centi-MCPS can be used as an initial low-ambient reference, but acceptable values depend on the target and configuration.

## 5. Compare signal with ambient

When the ambient value is greater than zero, calculate:

```
signal-to-ambient ratio = peak signal / ambient
```

Values above 1.5 can be used as an initial characterization target, while values above 2.0 provide more margin. If ambient is zero, do not divide; evaluate status and peak signal directly.

## 6. Apply application checks

A robot should also confirm that:

* Distance is inside the mechanism’s physically possible range.
* The change from the previous accepted sample is plausible.
* Enough consecutive samples agree for the risk of the action.
* A rejected or missing reading produces a safe fallback behavior.

## Example acceptance policy

A conservative starting policy might require:

* Fresh data
* Status 0
* Peak signal greater than an experimentally selected threshold
* Adequate signal-to-ambient ratio
* Two or more consecutive plausible samples

Status 7 may be handled separately when the application can tolerate reduced confidence.

## Validation procedure

1. Collect data across the full operating distance.
2. Repeat for each target material, angle, and lighting condition.
3. Record both successful readings and failure modes.
4. Select thresholds with margin between valid and invalid cases.
5. Recheck after changing the sensor mode, timing budget, ROI, mounting, or robot lighting.
