This repository has been archived on 2026-06-17. You can view files and clone it, but cannot push or open issues or pull requests.
FireWatchTower_2axis/host
pgdalmeida 0ff062f48e
repo refactoring
2026-05-07 19:23:30 +02:00
..
CMakeLists.txt repo refactoring 2026-05-07 19:23:30 +02:00
Camera.cpp repo refactoring 2026-05-07 19:23:30 +02:00
Camera.h repo refactoring 2026-05-07 19:23:30 +02:00
FWT_host.cpp repo refactoring 2026-05-07 19:23:30 +02:00
JPEG_XL.h repo refactoring 2026-05-07 19:23:30 +02:00
Log.h repo refactoring 2026-05-07 19:23:30 +02:00
MQTT.cpp repo refactoring 2026-05-07 19:23:30 +02:00
MQTT.h repo refactoring 2026-05-07 19:23:30 +02:00
Parser.h repo refactoring 2026-05-07 19:23:30 +02:00
README.md repo refactoring 2026-05-07 19:23:30 +02:00
Serial.h repo refactoring 2026-05-07 19:23:30 +02:00
deploy.sh repo refactoring 2026-05-07 19:23:30 +02:00
timing.h repo refactoring 2026-05-07 19:23:30 +02:00

README.md

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):

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

mkdir build && cd build
cmake ..
make -j$(nproc)

Usage

./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:

./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.

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<heading> — Set target heading (guided mode)

MQTT Integration

Connects to broker at 172.16.42.1 (hardcoded; modify MQTT.cpp to change). Subscribes to two control topics and publishes status/camera events.

Subscribed Topics

Topic Payload Effect
GGS/FWT/<name>/ControlCode 0 or 1 Switch control mode: 0=free scan, 1=guided heading
GGS/FWT/<name>/target_HDG Float string Target yaw heading for guided mode

Published Topics

Topic Payload Description
GGS/FWT/<name>/StatusCode Integer Current control mode
GGS/FWT/<name>/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 <option> <value> Set camera parameter via Vimba
set fps <value> Change image rate (images/sec)
set motorctl <command> Send raw command to firmware
debug Toggle motor controller info output
exit Shut down

Source Files

File Purpose
FWT_host.cpp Main entry point, CLI parsing, main loop
Camera.h / Camera.cpp Vimba camera handler, image queue, JPEG XL encoding
MQTT.h / MQTT.cpp Paho MQTT client wrapper, callback handling
Serial.h Boost.ASIО serial port, telemetry parser
Parser.h Boost.Spirit stdin command parser
timing.h Timer utility class
Log.h Logging utilities
JPEG_XL.h JPEG XL encoding wrapper