#pragma once // The tower's three modes of operation, and what each one accepts. // // auto - sweep the scan grid, a picture at every waypoint (the normal, // unattended state; the boot service starts here with --start); // pan - watch one direction: centred on a heading, walk left to right // across a span, a picture at each position, then back to the left // edge and again; // manual - the gimbal does nothing by itself; a person drives it, over the // MQTT Command topic or at the console. // // Modes change only by command (`mode auto|pan|manual`), and the tower reports // its mode on StatusCode, as the numeric value of Mode. #include #include namespace fgc { enum class Mode { Auto = 0, Pan = 1, Manual = 2 }; // values = StatusCode const char* modeName(Mode m); // "auto" / "pan" / "manual" // `mode pan []`, all in degrees. Heading is a true // bearing; the span is the full width covered, centred on it. struct PanSpec { double heading = 0.0; double span = 0.0; double pitch = 0.0; }; // The bearings a pan visits, left to right. A span narrower than one picture // (`step`, hardware.ini [Hardware] pan_step_deg) is a single heading, the // centre. Otherwise the span is cut into ceil(span / step) equal intervals and // both edges are included: 90 +/- 15 at 6 degrees is 75, 81, ..., 105 - six // pictures, never more than `step` apart. Bearings are wrapped to [0, 360). std::vector panHeadings(const PanSpec& pan, double step); // `mode ...` from its whitespace-separated tokens (tokens[0] == "mode"). // `valid` false with `error` set on a bad command; a bare `mode` is valid with // `query` set - it asks for the mode rather than changing it. struct ModeRequest { bool valid = false; bool query = false; Mode mode = Mode::Manual; PanSpec pan; std::string error; }; ModeRequest parseModeCommand(const std::vector& tokens); // May this console command line run in `mode`? Manual accepts everything. Auto // and pan accept only what cannot move the gimbal or change the tower's // settings: reading its state, the log's verbosity, changing mode, cancelling, // and exit. The one list, used for every source - MQTT, console, dashboard keys. bool allowedIn(Mode mode, const std::string& line); } // namespace fgc