An example indicating the network performance.
#include <chrono>
#include <iostream>
#include <thread>
int main(int argc, char** argv) {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " <robot-hostname>" << std::endl;
return -1;
}
uint64_t counter = 0;
double avg_success_rate = 0.0;
double min_success_rate = 1.0;
double max_success_rate = 0.0;
uint64_t time = 0;
std::cout.precision(2);
std::cout << std::fixed;
try {
std::array<double, 7> q_goal = {{0, -M_PI_4, 0, -3 * M_PI_4, 0, M_PI_2, M_PI_4}};
std::cout << "WARNING: This example will move the robot! "
<< "Please make sure to have the user stop button at hand!" << std::endl
<< "Press Enter to continue..." << std::endl;
std::cin.ignore();
std::cout << "Finished moving to initial joint configuration." << std::endl << std::endl;
std::cout << "Starting communication test." << std::endl;
{{20.0, 20.0, 18.0, 18.0, 16.0, 14.0, 12.0}}, {{20.0, 20.0, 18.0, 18.0, 16.0, 14.0, 12.0}},
{{20.0, 20.0, 18.0, 18.0, 16.0, 14.0, 12.0}}, {{20.0, 20.0, 18.0, 18.0, 16.0, 14.0, 12.0}},
{{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}}, {{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}},
{{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}}, {{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}});
[&time, &counter, &avg_success_rate, &min_success_rate, &max_success_rate, zero_torques](
if (time == 0.0) {
return zero_torques;
}
counter++;
if (counter % 100 == 0) {
std::cout << "#" << counter
<< std::endl;
}
std::this_thread::sleep_for(std::chrono::microseconds(100));
}
}
if (time >= 10000) {
std::cout << std::endl << "Finished test, shutting down example" << std::endl;
}
return zero_torques;
},
false, 1000);
std::cout << e.what() << std::endl;
return -1;
}
avg_success_rate = avg_success_rate / counter;
std::cout << std::endl
<< std::endl
<< "#######################################################" << std::endl;
uint64_t lost_robot_states = time - counter;
if (lost_robot_states > 0) {
std::cout << "The control loop did not get executed " << lost_robot_states << " times in the"
<< std::endl
<< "last " << time << " milliseconds! (lost " << lost_robot_states << " robot states)"
<< std::endl
<< std::endl;
}
std::cout << "Control command success rate of " << counter << " samples: " << std::endl;
std::cout << "Max: " << max_success_rate << std::endl;
std::cout << "Avg: " << avg_success_rate << std::endl;
std::cout << "Min: " << min_success_rate << std::endl;
if (avg_success_rate < 0.90) {
std::cout << std::endl
<< "WARNING: THIS SETUP IS PROBABLY NOT SUFFICIENT FOR FCI!" << std::endl;
std::cout << "PLEASE TRY OUT A DIFFERENT PC / NIC" << std::endl;
} else if (avg_success_rate < 0.95) {
std::cout << std::endl << "WARNING: MANY PACKETS GOT LOST!" << std::endl;
std::cout << "PLEASE INSPECT YOUR SETUP AND FOLLOW ADVICE ON" << std::endl
<< "https://frankaemika.github.io/docs/troubleshooting.html" << std::endl;
}
std::cout << "#######################################################" << std::endl << std::endl;
return 0;
}