Geofence: Add vehicle sync and plan types#2807
Conversation
Adds the runtime types backing the new geofencing flow: FenceLatLng, FencePolygon (with inclusion flag and vertex list), FenceCircle, BreachReturnPoint, the Cockpit-level GeoFencePlan, the on-disk CockpitFencePlanFile (.cfp) envelope, and the MavlinkPlanFile envelope that lets fence (and mission) plans round-trip with other ground stations through the de-facto MAVLink-ecosystem .plan JSON format. Type guards (instanceOfGeoFencePlan, instanceOfCockpitFencePlanFile, instanceOfMavlinkPlanFile) only inspect the outer discriminator + version so deeper validation stays at the call site that knows the schema. Signed-off-by: Arturo Manzoli <arturomanzoli@gmail.com>
On vehicle bring-up, send MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES and cache the bitmask received via the AUTOPILOT_VERSION message. Exposes `capabilities()` / `hasCapability(bit)` accessors, and a new `onCapabilities` signal so consumers can react when the bitmask first arrives. Failures are logged at warn level and gracefully fall back to "optimistic" capability reporting (consumers default to enabling features when no AUTOPILOT_VERSION has been seen yet). Signed-off-by: Arturo Manzoli <arturomanzoli@gmail.com>
Automated PR Review (Claude)0. SummaryVerdict: MINOR SUGGESTIONS Minor items to consider: 1.1, 1.2, 1.3, 4.1, 6.1, 6.2 This PR adds the foundational types, MAVLink conversion helpers, vehicle-level fence upload/fetch/clear, autopilot capability tracking, parameter request helpers, and a comprehensive 1. Correctness & Implementation Bugs1.1 1.2 1.3 2. AGENTS.md Adherence — ✅3. Security — ✅4. Performance4.1 5. UI / UX — ✅6. Code Quality & Style6.1 6.2 7. Commit Hygiene — ✅8. Tests — ✅9. Documentation — ✅10. Nitpicks / Optional10.1 10.2 10.3 Generated by Claude. This is advisory; a human reviewer must still approve. |
Adds two helpers that turn the existing PARAM_REQUEST_READ / PARAM_VALUE round-trip into something callers can actually \`await\`: - \`requestParameter(name)\`: fires a single PARAM_REQUEST_READ for the given parameter id; the reply still bubbles up through \`onParameter\` for code that wants to keep listening passively. - \`requestParameterValue(name, timeoutMs)\`: subscribes a one-shot listener that resolves with the value as soon as the matching PARAM_VALUE arrives (or undefined on timeout). Both the listener and the timeout handle are cleared as soon as the promise settles to avoid stray callbacks. Signed-off-by: Arturo Manzoli <arturomanzoli@gmail.com>
fba258a to
8ff9d6b
Compare
|
/review |
Automated PR Re-review 2 (Claude)Comparing Previous findings status
New findings0. SummaryVerdict: MINOR SUGGESTIONS Minor items to consider: 6.1, 6.2 (carried over nits) This re-review covers the incremental changes since the first review. The author addressed all four substantive findings (1.1–1.3, 4.1) — 1. Correctness & Implementation Bugs — ✅2. AGENTS.md Adherence — ✅3. Security — ✅4. Performance — ✅5. UI / UX — ✅6. Code Quality & Style — ✅No new findings beyond the two carried-over nits (6.1 and 6.2) noted in the status table above. 7. Commit Hygiene — ✅8. Tests — ✅9. Documentation — ✅10. Nitpicks / Optional — ✅No new nits beyond 10.3 carried over above. Generated by Claude. This is advisory; a human reviewer must still approve. |
Wires geofence support into the existing MAVLink mission micro-service: - geofence-conversion.ts: pure helpers that translate between a Cockpit GeoFencePlan and a flat list of MissionItemInt[]. Polygons are emitted vertex-per-item with a shared param1=vertex_count; circles use param1 for the radius; the optional breach return point goes last as a MAV_FRAME_GLOBAL_RELATIVE_ALT item. The reverse path detects bad/incomplete polygon item streams from the autopilot and surfaces a descriptive error. - vehicle.ts: extracts _fetchMissionItems / _uploadMissionItems from the mission code so fence and mission paths share the handshake, then layers uploadFence / fetchFence / clearFence on top using MAV_MISSION_TYPE_FENCE. uploadFence also calls _ensureArduPilotPolygonFenceTypeBit to set the Polygon bit (4) of FENCE_TYPE on ArduPilot — without it the autopilot silently ignores the uploaded polygons/circles. Other FENCE_TYPE bits are preserved. Signed-off-by: Arturo Manzoli <arturomanzoli@gmail.com>
Surfaces the new MAVLink capability and fence APIs through the existing main-vehicle Pinia store so consumers don't need to reach into the underlying MAVLinkVehicle instance: - \`capabilities\` ref + \`onCapabilities\` subscription, kept in sync as AUTOPILOT_VERSION arrives. - \`uploadFence\` / \`fetchFence\` / \`clearFence\` proxy actions, mirroring the existing mission helpers (and emitting the same "Geofence deleted from vehicle" snackbar on clear). - \`requestParameter\` proxy so other stores (notably the upcoming geo-fence store) can pull individual parameter values without duplicating the MAVLink boilerplate. Signed-off-by: Arturo Manzoli <arturomanzoli@gmail.com>
Pinia store that owns all editor-side geofencing state: - Reactive polygons, circles and breach-return point with \`cockpit-draft-fence\` (in-progress) and \`cockpit-vehicle-fence\` (last uploaded) persistence so the user doesn't lose work across reloads. - Plan import/export between Cockpit's runtime shape, the .cfp envelope and the de-facto MAVLink-ecosystem .plan file. - Vehicle sync: \`uploadToVehicle\` (auto-enables FENCE_ENABLE and FENCE_AUTOENABLE on ArduPilot once the upload completes), \`downloadFromVehicle\`, \`clearOnVehicle\`, plus \`setFenceEnabled\` / \`setFenceAutoEnable\` that talk to the new MAVLink helpers. - \`FENCE_ENABLE\` polling watch (3 s) tied to ArduPilot + a loaded plan so the Map widget toggle reflects autopilot-side flips (e.g. takeoff-time activation) the autopilot doesn't broadcast. - Capability gate via \`isFenceSupported\` (\`MISSION_FENCE\` bit) and a \`detectMissionBreaches\` helper that flags mission waypoints which fall outside an inclusion fence or inside an exclusion fence so the UI can warn before mission upload. Signed-off-by: Arturo Manzoli <arturomanzoli@gmail.com>
8ff9d6b to
eed1509
Compare
.cfpand MAVLink.planenvelopes and their type guards.GeoFencePlanand theMissionItemIntarray format.AUTOPILOT_VERSIONon the MAVLink vehicle.uploadFence,fetchFence,clearFence,requestParameter) on the main-vehicle store.geoFencePinia store: editor draft state, persistence undercockpit-keys, vehicle sync, visibility-gatedFENCE_ENABLEenforcement polling, and mission-vs-fence breach detection.First of three sequential PRs splitting #2671 — the follow-ups land on top of this one:
geofence-planning-editor— Mission/GeoFence sidebar switch, polygon and circle drawing, inclusion/exclusion tagging, breach return point, parameter panel, vehicle send/fetch/clear,.cfp/.planimport-export, and the pre-upload breach check.geofence-map-overlay— live fence overlay and enforcement toggle on the Map widget.