component: CameraDiagnostic
proto_imports:
  - vehicle/sensors/cameras/diagnostics/diagnostic.proto
metric: CameraMetric
namespace: zoox::vehicle::cammux

# TODO(SWAT-2932): Address camera diagnostics that should be NoGo
faults:
# Connection (1-10)
  - id: 1
    name: not_detected
    severity: ERROR
    description: "Network connection to vision machine not detected."
    freeze_frame: CameraConnectionFreezeFrame
    triggers_nogo: true
    # Deprecated.
  - id: 2
    name: disconnected
    severity: ERROR
    description: "Vision machine not connected."
    freeze_frame: CameraConnectionFreezeFrame
    triggers_nogo: true
    deprecated: true
  - id: 3
    name: starting
    severity: ERROR
    description: "Camera is starting up; please wait."
    triggers_nogo: true
  - id: 4
    name: initialization_failed
    severity: ERROR
    description: "Failed to initialize."
    triggers_nogo: true
    # Deprecated.
  - id: 5
    name: isp_heartbeat_timeout
    severity: ERROR
    description: "Camera heartbeat not detected. Check camera connection."
    triggers_nogo: true
    deprecated: true
# Capture and Processing (11-20)
  - id: 11
    name: capture_time_mean_high
    severity: ERROR
    description: "Image capture took too long. Possible hardware or software issue."
    freeze_frame: CameraCaptureTimeFreezeFrame
    triggers_nogo: true
  - id: 12
    name: capture_frequency_mean_high
    severity: WARNING
    description: "Capturing more images than expected."
    freeze_frame: CameraCaptureFrequencyFreezeFrame
  - id: 13
    name: sync_timestamp_offset_high
    severity: WARNING
    description: "Framegrabber clock is out of sync with host. Camera timestamps may be incorrect."
    freeze_frame: CameraSyncTimestampOffsetFreezeFrame
  - id: 14
    name: capture_frequency_mean_low
    severity: WARNING
    description: "Capturing fewer images (likely dropping frames)."
    freeze_frame: CameraCaptureFrequencyFreezeFrame
  - id: 15
    name: invalid_camera_mode
    severity: ERROR
    description: "Invalid camera mode for driving. Cameras are not delivering valid frames."
    triggers_nogo: true
  - id: 16
    name: image_queue_overrun
    severity: WARNING
    description: "Unable to add image to the queue. The queue is already full. The images are not being consumed fast enough. Frames are likely to be old."
# Hardware (21-50)
    # Deprecated.
  - id: 21
    name: temperature_high
    severity: ERROR
    description: "Camera temperature is too high."
    freeze_frame: CameraHardwareFreezeFrame
    deprecated: true
    # Deprecated.
  - id: 22
    name: temperature_low
    severity: ERROR
    description: "Camera temperature is too low."
    freeze_frame: CameraHardwareFreezeFrame
    deprecated: true
  - id: 23
    name: camera_capture_error
    severity: ERROR
    description: "Failed to capture image from the cameras."
    triggers_nogo: true
  - id: 24
    name: serial_number_mismatch
    severity: ERROR
    description: "Configured serial number does not match camera."
    triggers_nogo: true
  - id: 25
    name: fpga_bitstream_mismatch
    severity: ERROR
    description: "FPGA bitstream does not match expected version. Upgrade FPGA bitstream."
    triggers_nogo: true
  - id: 26
    name: sync_malfunction
    severity: ERROR
    description: "Images captured out of sync."
    freeze_frame: CameraConfigurationFreezeFrame
    triggers_nogo: true
  - id: 27
    name: isp_firmware_mismatch
    severity: ERROR
    description: "ISP firmware does not match expected version. Upgrade ISP firmware in camera."
    triggers_nogo: true
  - id: 28
    name: camera_power_error
    severity: ERROR
    description: "Camera is drawing too much power. Inspection required."
    triggers_nogo: true
    deprecated: true
  - id: 29
    name: camera_packet_errors
    severity: ERROR
    description: "Too many packet errors from camera. Inspect cables and hardware."
    deprecated: true
  - id: 30
    name: fpga_temperature_high_error
    severity: ERROR
    description: "Camera capture card temperature too high. Inspect card and cooling system."
    triggers_nogo: true
  - id: 31
    name: diagnostic_retrieval_error
    severity: WARNING
    description: "Could not retrieve diagnostic information from camera. Check messages and inspect hardware."
  - id: 32
    name: clock_drift_high
    severity: WARNING
    description: "High clock drift between AI and Framegrabber. Inspect card."
    # Fault should be an ERROR.
  - id: 33
    name: metadata_error
    severity: WARNING
    description: "Unable to decode image metadata; image is likely corrupt. Possible hardware error or incorrect configuration. If this error persists, check cables and other diagnostics."
    # Deprecated.
  - id: 34
    name: dropped_frames
    severity: ERROR
    description: "Dropped camera frames. This indicates a hardware, triggering or software problem. If this persists, discontinue operation and contact support."
    deprecated: true
  - id: 35
    name: capture_late
    severity: WARNING
    description: "Capture started late."
  - id: 36
    name: camera_model_mismatch
    severity: ERROR
    description: "The camera model does not match the expected model. Check that the vehicle configuration is correct and that you are using the right type of camera."
    triggers_nogo: true
  - id: 37
    name: dropped_frames_warn
    severity: WARNING
    description: "Dropped camera frames. This indicates a hardware, triggering or software problem. If this persists, discontinue operation and contact support."
  - id: 38
    name: too_many_dropped_frames
    severity: ERROR
    description: "Too many dropped camera frames. This indicates a hardware, triggering or software problem."
    triggers_nogo: true
  - id: 39
    name: camera_temperature_high
    severity: ERROR
    description: "Camera temperature is too high."
    freeze_frame: CameraHardwareFreezeFrame
    triggers_nogo: true
    # Fault should be an ERROR.
  - id: 40
    name: camera_temperature_low
    severity: WARNING
    description: "Camera temperature is too low."
    freeze_frame: CameraHardwareFreezeFrame
  - id: 41
    name: trigger_offset_abs_diff_high
    severity: WARNING
    description: "The difference between the expected trigger offset and the actual trigger offset is too high."
  - id: 42
    name: camera_packet_errors_warn
    severity: WARNING
    description: "Camera is dropping packets, frame quality may be degraded."
  - id: 43
    name: too_many_packet_errors
    severity: ERROR
    description: "Too many packets are being dropped. Frames are likely to be corrupted. Inspect cables and hardware."
    triggers_nogo: true
    # Fault should be an ERROR.
  - id: 44
    name: mipi_crc_error
    severity: WARNING
    description: "Mipi interface from deserializer to FPGA reported a checksum error."
    # Deprecated.
  - id: 45
    name: discarded_frames
    severity: WARNING
    description: "Camera frames are old and are being discarded."
    deprecated: true
  - id: 46
    name: unknown_hardware_revision
    severity: ERROR
    description: "Error gathering hardware diagnostics."
    triggers_nogo: true
  - id: 47
    name: fpga_temperature_high_warn
    severity: WARNING
    description: "Camera capture card is near the maximum temperature."
  - id: 48
    name: camera_power_thermal_shutdown
    severity: ERROR
    description: "Load switch thermal shutdown, framegrabber is overheating."
    triggers_nogo: true
  - id: 49
    name: camera_power_overcurrent
    severity: ERROR
    description: "Load switch overcurrent. Camera is shorted."
    triggers_nogo: true
  - id: 50
    name: camera_power_overvoltage
    severity: ERROR
    description: "Load switch overvoltage. Power is being injected the the link or the signal line is shorted to a power supply."
    triggers_nogo: true
  - id: 51
    name: camera_power_undervoltage
    severity: ERROR
    description: "Load switch undervoltage. Camera is drawing too much power, possibly shorted"
    triggers_nogo: true
  - id: 52
    name: camera_no_power_error
    severity: ERROR
    description: "Camera is drawing no power. Is it connected?"
    triggers_nogo: true
  - id: 53
    name: flycap_hardware_error
    # Fault should be an ERROR after verification of its impact.
    severity: WARNING
    description: "Fly Capture Camera has error status."
    deprecated: true
  - id: 54
    name: sensor_row_time_mismatch
    severity: WARNING
    description: "Rolling shutter row time does not match the expected row time"
  - id: 55
    name: isp_temperature_low_warn
    severity: WARNING
    description: "The ISP on the camera is too low the camera may not be functioning properly"
  - id: 56
    name: isp_temperature_high_warn
    severity: WARNING
    description: "The ISP on the camera is getting hot and may shut down soon"
  - id: 57
    name: isp_temperature_low_error
    severity: ERROR
    description: "The ISP on the camera is too low the camera is outside of spec"
    triggers_nogo: true
  - id: 58
    name: isp_temperature_high_error
    severity: ERROR
    description: "The ISP on the camera is overheated"
    triggers_nogo: true
  - id: 59
    name: sensor_temperature_low_warn
    severity: WARNING
    description: "The sensor on the camera is too low. The camera may not be functioning properly"
  - id: 60
    name: sensor_temperature_high_warn
    severity: WARNING
    description: "The sensor on the camera is getting hot and may shut down soon"
  - id: 61
    name: sensor_temperature_low_error
    severity: ERROR
    description: "The sensor on the camera is too low. The camera is outside of spec"
    triggers_nogo: true
  - id: 62
    name: sensor_temperature_high_error
    severity: ERROR
    description: "The sensor on the camera is overheated"
    triggers_nogo: true
  - id: 63
    name: fpga_temperature_low_warn
    severity: WARNING
    description: "Camera capture card is near the minimum temperature."
  - id: 64
    name: fpga_temperature_low_error
    severity: ERROR
    description: "Camera capture card is below the minimum temperature."
    triggers_nogo: true
  - id: 65
    name: camera_power_low_warn
    severity: WARNING
    description: "Camera is near the minimum power consumption."
  - id: 66
    name: camera_power_high_warn
    severity: WARNING
    description: "Camera is near the maximum power consumption."
  - id: 67
    name: camera_power_low_error
    severity: ERROR
    description: "Camera is below the minimum allowed power consumption."
    triggers_nogo: true
  - id: 68
    name: camera_power_high_error
    severity: ERROR
    description: "Camera is above the maximum allowed power consumption."
    triggers_nogo: true
  - id: 69
    name: unsupported_bitstream
    severity: ERROR
    description: "Bitstream is not supported by current framegrabber hardware revision"
    triggers_nogo: true
  - id: 70
    name: framegrabber_to_device_dma_not_enabled
    severity: WARNING
    description: "GPU Direct pipeline is not enabled. Performance may be degraded."
  - id: 71
    name: camera_firmware_crc_mismatch
    severity: ERROR
    description: "Camera firmware CRC error. You may be running the wrong firmware for this camera, or the camera firmware may be corrupted."
    triggers_nogo: true
  - id: 72
    name: camera_internal_state_error
    severity: ERROR
    description: "Camera internal state error. This is due to a component on the camera raising an internal error flag. The camera must be queried to determine the reason for the fault."
    triggers_nogo: true
  - id: 73
    name: pcie_link_speed_mismatch
    severity: INFO
    description: "Framegrabber link speed is lower than expected"
  - id: 74
    name: pcie_link_width_mismatch
    severity: INFO
    description: "Framegrabber link width is lower than expected"
