================================================================================
OptiNav, Inc. 4D ACOUSTIC FUSION & TRIANGULATION SERVER (LINUX RELEASE)
Interface for multi-array BeamformX Drone Hound system
Parired to BeamformX version 7.0.41
================================================================================

1. OVERVIEW
-----------
This package provides a standalone 4D spacetime acoustic triangulation engine
(fusionE) and a reference visualization/telemetry receiver (mock_receiverD).
No Python installation or external libraries are required to run the compiled
binaries.

Package Contents:
  README.txt                This quick-start guide
  run.sh                    Master launcher script (Demo and Headless modes)
  fusionE                   Standalone 4D fusion and triangulation server
  mock_receiverD            Standalone telemetry monitor and 3D/2D plot display
  config.json               Network, array geometry, gating, and display config
  examples/mock_receiverD.py Reference Python source showing how to receive JSON
                            output from fusionE over TCP

2. EXTRACTION & SETUP
---------------------
Extract the archive and enter the release folder:

  tar -xzvf acoustic_tracker_release_YYYYMMDD.tar.gz
  cd acoustic_tracker_release

3. CONFIGURING ARRAYS & PARAMETERS (config.json)
------------------------------------------------
Before starting the system, edit config.json to match your array deployment:

  "sources":
    List each acoustic array's IP address, TCP port (default 9431), physical
    East-North-Up coordinates in meters ("enu": [E, N, U]), and orientation
    quaternion ("q": [qx, qy, qz, qw]).
    Tip: Placing the (0, 0, 0) ENU origin at the midpoint between the arrays
    keeps thetaENU, phiENU, and rENU centered on the array baseline.

  "target":
    IP address and TCP port (default 127.0.0.1:6000) where fusionE streams
    JSON triangulation matches and single-array bearings.
    - Same machine (Demo mode): Keep "ip": "127.0.0.1".
    - Remote receiver machine: Set "ip" to the remote computer's LAN IP address
      and run ./run.sh --headless on the fusionE machine.

  Fusion & Gating Parameters:
    "buffer_size"               Ring-buffer history length (default: 100)
    "tempC"                     Ambient air temperature in Celsius
    "rhPct"                     Relative humidity (%)
    "max_mahalanobis_distance"  4D Chi-squared gating limit (e.g., 0.1 - 5.0)
    "min_height"                Minimum source height above array (meters)
    "max_spect_error"           Max RMS spectral difference in dB (e.g., 6.0)
    "min_spect_level"           Minimum spectral bin level in dB (e.g., -15.0)
    "drone_metric_half_point_db" DroneMetric value (dB) corresponding to 0.50
                                drone confidence (default: 3.0)

  Display Settings (used by mock_receiverD):
    "target_persistance_time"   Display persistence for tracks/rays (seconds)
    "view_volume"               3D plot bounds (min/max east, north, up in m)

4. RUNNING THE SYSTEM
---------------------
A. Demo Mode (Starts both the visual dashboard and fusionE):
     ./run.sh

B. Headless / Custom Integration Mode (Starts fusionE only):
     ./run.sh --headless
   Use this mode on machines without a monitor or when your own software is
   listening on Port 6000 to ingest fusionE's JSON output stream.

Press Ctrl+C in the launcher terminal to cleanly shut down all processes.

5. RUNTIME COMMANDS (PORT 7000)
-------------------------------
fusionE listens on 0.0.0.0:7000 for live text commands from either the local
machine (127.0.0.1:7000) or a remote machine on the LAN (<fusionE_IP>:7000),
e.g., via netcat: `nc <fusionE_IP> 7000`.

  thresh <std. devs>    Set Mahalanobis gating limit (0.1 - 5.0)
  spect <dB>            Set max error for comparing spectra
  temp <deg C>          Set temperature
  rh <%>                Set relative humidity
  freq <kHz>            Set beamforming center frequency (2-6)
  dynamic <dB>          Set BeamformX dynamic range (usually 30)
  integ <sec>           Set integration time (0.5 - 2.0)
  dthresh <dB>          Set drone metric detection threshold (3) (larger for more results)
  range_metric_filter <yes/no> Filter sources by (drone metric < dthresh) and (r <= maximum range)
  min <dB>              Set min. SPL detection threshold (-25 to 0)
  pause / resume        Pause or Resume BeamformX (resume currently has a bug)
  log <filename>        Begin logging to filename such as fileA.bin
  stop                  Stop logging data
  folder <path>         Set the folder on the BeamformX PCs to Log and Load files
  load <filename>       Open a data file fileA.bin and play it
  exit                  Exit BeamformX with prefs saved
  help                  Display this command list in the fusionE console

6. OUTPUT FORMAT & LOGS
-----------------------
* Live TCP Stream (Port 6000): Newline-delimited JSON objects (JSON Lines)
  with two possible message types:

  1. Triangulated Match ("status": "acoustic_triangulation_match")
     Emitted when two arrays intersect within the Mahalanobis and spectral
     thresholds:
       - "peak_enut": [E, N, U, T]    Solved 4D coordinates (meters & Unix sec)
       - "thetaENU": float            Zenith angle from Up in global ENU (deg)
       - "phiENU": float              Compass azimuth clockwise from North (deg)
       - "rENU": float                Slant range from global ENU origin (m)
       - "drone_metric_dB": float     Combined RMS drone harmonic metric (dB)
       - "drone_confidence": float    Drone probability score in [0.0, 1.0]
       - "mahalanobis_dist": float    4D spacetime mismatch score
       - "spect_rms_error": float     Propagation-adjusted spectral RMS diff (dB)
       - "lossless_10m_dba": float    Back-propagated 10-m A-weighted level (dBA,
                                      or null if all bins are below floor)
       - "timestamp_processed": float Fusion server processing timestamp
       - "station_data": [...]        Array IDs, individual drone_metric_dB,
                                      and raw spectra from both stations

  2. Single-Array Line of Bearing ("status": "single_array_detection")
     Emitted when an upward-pointing detection does not match a second array:
       - "sender_id": int             Reporting array index
       - "origin_enu": [E, N, U]      Reporting array coordinates (meters)
       - "global_bearing_theta_deg"   Array-relative zenith angle in ENU (deg)
       - "global_bearing_phi_deg"     Array-relative azimuth from North (deg)
       - "estimated_range_m": float   Range estimate from BeamformX (m)
       - "thetaENU": float            Estimated zenith angle from ENU origin (deg)
       - "phiENU": float              Estimated azimuth from ENU origin (deg)
       - "rENU": float                Estimated slant range from ENU origin (m)
       - "drone_metric_dB": float     Reporting array drone harmonic metric (dB)
       - "drone_confidence": float    Drone probability score in [0.0, 1.0]
       - "spectrum": [...]            Frequency bin levels from the reporting array

* Disk Logs: Automatically saved as JSON-lines files in ./logs/ upon startup
  (with "status" formatted as "TRIANGULATION_MATCH" or "LINE_OF_BEARING").
* Custom Integration: See examples/mock_receiverD.py for a complete example
  of parsing both JSON payload types over TCP.
