Skip to content

feat(core): add heartbeat watchdog (deadman timer) (#2895)#2905

Open
tpayne-censystech wants to merge 1 commit into
mavlink:mainfrom
tpayne-censystech:feat-2895
Open

feat(core): add heartbeat watchdog (deadman timer) (#2895)#2905
tpayne-censystech wants to merge 1 commit into
mavlink:mainfrom
tpayne-censystech:feat-2895

Conversation

@tpayne-censystech

Copy link
Copy Markdown

Implements external control of MAVSDK heartbeat emission, per the API added in mavlink/MAVSDK-Proto#415.

When enabled, this disables MAVSDK's internally generated HEARTBEAT sending and drives emission from the client via a runtime-configurable deadman timeout. The client refreshes within the timeout to keep heartbeats flowing; if it crashes, disconnects, or stops servicing the path, MAVSDK stops sending, so PX4 sees the GCS/companion component go offline and triggers the configured lost-link failsafe (e.g. RTL). MAVSDK continues to own heartbeat content (sysid, compid, mav_type, etc.); the client only controls whether emission continues. Default behavior is unchanged.

Includes the proto submodule bump to the merged commit, regenerated mavsdk_server code, and the core implementation with tests.

Depends on mavlink/MAVSDK-Proto#415 (merge first).

Closes #2895

Contributed by Tyler Payne on behalf of Censys Technologies, Inc.

Add heartbeat_watchdog_timeout_s to Mavsdk::Configuration. While
configured, periodic heartbeats are only sent as long as
feed_heartbeat_watchdog() (C++/C API) or the FeedHeartbeatWatchdog RPC
keeps being called at least once per timeout period; on expiry
heartbeats latch off, including across reconnects and discovery, until
fed again, so they reflect the liveness of the client application.

A feed only restarts heartbeats stopped by the watchdog, and only if
they are supposed to be sent in the first place (always_send_heartbeats
or a connected system); it never starts heartbeats that are off for any
other reason.

mavsdk_server accepts the timeout via the new
--heartbeat-watchdog-timeout CLI option, plumbed through the new
mavsdk_server_run_with_mavlink_ids_and_options() C API entry point.

Covered by unit tests in heartbeat_watchdog_test.cpp (expiry, latching,
policy, feed restart, runtime reconfiguration) and a gRPC forwarding
test in core_service_impl_test.cpp.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for disabling native heartbeat sending and triggering HEARTBEAT over gRPC

1 participant