AutonomyController

AutonomyController class for managing autonomous operations and mission planning.

#include <autonomy_controller.hpp>

Classes

class AutonomyController

Manages autonomous operations and mission planning on a vehicle.

Lifetime is bound to the owning Vehicle. Obtain via `vehicle.GetAutonomyController()`. The returned reference is stable for the vehicle's lifetime.

Two mission families are exposed through one surface: - Named missions — catalogue-driven (circle, exploration, frontier-explore). - Task missions — free-form natural-language goals dispatched to an onboard AI planner (e.g. "scan the whole house").

Supervised missions additionally offer operator-in-the-loop navigation: fetch GetCandidates(), then confirm with GoTo()/GoToPose()/Spin().

struct Status

Snapshot of autonomy state (service `STATUS`).

FieldTypeDescription
active bool true while a mission is running
mission std::string name of the active mission ("" if none)
state std::string mission-defined state string
detail std::string human-readable detail / last event
paused bool operator paused the mission (state kept)
raw_json std::string

struct NavCandidate

A proposed next-hop goal offered by a supervised mission (map frame).

FieldTypeDescription
x float target X in map frame (m)
y float target Y in map frame (m)
z float target altitude in map frame (m); 0/ignored for ground
yaw float suggested final heading (rad); 0 if unconstrained
score float mission-defined desirability (higher = better)
is_probe bool true = open-direction probe (into unknown)
has_altitude bool true only when `z` is meaningful (aerial)
auto IsAvailable() const -> bool

True when the controller has a route to the vehicle's autonomy-service (i.e. the last command reached it). Performs a lightweight probe on the first call.

Returns: bool

auto GetAvailableMissions() const -> std::vector<std::string>

Lists the named missions the vehicle's autonomy-service supports (service `LIST`).

Returns: std::vector<std::string>

auto SelectMission(const std::string& name) -> bool

Selects and activates a named mission (service `SELECT `).

ParameterTypeDescription
name const std::string&

Returns: true if the service accepted and started the mission.

auto StartTaskMission(const std::string& task) -> bool

Starts a free-form, AI-planned task mission (e.g. "patrol the yard").

ParameterTypeDescription
task const std::string&

Returns: true if accepted, false if unsupported or rejected.

auto Stop() -> void

Stops / aborts the active mission and holds the vehicle in place.

auto Pause() -> void

Toggles pause/resume on the active mission (where supported).

auto Resume() -> void

Resume a paused mission from where it left off.

The counterpart to Pause(), and deliberately distinct from re-selecting the mission: pause keeps the mission's internal progress (a waypoint route keeps its leg index), so resuming continues rather than restarting.

auto UploadRoute(const std::string& route_json) -> bool

Replaces the waypoint route in one atomic upload.

Coordinates are in map-frame metres. Rejected wholesale if any point is malformed, or if the route is currently being flown.

ParameterTypeDescription
route_json const std::string& Route as `{"waypoints":[{"x":…,"y":…,"agl":…}, …]}`.

Returns: true when the service accepted it.

auto GetRoute() const -> std::string

Returns the route the service currently holds, as its raw ROUTE reply.

Includes the mission name and content hash so callers can check the held route against the authoritative one.

Returns: The ROUTE reply JSON, or empty string if the service is unreachable.

auto Reset() -> void

Resets the active mission — aborts the current goal and restarts from a clean state (service `RESET`). Issued after a map change or loop-closure.

auto GetStatus() const -> Status

Returns the latest autonomy status snapshot.

Returns: Status

auto OnStatusChanged(std::function<void(const Status&)> cb) -> void

Registers a callback fired when the autonomy status changes.

ParameterTypeDescription
cb std::function<void(const Status&)> Callback invoked with the new Status. Pass an empty callable to clear.
auto GetCandidates() const -> std::vector<NavCandidate>

Candidate next-hop goals for the active supervised mission (`CANDIDATES`).

Returns: std::vector<NavCandidate>

auto IsSpinSuggested() const -> bool

True when the mission has nothing to propose and is asking the operator to confirm a look-around spin. Reflects the most recent GetCandidates() reply.

Returns: bool

auto SupportsAltitude() const -> bool

True when this vehicle's autonomy supports altitude-aware (3D) goals. False for ground/marine robots.

Returns: bool

auto GoTo(float x, float y) -> bool

Confirms a 2D navigation goal (`GOTO `). Unchanged ground contract.

ParameterTypeDescription
x float
y float

Returns: bool

auto GoTo(float x, float y, float z, AltitudeReference ref = AltitudeReference::RelativeToCurrentPosition) -> bool

Confirms a 3D navigation goal (aerial). Emits `GOTO_3D` ONLY when SupportsAltitude() is true; otherwise returns false without sending.

ParameterTypeDescription
x float
y float
z float
ref AltitudeReference

Returns: bool

auto GoToPose(float x, float y, float yaw) -> bool

Confirms a 2D goal with final heading (`GOTO_POSE `).

ParameterTypeDescription
x float
y float
yaw float

Returns: bool

auto GoToPose(float x, float y, float z, float yaw, AltitudeReference ref = AltitudeReference::RelativeToCurrentPosition) -> bool

Confirms a 3D goal with final heading (aerial). Emits `GOTO_POSE_3D` ONLY when SupportsAltitude() is true; otherwise returns false.

ParameterTypeDescription
x float
y float
z float
yaw float
ref AltitudeReference

Returns: bool

auto Spin() -> bool

Requests an in-place look-around rotation (`SPIN`).

Returns: bool