Skip to content

Commit

Permalink
server cpp: improve handling of crashed CF
Browse files Browse the repository at this point in the history
When connecting two CFs and turning on off, the unicast connection of the other one essentially froze. There were two reasons:

1.) Division by zero caused a crash;
2.) The crazyflie_link_cpp essentially starved one connection.

Fixes #419.
  • Loading branch information
whoenig committed Feb 7, 2024
1 parent 4260ba1 commit 6d1495b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crazyflie/deps/crazyflie_tools
8 changes: 5 additions & 3 deletions crazyflie/src/crazyflie_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,11 @@ class CrazyflieROS
}

auto stats = cf_.connectionStatsDelta();
float ack_rate = stats.sent_count / stats.ack_count;
if (ack_rate < min_ack_rate_) {
RCLCPP_WARN(logger_, "Ack rate: %.1f %%", ack_rate * 100);
if (stats.ack_count > 0) {
float ack_rate = stats.sent_count / stats.ack_count;
if (ack_rate < min_ack_rate_) {
RCLCPP_WARN(logger_, "Ack rate: %.1f %%", name_.c_str(), ack_rate * 100);
}
}

if (publish_stats_) {
Expand Down

0 comments on commit 6d1495b

Please sign in to comment.