Skip to content

Attempt to re-initiate FC coms on data loss#32

Open
mBerdal wants to merge 8 commits into
tool-v2from
DRONE-1485-robusitfy-dji_sdk
Open

Attempt to re-initiate FC coms on data loss#32
mBerdal wants to merge 8 commits into
tool-v2from
DRONE-1485-robusitfy-dji_sdk

Conversation

@mBerdal

@mBerdal mBerdal commented Mar 24, 2026

Copy link
Copy Markdown

No description provided.

@mBerdal mBerdal marked this pull request as draft March 24, 2026 12:41
@mBerdal mBerdal marked this pull request as ready for review March 31, 2026 10:55
@mBerdal mBerdal requested a review from a team March 31, 2026 10:55
@mikkelti mikkelti requested a review from Copilot June 8, 2026 11:37
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be tested.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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};

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.

3 participants