feat(core): add heartbeat watchdog (deadman timer) (#2895)#2905
Open
tpayne-censystech wants to merge 3 commits into
Open
feat(core): add heartbeat watchdog (deadman timer) (#2895)#2905tpayne-censystech wants to merge 3 commits into
tpayne-censystech wants to merge 3 commits into
Conversation
While a watchdog timeout is configured, MAVSDK's periodic heartbeats are only sent as long as the watchdog keeps being fed at least once per timeout period, so heartbeats reflect the liveness of the client application. - Configure via Configuration::set_heartbeat_watchdog_timeout_s() or at runtime via Mavsdk::set_heartbeat_watchdog_timeout_s(); must be 0 (disabled) or at least 1 second. - Feed via Mavsdk::feed_heartbeat_watchdog() (C++/C API) or the FeedHeartbeatWatchdog gRPC RPC. Also exposed as the SetHeartbeatWatchdogTimeout RPC (proto submodule bump) and the mavsdk_server --heartbeat-watchdog-timeout CLI option. - Heartbeats latch off until fed: on enable, timeout change, expiry, and any other stop (e.g. disconnect), so a dead client cannot emit heartbeats across reconnects or discovery. A feed only restarts heartbeats that are supposed to be sent (always_send_heartbeats or a connected system). - Watchdog state is guarded by _heartbeat_mutex with a generation counter against in-flight expiries; configuration writers are serialized on a dedicated mutex, and heartbeat starts/stops self-heal against stale policy snapshots. - Unit tests (expiry, latching, policy, feed restart, reconfiguration, stress) and gRPC service tests.
tpayne-censystech
force-pushed
the
feat-2895
branch
from
July 16, 2026 17:57
6dc8da3 to
032d8f1
Compare
Collaborator
|
Thanks @tpayne-censystech, let me check CI, once that passes I'll merge the proto PR, and then update this PR and then merge it. |
Use a checked-out MAVLink channel for test inject packing, and define MavlinkChannels::Instance() in the .cpp so shared builds share one allocator.
Author
|
@julianoes , I tried to fix the CI but I can't get it to run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.