4 #include <boost/program_options.hpp> 5 #include <crazyflie_cpp/Crazyflie.h> 6 #include <crazyflie_cpp/crtp.h> 15 , time_since_epoch(time_since_epoch)
25 auto now = std::chrono::high_resolution_clock::now();
26 auto now_us = std::chrono::time_point_cast<std::chrono::milliseconds>(now);
28 auto value = now_us.time_since_epoch();
48 sumRoundtripTime += roundtripTime;
54 std::cout <<
"RSSI: " << (int)cb->
rssi << std::endl;
59 linkQualitySent += 100;
60 linkQualityAcked += quality * 100;
64 int main(
int argc,
char **argv)
68 std::string defaultUri(
"radio://0/80/2M/E7E7E7E7E7");
71 namespace po = boost::program_options;
73 po::options_description desc(
"Allowed options");
75 (
"help",
"produce help message")
76 (
"uri", po::value<std::string>(&uri)->default_value(defaultUri),
"unique ressource identifier")
77 (
"numPackets", po::value<uint32_t>(&numPackets)->default_value(1000),
"unique ressource identifier")
83 po::store(po::parse_command_line(argc, argv, desc), vm);
86 if (vm.count(
"help")) {
87 std::cout << desc <<
"\n";
93 std::cerr << e.what() << std::endl << std::endl;
94 std::cerr << desc << std::endl;
106 for (
size_t i = 0; i < 1000; ++i) {
113 for (uint64_t
id = 0;
id < numPackets; ++
id) {
121 packet.
header = *
reinterpret_cast<const uint8_t*
>(&p.
header);
130 for (
size_t i = 0; i < 1000; ++i) {
134 std::cout <<
"numPacketsReceived: " << numPacketsReceived / (double)numPackets * 100.0f <<
" %" << std::endl;
135 std::cout <<
"Avg. roundtrip time: " << sumRoundtripTime / (double) numPacketsReceived <<
" ms" << std::endl;
136 std::cout << numPackets / (timeToSent / 1000.0f) <<
" packets/s sent" << std::endl;
137 std::cout <<
"link quality: " << linkQualityAcked / (float)linkQualitySent << std::endl;
142 catch(std::exception& e)
144 std::cerr << e.what() << std::endl;
void setEmptyAckCallback(std::function< void(const crtpPlatformRSSIAck *)> cb)
void onGenericPacket(const ITransport::Ack &ack)
void onLinkQuality(float quality)
void setGenericPacketCallback(std::function< void(const ITransport::Ack &)> cb)
uint8_t data[CRTP_MAX_DATA_SIZE]
void queueOutgoingPacket(const crtpPacket_t &packet)
int main(int argc, char **argv)
uint32_t linkQualityAcked
uint64_t sumRoundtripTime
uint64_t time_since_epoch
crtpMyPacket(uint64_t id, uint64_t time_since_epoch)
uint32_t numPacketsReceived
void onEmptyAck(const crtpPlatformRSSIAck *cb)
struct crtpMyPacket __attribute__((packed))
void setLinkQualityCallback(std::function< void(float)> cb)