-
Notifications
You must be signed in to change notification settings - Fork 37
/
Crazyflie.h
869 lines (740 loc) · 20.8 KB
/
Crazyflie.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
#pragma once
#include <cstring>
#include <sstream>
#include <functional>
#include "Crazyradio.h"
#include "crtp.h"
#include <list>
#include <set>
#include <map>
#include <chrono>
#define ENABLE_SAFELINK 0
class Logger
{
public:
Logger() {}
virtual ~Logger() {}
virtual void info(const std::string& /*msg*/) {}
virtual void warning(const std::string& /*msg*/) {}
virtual void error(const std::string& /*msg*/) {}
};
extern Logger EmptyLogger;
class Crazyflie
{
public:
enum ParamType {
ParamTypeUint8 = 0x00 | (0x00<<2) | (0x01<<3),
ParamTypeInt8 = 0x00 | (0x00<<2) | (0x00<<3),
ParamTypeUint16 = 0x01 | (0x00<<2) | (0x01<<3),
ParamTypeInt16 = 0x01 | (0x00<<2) | (0x00<<3),
ParamTypeUint32 = 0x02 | (0x00<<2) | (0x01<<3),
ParamTypeInt32 = 0x02 | (0x00<<2) | (0x00<<3),
ParamTypeFloat = 0x02 | (0x01<<2) | (0x00<<3),
};
struct ParamTocEntry {
uint16_t id;
ParamType type;
bool readonly;
// ParamLength length;
// ParamType type;
// ParamSign sign;
// bool readonly;
// ParamGroup paramGroup;
std::string group;
std::string name;
};
union ParamValue{
uint8_t valueUint8;
int8_t valueInt8;
uint16_t valueUint16;
int16_t valueInt16;
uint32_t valueUint32;
int32_t valueInt32;
float valueFloat;
};
enum LogType {
LogTypeUint8 = 1,
LogTypeUint16 = 2,
LogTypeUint32 = 3,
LogTypeInt8 = 4,
LogTypeInt16 = 5,
LogTypeInt32 = 6,
LogTypeFloat = 7,
LogTypeFP16 = 8,
};
struct LogTocEntry {
uint8_t id;
LogType type;
std::string group;
std::string name;
};
enum BootloaderTarget {
TargetSTM32 = 0xFF,
TargetNRF51 = 0xFE,
};
enum MemoryType {
MemoryTypeEEPROM = 0x00,
MemoryTypeOneWire = 0x01,
MemoryTypeLED12 = 0x10,
MemoryTypeLOCO = 0x11,
MemoryTypeTRAJ = 0x12,
};
struct MemoryTocEntry {
uint16_t id;
MemoryType type;
uint32_t size;
uint64_t addr;
};
struct poly4d {
float p[4][8];
float duration;
} __attribute__((packed));
public:
Crazyflie(
const std::string& link_uri,
Logger& logger = EmptyLogger);
virtual ~Crazyflie();
void logReset();
void sendSetpoint(
float roll,
float pitch,
float yawrate,
uint16_t thrust);
void sendFullStateSetpoint(
float x, float y, float z,
float vx, float vy, float vz,
float ax, float ay, float az,
float qx, float qy, float qz, float qw,
float rollRate, float pitchRate, float yawRate);
void sendHoverSetpoint(
float vx,
float vy,
float yawrate,
float zDistance);
void sendStop();
void sendPositionSetpoint(
float x,
float y,
float z,
float yaw);
void sendExternalPositionUpdate(
float x,
float y,
float z);
void sendPing();
void reboot();
// returns new address
uint64_t rebootToBootloader();
void sysoff();
void trySysOff();
void alloff();
void syson();
float vbat();
void writeFlash(
BootloaderTarget target,
const std::vector<uint8_t>& data);
void readFlash(
BootloaderTarget target,
size_t size,
std::vector<uint8_t>& data);
void setChannel(uint8_t channel);
void requestLogToc(bool forceNoCache=false);
void requestParamToc(bool forceNoCache=false);
void requestMemoryToc();
std::vector<ParamTocEntry>::const_iterator paramsBegin() const {
return m_paramTocEntries.begin();
}
std::vector<ParamTocEntry>::const_iterator paramsEnd() const {
return m_paramTocEntries.end();
}
std::vector<LogTocEntry>::const_iterator logVariablesBegin() const {
return m_logTocEntries.begin();
}
std::vector<LogTocEntry>::const_iterator logVariablesEnd() const {
return m_logTocEntries.end();
}
std::vector<MemoryTocEntry>::const_iterator memoriesBegin() const {
return m_memoryTocEntries.begin();
}
std::vector<MemoryTocEntry>::const_iterator memoriesEnd() const {
return m_memoryTocEntries.end();
}
template<class T>
void setParam(uint8_t id, const T& value) {
ParamValue v;
memcpy(&v, &value, sizeof(value));
setParam(id, v);
}
void startSetParamRequest();
template<class T>
void addSetParam(uint8_t id, const T& value) {
ParamValue v;
memcpy(&v, &value, sizeof(value));
addSetParam(id, v);
}
void setRequestedParams();
template<class T>
T getParam(uint8_t id) const {
ParamValue v = getParam(id);
return *(reinterpret_cast<T*>(&v));
}
const ParamTocEntry* getParamTocEntry(
const std::string& group,
const std::string& name) const;
void setEmptyAckCallback(
std::function<void(const crtpPlatformRSSIAck*)> cb) {
m_emptyAckCallback = cb;
}
void setLinkQualityCallback(
std::function<void(float)> cb) {
m_linkQualityCallback = cb;
}
void setConsoleCallback(
std::function<void(const char*)> cb) {
m_consoleCallback = cb;
}
static size_t size(LogType t) {
switch(t) {
case LogTypeUint8:
case LogTypeInt8:
return 1;
break;
case LogTypeUint16:
case LogTypeInt16:
case LogTypeFP16:
return 2;
break;
case LogTypeUint32:
case LogTypeInt32:
case LogTypeFloat:
return 4;
break;
default:
// assert(false);
return 0;
}
}
void setGenericPacketCallback(
std::function<void(const ITransport::Ack&)> cb) {
m_genericPacketCallback = cb;
}
/**
* En-queues a generic crtpPacket into a vector so that it can be transmitted later.
* @param packet the crtpPacket to be en-queued.
*/
void queueOutgoingPacket(const crtpPacket_t& packet) {
m_outgoing_packets.push_back(packet);
}
void transmitPackets();
// High-Level setpoints
void setGroupMask(uint8_t groupMask);
void takeoff(float height, float duration, uint8_t groupMask = 0);
void land(float height, float duration, uint8_t groupMask = 0);
void stop(uint8_t groupMask = 0);
void goTo(float x, float y, float z, float yaw, float duration, bool relative = false, uint8_t groupMask = 0);
void uploadTrajectory(
uint8_t trajectoryId,
uint32_t pieceOffset,
const std::vector<poly4d>& pieces);
void startTrajectory(
uint8_t trajectoryId,
float timescale = 1.0,
bool reversed = false,
bool relative = true,
uint8_t groupMask = 0);
private:
void sendPacket(
const uint8_t* data,
uint32_t length,
ITransport::Ack& result,
bool useSafeLink = ENABLE_SAFELINK);
bool sendPacket(
const uint8_t* data,
uint32_t length,
bool useSafeLink = ENABLE_SAFELINK);
void sendPacketOrTimeout(
const uint8_t* data,
uint32_t length,
bool useSafeLink = ENABLE_SAFELINK,
float timeout = 1.0);
void handleAck(
const ITransport::Ack& result);
std::vector<crtpPacket_t> m_outgoing_packets;
void startBatchRequest();
void addRequest(
const uint8_t* data,
size_t numBytes,
size_t numBytesToMatch);
template<typename R>
void addRequest(
const R& request,
size_t numBytesToMatch)
{
addRequest(
reinterpret_cast<const uint8_t*>(&request), sizeof(request), numBytesToMatch);
}
void handleRequests(
bool crtpMode = true,
bool useSafeLink = ENABLE_SAFELINK,
float baseTime = 2.0,
float timePerRequest = 0.2);
void handleBatchAck(
const ITransport::Ack& result,
bool crtpMode);
template<typename R>
const R* getRequestResult(size_t index) const {
return reinterpret_cast<const R*>(m_batchRequests[index].ack.data);
}
private:
struct logInfo {
uint8_t len;
uint32_t log_crc;
uint8_t log_max_packet;
uint8_t log_max_ops;
};
/////////
struct paramInfo {
uint8_t len;
uint32_t crc;
};
// enum ParamLength {
// ParamLength1Byte = 0,
// ParamLength2Bytes = 1,
// ParamLength3Bytes = 2,
// ParamLength4Bytes = 3,
// };
// enum ParamType {
// ParamTypeInt = 0,
// ParamTypeFloat = 1,
// };
// enum ParamSign {
// ParamSignSigned = 0,
// ParamSignUnsigned = 1,
// };
// enum ParamGroup {
// ParamGroupVariable = 0,
// ParamGroupGroup = 1,
// };
private:
const LogTocEntry* getLogTocEntry(
const std::string& group,
const std::string& name) const;
uint8_t registerLogBlock(
std::function<void(crtpLogDataResponse*, uint8_t)> cb);
bool unregisterLogBlock(
uint8_t id);
void setParam(uint8_t id, const ParamValue& value);
void addSetParam(uint8_t id, const ParamValue& value);
const ParamValue& getParam(uint8_t id) const {
return m_paramValues.at(id);
}
private:
Crazyradio* m_radio;
ITransport* m_transport;
int m_devId;
uint8_t m_channel;
uint64_t m_address;
Crazyradio::Datarate m_datarate;
std::vector<LogTocEntry> m_logTocEntries;
std::map<uint8_t, std::function<void(crtpLogDataResponse*, uint8_t)> > m_logBlockCb;
std::vector<ParamTocEntry> m_paramTocEntries;
std::map<uint8_t, ParamValue> m_paramValues;
std::vector<MemoryTocEntry> m_memoryTocEntries;
std::function<void(const crtpPlatformRSSIAck*)> m_emptyAckCallback;
std::function<void(float)> m_linkQualityCallback;
std::function<void(const char*)> m_consoleCallback;
std::function<void(const ITransport::Ack&)> m_genericPacketCallback;
template<typename T>
friend class LogBlock;
friend class LogBlockGeneric;
// batch system
struct batchRequest
{
std::vector<uint8_t> request;
size_t numBytesToMatch;
ITransport::Ack ack;
bool finished;
};
std::vector<batchRequest> m_batchRequests;
size_t m_numRequestsFinished;
int m_curr_up;
int m_curr_down;
bool m_log_use_V2;
bool m_param_use_V2;
// logging
Logger& m_logger;
};
template<class T>
class LogBlock
{
public:
LogBlock(
Crazyflie* cf,
std::list<std::pair<std::string, std::string> > variables,
std::function<void(uint32_t, T*)>& callback)
: m_cf(cf)
, m_callback(callback)
, m_id(0)
{
m_id = m_cf->registerLogBlock([=](crtpLogDataResponse* r, uint8_t s) { this->handleData(r, s);});
if (m_cf->m_log_use_V2) {
crtpLogCreateBlockV2Request request;
request.id = m_id;
int i = 0;
for (auto&& pair : variables) {
const Crazyflie::LogTocEntry* entry = m_cf->getLogTocEntry(pair.first, pair.second);
if (entry) {
request.items[i].logType = entry->type;
request.items[i].id = entry->id;
++i;
}
else {
std::stringstream sstr;
sstr << "Could not find " << pair.first << "." << pair.second << " in log toc!";
throw std::runtime_error(sstr.str());
}
}
m_cf->startBatchRequest();
m_cf->addRequest(reinterpret_cast<const uint8_t*>(&request), 3 + 3*i, 2);
m_cf->handleRequests();
auto r = m_cf->getRequestResult<crtpLogControlResponse>(0);
if (r->result != crtpLogControlResultOk
&& r->result != crtpLogControlResultBlockExists) {
std::stringstream sstr;
sstr << "Could not create log block! Result: " << (int)r->result << " " << (int)m_id << " " << (int)r->requestByte1 << " " << (int)r->command;
throw std::runtime_error(sstr.str());
}
} else {
crtpLogCreateBlockRequest request;
request.id = m_id;
int i = 0;
for (auto&& pair : variables) {
const Crazyflie::LogTocEntry* entry = m_cf->getLogTocEntry(pair.first, pair.second);
if (entry) {
request.items[i].logType = entry->type;
request.items[i].id = entry->id;
++i;
}
else {
std::stringstream sstr;
sstr << "Could not find " << pair.first << "." << pair.second << " in log toc!";
throw std::runtime_error(sstr.str());
}
}
m_cf->startBatchRequest();
m_cf->addRequest(reinterpret_cast<const uint8_t*>(&request), 3 + 2*i, 2);
m_cf->handleRequests();
auto r = m_cf->getRequestResult<crtpLogControlResponse>(0);
if (r->result != crtpLogControlResultOk
&& r->result != crtpLogControlResultBlockExists) {
std::stringstream sstr;
sstr << "Could not create log block! Result: " << (int)r->result << " " << (int)m_id << " " << (int)r->requestByte1 << " " << (int)r->command;
throw std::runtime_error(sstr.str());
}
}
}
~LogBlock()
{
stop();
m_cf->unregisterLogBlock(m_id);
}
void start(uint8_t period)
{
crtpLogStartRequest request(m_id, period);
m_cf->startBatchRequest();
m_cf->addRequest(request, 2);
m_cf->handleRequests();
}
void stop()
{
crtpLogStopRequest request(m_id);
m_cf->startBatchRequest();
m_cf->addRequest(request, 2);
m_cf->handleRequests();
}
private:
void handleData(crtpLogDataResponse* response, uint8_t size) {
if (size == sizeof(T)) {
uint32_t time_in_ms = ((uint32_t)response->timestampHi << 8) | (response->timestampLo);
T* t = (T*)response->data;
m_callback(time_in_ms, t);
}
else {
std::stringstream sstr;
sstr << "Size doesn't match! Is: " << (size_t)size << " expected: " << sizeof(T);
throw std::runtime_error(sstr.str());
}
}
private:
Crazyflie* m_cf;
std::function<void(uint32_t, T*)> m_callback;
uint8_t m_id;
};
///
class LogBlockGeneric
{
public:
LogBlockGeneric(
Crazyflie* cf,
const std::vector<std::string>& variables,
void* userData,
std::function<void(uint32_t, std::vector<double>*, void* userData)>& callback)
: m_cf(cf)
, m_userData(userData)
, m_callback(callback)
, m_id(0)
{
m_id = m_cf->registerLogBlock([=](crtpLogDataResponse* r, uint8_t s) { this->handleData(r, s);});
if (m_cf->m_log_use_V2) {
crtpLogCreateBlockV2Request request;
request.id = m_id;
int i = 0;
size_t s = 0;
for (auto&& var : variables) {
auto pos = var.find(".");
std::string first = var.substr(0, pos);
std::string second = var.substr(pos+1);
const Crazyflie::LogTocEntry* entry = m_cf->getLogTocEntry(first, second);
if (entry) {
s += Crazyflie::size(entry->type);
if (s > 26) {
std::stringstream sstr;
sstr << "Can't configure that many variables in a single log block!"
<< " Ignoring " << first << "." << second << std::endl;
throw std::runtime_error(sstr.str());
} else {
request.items[i].logType = entry->type;
request.items[i].id = entry->id;
++i;
m_types.push_back(entry->type);
}
}
else {
std::stringstream sstr;
sstr << "Could not find " << first << "." << second << " in log toc!";
throw std::runtime_error(sstr.str());
}
}
m_cf->startBatchRequest();
m_cf->addRequest(reinterpret_cast<const uint8_t*>(&request), 3 + 3*i, 2);
m_cf->handleRequests();
auto r = m_cf->getRequestResult<crtpLogControlResponse>(0);
if (r->result != crtpLogControlResultOk
&& r->result != crtpLogControlResultBlockExists) {
throw std::runtime_error("Could not create log block!");
}
} else {
crtpLogCreateBlockRequest request;
request.id = m_id;
int i = 0;
size_t s = 0;
for (auto&& var : variables) {
auto pos = var.find(".");
std::string first = var.substr(0, pos);
std::string second = var.substr(pos+1);
const Crazyflie::LogTocEntry* entry = m_cf->getLogTocEntry(first, second);
if (entry) {
s += Crazyflie::size(entry->type);
if (s > 26) {
std::stringstream sstr;
sstr << "Can't configure that many variables in a single log block!"
<< " Ignoring " << first << "." << second << std::endl;
throw std::runtime_error(sstr.str());
} else {
request.items[i].logType = entry->type;
request.items[i].id = entry->id;
++i;
m_types.push_back(entry->type);
}
}
else {
std::stringstream sstr;
sstr << "Could not find " << first << "." << second << " in log toc!";
throw std::runtime_error(sstr.str());
}
}
m_cf->startBatchRequest();
m_cf->addRequest(reinterpret_cast<const uint8_t*>(&request), 3 + 2*i, 2);
m_cf->handleRequests();
auto r = m_cf->getRequestResult<crtpLogControlResponse>(0);
if (r->result != crtpLogControlResultOk
&& r->result != crtpLogControlResultBlockExists) {
throw std::runtime_error("Could not create log block!");
}
}
}
~LogBlockGeneric()
{
stop();
m_cf->unregisterLogBlock(m_id);
}
void start(uint8_t period)
{
crtpLogStartRequest request(m_id, period);
m_cf->startBatchRequest();
m_cf->addRequest(request, 2);
m_cf->handleRequests();
}
void stop()
{
crtpLogStopRequest request(m_id);
m_cf->startBatchRequest();
m_cf->addRequest(request, 2);
m_cf->handleRequests();
}
private:
void handleData(crtpLogDataResponse* response, uint8_t /*size*/) {
std::vector<double> result;
size_t pos = 0;
for (size_t i = 0; i < m_types.size(); ++i)
{
switch (m_types[i])
{
case Crazyflie::LogTypeUint8:
{
uint8_t value;
memcpy(&value, &response->data[pos], sizeof(uint8_t));
result.push_back(value);
pos += sizeof(uint8_t);
break;
}
case Crazyflie::LogTypeInt8:
{
int8_t value;
memcpy(&value, &response->data[pos], sizeof(int8_t));
result.push_back(value);
pos += sizeof(int8_t);
break;
}
case Crazyflie::LogTypeUint16:
{
uint16_t value;
memcpy(&value, &response->data[pos], sizeof(uint16_t));
result.push_back(value);
pos += sizeof(uint16_t);
break;
}
case Crazyflie::LogTypeInt16:
{
int16_t value;
memcpy(&value, &response->data[pos], sizeof(int16_t));
result.push_back(value);
pos += sizeof(int16_t);
break;
}
case Crazyflie::LogTypeUint32:
{
uint32_t value;
memcpy(&value, &response->data[pos], sizeof(uint32_t));
result.push_back(value);
pos += sizeof(uint32_t);
break;
}
case Crazyflie::LogTypeInt32:
{
int32_t value;
memcpy(&value, &response->data[pos], sizeof(int32_t));
result.push_back(value);
pos += sizeof(int32_t);
break;
}
case Crazyflie::LogTypeFloat:
{
float value;
memcpy(&value, &response->data[pos], sizeof(float));
result.push_back(value);
pos += sizeof(float);
break;
}
case Crazyflie::LogTypeFP16:
{
double value;
memcpy(&value, &response->data[pos], sizeof(double));
result.push_back(value);
pos += sizeof(double);
break;
}
}
}
uint32_t time_in_ms = ((uint32_t)response->timestampHi << 8) | (response->timestampLo);
m_callback(time_in_ms, &result, m_userData);
}
private:
Crazyflie* m_cf;
void* m_userData;
std::function<void(uint32_t, std::vector<double>*, void*)> m_callback;
uint8_t m_id;
std::vector<Crazyflie::LogType> m_types;
};
///
class CrazyflieBroadcaster
{
public:
CrazyflieBroadcaster(
const std::string& link_uri);
// High-Level setpoints
void takeoff(float height, float duration, uint8_t groupMask = 0);
void land(float height, float duration, uint8_t groupMask = 0);
void stop(uint8_t groupMask = 0);
// This is always in relative coordinates
void goTo(float x, float y, float z, float yaw, float duration, uint8_t groupMask = 0);
// This is always in relative coordinates
void startTrajectory(
uint8_t trajectoryId,
float timescale = 1.0,
bool reversed = false,
uint8_t groupMask = 0);
struct externalPosition
{
uint8_t id;
float x;
float y;
float z;
};
void sendExternalPositions(
const std::vector<externalPosition>& data);
struct externalPose
{
uint8_t id;
float x;
float y;
float z;
float qx;
float qy;
float qz;
float qw;
};
// Crazyswarm experimental
void sendExternalPoses(
const std::vector<externalPose>& data);
// // Parameter support
// template<class T>
// void setParam(
// uint8_t group,
// uint8_t id,
// Crazyflie::ParamType type,
// const T& value)
// {
// Crazyflie::ParamValue v;
// memcpy(&v, &value, sizeof(value));
// setParam(group, id, type, v);
// }
protected:
void sendPacket(
const uint8_t* data,
uint32_t length);
void send2Packets(
const uint8_t* data,
uint32_t length);
// void setParam(
// uint8_t group,
// uint8_t id,
// Crazyflie::ParamType type,
// const Crazyflie::ParamValue& value);
private:
Crazyradio* m_radio;
int m_devId;
uint8_t m_channel;
uint64_t m_address;
Crazyradio::Datarate m_datarate;
};