Attempt to re-initiate FC coms on data loss#32
Open
mBerdal wants to merge 8 commits into
Open
Conversation
mikkelti
reviewed
Jun 8, 2026
Comment on lines
+221
to
+223
| // TODO: will display mode change instantly, or will a few messages containing | ||
| // a display mode other than MODE_NAVI_SDK_CTRL be published before? If so, ensure that | ||
| // the rest of the system handles it correctly |
There was a problem hiding this comment.
Pull request overview
This PR adds a flight-controller (FC) communication watchdog to detect telemetry loss and attempt to recover by tearing down and recreating the OSDK Vehicle, re-subscribing to FC telemetry, and optionally re-requesting SDK control authority after communications are re-established.
Changes:
- Add a periodic watchdog timer that triggers a
Vehicle+ telemetry re-init when no recent data is observed. - Track whether SDK control should be re-requested after FC comms recovery (based on successful control requests).
- Mark “data received” from the 400Hz subscription publisher callback to feed the watchdog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
dji_sdk/src/modules/dji_sdk_node.cpp |
Adds the watchdog timer, recovery logic (recreate Vehicle, restart data subscription), and helper to mark data received. |
dji_sdk/src/modules/dji_sdk_node_services.cpp |
Remembers whether to re-request SDK control after recovery when a control request succeeds. |
dji_sdk/src/modules/dji_sdk_node_publisher.cpp |
Marks data received on each 400Hz publish to satisfy the watchdog. |
dji_sdk/include/dji_sdk/dji_sdk_node.h |
Declares new watchdog APIs/state, adds stored NodeHandle, and updates signatures for activation/cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+151
to
+152
| const bool data_recieved{has_recieved_data_since_prev_check_}; | ||
| has_recieved_data_since_prev_check_ = false; |
Comment on lines
+131
to
+134
| fc_communication_watchdog_timer_ = nh_.createTimer( | ||
| FC_COMMUNICATION_WATCHDOG_NOMINAL_PERIOD, | ||
| &DJISDKNode::fcCommunicationWatchdogCallback, this | ||
| ); |
Comment on lines
+159
to
+164
| if (vehicle) | ||
| { | ||
| cleanUpSubscribeFromFC(1u); | ||
| delete vehicle; | ||
| vehicle = nullptr; | ||
| } |
Comment on lines
+176
to
+182
| if (!initDataSubscribeFromFC(nh_)) | ||
| { | ||
| ROS_ERROR_STREAM("Restarting data subscription from FC failed. Retrying in " << FC_COMMUNICATION_WATCHDOG_RESTART_SUB_PERIOD.toSec() << " seconds."); | ||
| fc_communication_watchdog_timer_.setPeriod(FC_COMMUNICATION_WATCHDOG_RESTART_SUB_PERIOD, true); | ||
| fc_communication_watchdog_timer_.start(); | ||
| } | ||
| else |
| return; | ||
|
|
||
| fc_communication_watchdog_timer_.stop(); // Avoid concurrent calls due to AsyncSpinner | ||
| ROS_ERROR_STREAM("No data recieved during the last " << (event.current_real - event.last_real).toSec() << " seconds."); |
Comment on lines
+218
to
+219
| flightControl(CONTROL_FLAG, 0.0, 0.0, 0.0, 0.0); | ||
| ROS_ERROR_STREAM("SDK control regained after re-initiating FC coms."); |
Comment on lines
+446
to
+451
| const ros::Duration FC_COMMUNICATION_WATCHDOG_NOMINAL_PERIOD{1.0}; | ||
| const ros::Duration FC_COMMUNICATION_WATCHDOG_RESTART_SUB_PERIOD{0.5}; | ||
| ros::Timer fc_communication_watchdog_timer_; | ||
| std::atomic_bool has_recieved_data_since_prev_check_{false}; | ||
|
|
||
| bool rerequest_sdk_ctrl_on_fc_coms_reestablished_{false}; |
Comment on lines
+448
to
+452
| ros::Timer fc_communication_watchdog_timer_; | ||
| std::atomic_bool has_recieved_data_since_prev_check_{false}; | ||
|
|
||
| bool rerequest_sdk_ctrl_on_fc_coms_reestablished_{false}; | ||
|
|
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.
No description provided.