# Host Application C++ application running on the LattePanda's Linux side. Handles camera acquisition, serial communication with the Arduino firmware, and MQTT-based remote control. ## Dependencies | Library | Purpose | |---------|---------| | **Vimba SDK** | Camera control (Allied Vision / FLIR) | | **Eclipse Paho MQTT C/C++** | MQTT client for telemetry and remote commands | | **OpenCV 4** | Image processing and codecs | | **libjxl** | JPEG XL image encoding | | **Boost** | Program options, ASIO (serial), Spirit (parsing), threading | Install system packages (Debian/Ubuntu): ```bash sudo apt install libboost-all-dev libopencv-dev libjxl-dev libpaho-mqttpp3-dev libpaho-mqtt3-dev ``` Vimba SDK must be installed separately from Allied Vision. ## Build ```bash mkdir build && cd build cmake .. make -j$(nproc) ``` ## Usage ```bash ./FireWatchTower_2axis [options] Options: -h, --help Produce help message -i, --init [bool] Run gimbal endstop initialization sequence -s, --start [bool] Auto-start camera acquisition on launch ``` Example: ```bash ./FireWatchTower_2axis --init true --start true ``` ## Serial Communication The host communicates with the Arduino firmware over `/dev/ttyACM0` at 115200 baud. ### Incoming Telemetry The firmware periodically sends motor status lines prefixed with `$`, semicolon-delimited: ``` $Xenc;Xerr;sgt_val;sgt_stat;is_moving;control_status;hdg;deviation_warn;humid;temp;fan_pwm ``` Parsed into `motor_info` struct in [Serial.h](Serial.h). ### Outgoing Commands Single-character commands sent via `serial.sendCommand()`: - `r` — Reset motor parameters and power on - `e` — Reset SGT (step goal threshold) - `q` — Run endstop homing sequence - `y` — Load heading calibration from EEPROM - `ud80` — Set auto-scan step length - `p` — Step yaw to next position (trigger after stop) - `kd` — Set target heading (guided mode) ## MQTT Integration Connects to broker at `172.16.42.1` (hardcoded; modify [MQTT.cpp](MQTT.cpp) to change). Subscribes to two control topics and publishes status/camera events. ### Subscribed Topics | Topic | Payload | Effect | |-------|---------|--------| | `GGS/FWT//ControlCode` | `0` or `1` | Switch control mode: 0=free scan, 1=guided heading | | `GGS/FWT//target_HDG` | Float string | Target yaw heading for guided mode | ### Published Topics | Topic | Payload | Description | |-------|---------|-------------| | `GGS/FWT//StatusCode` | Integer | Current control mode | | `GGS/FWT//CamEvent/RGB` | — | Camera event notifications | ## Interactive Commands (stdin) While running, the host accepts commands on stdin parsed by Boost.Spirit: | Command | Description | |---------|-------------| | `start` | Start camera acquisition | | `stop` | Stop camera acquisition | | `set camera