crtp.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Crazyradio.h"
4 #include <cstdint>
5 
6 static int const CRTP_MAX_DATA_SIZE = 30;
7 static int const CRTP_MAXSIZE = 31;
8 #define CHECKSIZE(s) static_assert(sizeof(s) <= CRTP_MAXSIZE, #s " packet is too large");
9 #define CHECKSIZE_WITH_STATE(s, stateSize) static_assert(sizeof(s) - stateSize <= CRTP_MAXSIZE, #s " packet is too large");
10 
11 static int const CRTP_MAXSIZE_RESPONSE = 32;
12 #define CHECKSIZE_RESPONSE(s) static_assert(sizeof(s) <= CRTP_MAXSIZE_RESPONSE, #s " packet is too large");
13 
14 void quatdecompress(uint32_t comp, float q[4]);
15 
16 // Header
17 struct crtp
18 {
19  constexpr crtp(uint8_t port, uint8_t channel)
20  : channel(channel)
21  , link(3)
23  {
24  }
25 
26  crtp(uint8_t byte)
27  {
28  channel = (byte >> 0) & 0x3;
29  link = (byte >> 2) & 0x3;
30  port = (byte >> 4) & 0xF;
31  }
32 
33  bool operator==(const crtp& other) const {
34  return channel == other.channel && port == other.port;
35  }
36 
37  uint8_t channel:2;
38  uint8_t link:2;
39  uint8_t port:4;
40 } __attribute__((packed));
41 
42 // Packet structure definition
43 typedef struct {
44  uint8_t size;
45  union {
46  struct {
47  uint8_t header;
48  uint8_t data[CRTP_MAX_DATA_SIZE];
49  };
50  uint8_t raw[CRTP_MAX_DATA_SIZE+1];
51  };
52 } crtpPacket_t;
53 
54 struct crtpEmpty
55 {
56  const uint8_t cmd = 0xFF;
57 };
58 
59 // Port 0 (Console)
61 {
62  static bool match(const Crazyradio::Ack& response) {
63  return crtp(response.data[0]) == crtp(0, 0);
64  }
65 
66  crtp header;
67  char text[31];
68 };
70 
71 // Port 2 (Parameters)
72 
73 enum ParamType : uint8_t
74 {
75  ParamTypeUint8 = 0x00 | (0x00<<2) | (0x01<<3),
76  ParamTypeInt8 = 0x00 | (0x00<<2) | (0x00<<3),
77  ParamTypeUint16 = 0x01 | (0x00<<2) | (0x01<<3),
78  ParamTypeInt16 = 0x01 | (0x00<<2) | (0x00<<3),
79  ParamTypeUint32 = 0x02 | (0x00<<2) | (0x01<<3),
80  ParamTypeInt32 = 0x02 | (0x00<<2) | (0x00<<3),
81  ParamTypeFloat = 0x02 | (0x01<<2) | (0x00<<3),
82 };
83 
86 {
88  uint8_t id)
89  : header(2, 0)
90  , command(0)
91  , id(id)
92  {
93  }
94 
95  bool operator==(const crtpParamTocGetItemRequest& other) const {
96  return header == other.header && command == other.command && id == other.id;
97  }
98 
100 
101  const crtp header;
102  const uint8_t command;
103  uint8_t id;
104 } __attribute__((packed));
106 
108 {
109  static bool match(const Crazyradio::Ack& response) {
110  return response.size > 5 &&
111  crtp(response.data[0]) == crtp(2, 0) &&
112  response.data[1] == 0;
113  }
114 
116  uint8_t length:2; // one of ParamLength
117  uint8_t type:1; // one of ParamType
118  uint8_t sign:1; // one of ParamSign
119  uint8_t res0:2; // reserved
120  uint8_t readonly:1;
121  uint8_t group:1; // one of ParamGroup
122  char text[28]; // group, name
123 } __attribute__((packed));
125 
128 {
130  : header(2, 0)
131  , command(1)
132  {
133  }
134 
135  bool operator==(const crtpParamTocGetInfoRequest& other) const {
136  return header == other.header && command == other.command;
137  }
138 
139  typedef crtpParamTocGetInfoResponse Response;
140 
141  const crtp header;
142  const uint8_t command;
143 } __attribute__((packed));
145 
147 {
148  static bool match(const Crazyradio::Ack& response) {
149  return response.size == 7 &&
150  crtp(response.data[0]) == crtp(2, 0) &&
151  response.data[1] == 1;
152  }
153 
155  uint8_t numParam;
156  uint32_t crc;
157 } __attribute__((packed));
159 
160 struct crtpParamValueResponse;
162 {
164  uint8_t id)
165  : header(2, 1)
166  , id(id)
167  {
168  }
169 
170  bool operator==(const crtpParamReadRequest& other) const {
171  return header == other.header && id == other.id;
172  }
173 
174  typedef crtpParamValueResponse Response;
175 
176  const crtp header;
177  const uint8_t id;
178 } __attribute__((packed));
180 
181 template <class T>
183 {
185  uint8_t id,
186  const T& value)
187  : header(2, 2)
188  , id(id)
189  , value(value)
190  {
191  }
192 
193  const crtp header;
194  const uint8_t id;
195  const T value;
196 } __attribute__((packed));
197 CHECKSIZE(crtpParamWriteRequest<double>) // largest kind of param
198 
199 struct crtpParamValueResponse
200 {
201  static bool match(const Crazyradio::Ack& response) {
202  return response.size > 2 &&
203  (crtp(response.data[0]) == crtp(2, 1) ||
204  crtp(response.data[0]) == crtp(2, 2));
205  }
206 
208  union {
209  uint8_t valueUint8;
210  int8_t valueInt8;
211  uint16_t valueUint16;
212  int16_t valueInt16;
213  uint32_t valueUint32;
214  int32_t valueInt32;
215  float valueFloat;
216  };
217 } __attribute__((packed));
218 CHECKSIZE_RESPONSE(crtpParamValueResponse)
219 
220 // V2
223 {
225  uint16_t id)
226  : header(2, 0)
227  , command(2)
228  , id(id)
229  {
230  }
232  bool operator==(const crtpParamTocGetItemV2Request& other) const {
233  return header == other.header && command == other.command && id == other.id;
234  }
235 
237 
238  const crtp header;
239  const uint8_t command;
240  uint16_t id;
241 } __attribute__((packed));
243 
245 {
246  static bool match(const Crazyradio::Ack& response) {
247  return response.size > 5 &&
248  crtp(response.data[0]) == crtp(2, 0) &&
249  response.data[1] == 2;
250  }
251 
253  uint8_t length:2; // one of ParamLength
254  uint8_t type:1; // one of ParamType
255  uint8_t sign:1; // one of ParamSign
256  uint8_t res0:2; // reserved
257  uint8_t readonly:1;
258  uint8_t group:1; // one of ParamGroup
259  char text[27]; // group, name
260 } __attribute__((packed));
262 
265 {
267  : header(2, 0)
268  , command(3)
269  {
270  }
271 
272  bool operator==(const crtpParamTocGetInfoV2Request& other) const {
273  return header == other.header && command == other.command;
274  }
275 
277 
278  const crtp header;
279  const uint8_t command;
280 } __attribute__((packed));
282 
284 {
285  static bool match(const Crazyradio::Ack& response) {
286  return response.size == 8 &&
287  crtp(response.data[0]) == crtp(2, 0) &&
288  response.data[1] == 3;
289  }
290 
292  uint16_t numParam;
293  uint32_t crc;
294 } __attribute__((packed));
296 
297 struct crtpParamValueV2Response;
299 {
301  uint16_t id)
302  : header(2, 1)
303  , id(id)
304  {
305  }
306 
307  bool operator==(const crtpParamReadV2Request& other) const {
308  return header == other.header && id == other.id;
309  }
310 
311  typedef crtpParamValueV2Response Response;
312 
313  const crtp header;
314  const uint16_t id;
315 } __attribute__((packed));
317 
318 template <class T>
320 {
322  uint16_t id,
323  const T& value)
324  : header(2, 2)
325  , id(id)
326  , value(value)
327  {
328  }
329 
330  const crtp header;
331  const uint16_t id;
332  const T value;
333 } __attribute__((packed));
334 CHECKSIZE(crtpParamWriteV2Request<float>) // largest kind of param
335 
336 struct crtpParamValueV2Response
337 {
338  static bool match(const Crazyradio::Ack& response) {
339  return response.size > 2 &&
340  (crtp(response.data[0]) == crtp(2, 1) ||
341  crtp(response.data[0]) == crtp(2, 2));
342  }
343 
345  uint8_t status; // 0 = success
346  union {
347  uint8_t valueUint8;
348  int8_t valueInt8;
349  uint16_t valueUint16;
350  int16_t valueInt16;
351  uint32_t valueUint32;
352  int32_t valueInt32;
353  float valueFloat;
354  };
355 } __attribute__((packed));
356 CHECKSIZE_RESPONSE(crtpParamValueV2Response)
357 
358 template <class T>
360 {
362  const char* group,
363  const char* name,
364  const T& value);
366  const crtp header;
367  const uint8_t cmd = 0;
368  uint8_t data[29];
370  uint8_t size() const {
371  return size_;
372  }
373 
374  uint8_t responseSize() const {
376  }
377 
378 private:
379  // member state (not part of packet)
380  uint8_t size_;
381  uint8_t responseSize_;
382 
383 private:
385  const char* group,
386  const char* name,
387  uint8_t paramType,
388  const void* value,
389  uint8_t valueSize);
390 } __attribute__((packed));
392 
393 struct crtpParamSetByNameResponse
394 {
395  static bool match(const Crazyradio::Ack& response) {
396  return response.size > 2 &&
397  (crtp(response.data[0]) == crtp(2, 3));
398  }
399 
400  uint8_t data[32];
401 
402  uint8_t error(uint8_t responseSize) const {
403  return data[responseSize];
404  }
405 
406 } __attribute__((packed));
407 CHECKSIZE_RESPONSE(crtpParamSetByNameResponse) // largest kind of param
408 
409 
410 // Port 3 (Commander)
411 
412 struct crtpSetpointRequest
413 {
414  crtpSetpointRequest(
415  float roll,
416  float pitch,
417  float yawrate,
418  uint16_t thrust)
419  : header(0x03, 0)
420  , roll(roll)
421  , pitch(pitch)
422  , yawrate(yawrate)
423  , thrust(thrust)
424  {
425  }
426  const crtp header;
427  float roll;
428  float pitch;
429  float yawrate;
430  uint16_t thrust;
431 } __attribute__((packed));
432 CHECKSIZE(crtpSetpointRequest)
433 
434 // Port 4 (Memory access)
435 
437 {
439  : header(0x04, 0)
440  , command(1)
441  {
442  }
443  const crtp header;
444  const uint8_t command;
445 } __attribute__((packed));
449 {
450  static bool match(const Crazyradio::Ack& response) {
451  return response.size == 3 &&
452  crtp(response.data[0]) == crtp(4, 0) &&
453  response.data[1] == 1;
454  }
458 } __attribute__((packed));
460 
462 {
464  uint8_t memId)
465  : header(0x04, 0)
466  , command(2)
467  , memId(memId)
468  {
469  }
470  const crtp header;
471  const uint8_t command;
472  uint8_t memId;
473 } __attribute__((packed));
475 
476 enum crtpMemoryType : uint8_t
477 {
478  EEPROM = 0x00,
479  OW = 0x01,
480  LED12 = 0x10,
481  LOCO = 0x11,
482 };
483 
485 {
486  static bool match(const Crazyradio::Ack& response) {
487  return response.size > 2 &&
488  crtp(response.data[0]) == crtp(4, 0) &&
489  response.data[1] == 2;
490  }
491 
494  uint32_t memSize; // Bytes
495  uint64_t memAddr; // valid for OW and EEPROM
496 } __attribute__((packed));
498 
500 {
502  uint8_t memId,
503  uint32_t memAddr,
504  uint8_t length)
505  : header(0x04, 1)
506  , memId(memId)
507  , memAddr(memAddr)
508  , length(length)
509  {
510  }
511  const crtp header;
512  uint8_t memId;
513  uint32_t memAddr;
514  uint8_t length;
515 } __attribute__((packed));
517 
519 {
520  static bool match(const Crazyradio::Ack& response) {
521  return response.size > 2 &&
522  crtp(response.data[0]) == crtp(4, 1);
523  }
524 
525  crtp header;
526  uint8_t memId;
527  uint32_t memAddr;
528  uint8_t status;
529  uint8_t data[24];
530 } __attribute__((packed));
532 
534 {
536  uint8_t memId,
537  uint32_t memAddr)
538  : header(0x04, 2)
539  , memId(memId)
540  , memAddr(memAddr)
541  {
542  }
543  const crtp header;
544  uint8_t memId;
545  uint32_t memAddr;
546  uint8_t data[24];
547 } __attribute__((packed));
549 
551 {
552  static bool match(const Crazyradio::Ack& response) {
553  return response.size > 2 &&
554  crtp(response.data[0]) == crtp(4, 2);
555  }
556 
557  crtp header;
558  uint8_t memId;
559  uint32_t memAddr;
560  uint8_t status;
561 } __attribute__((packed));
563 
564 // Port 5 (Data logging)
565 
568 {
570  : header(5, 0)
571  , command(1)
572  {
573  }
574 
575  bool operator==(const crtpLogGetInfoRequest& other) const {
576  return header == other.header && command == other.command;
577  }
578 
580 
581  const crtp header;
582  const uint8_t command;
583 } __attribute__((packed));
585 
587 {
588  static bool match(const Crazyradio::Ack& response) {
589  return response.size == 9 &&
590  crtp(response.data[0]) == crtp(5, 0) &&
591  response.data[1] == 1;
592  }
593 
595  // Number of log items contained in the log table of content
596  uint8_t log_len;
597  // CRC values of the log TOC memory content. This is a fingerprint of the copter build that can be used to cache the TOC
598  uint32_t log_crc;
599  // Maximum number of log packets that can be programmed in the copter
600  uint8_t log_max_packet;
601  // Maximum number of operation programmable in the copter. An operation is one log variable retrieval programming
602  uint8_t log_max_ops;
603 } __attribute__((packed));
605 
608 {
609  crtpLogGetItemRequest(uint8_t id)
610  : header(5, 0)
611  , command(0)
612  , id(id)
613  {
614  }
615 
616  bool operator==(const crtpLogGetItemRequest& other) const {
617  return header == other.header && command == other.command && id == other.id;
618  }
619 
621 
622  const crtp header;
623  const uint8_t command;
624  uint8_t id;
625 } __attribute__((packed));
627 
629 {
630  static bool match(const Crazyradio::Ack& response) {
631  return response.size > 5 &&
632  crtp(response.data[0]) == crtp(5, 0) &&
633  response.data[1] == 0;
634  }
635 
637  uint8_t type;
638  char text[28]; // group, name
639 } __attribute__((packed));
641 
642 struct logBlockItem {
643  uint8_t logType;
644  uint8_t id;
645 } __attribute__((packed));
646 
648 {
650  : header(5, 1)
651  , command(0)
652  {
653  }
654 
655  const crtp header;
656  const uint8_t command;
657  uint8_t id;
658  logBlockItem items[14];
659 } __attribute__((packed));
661 
662 // struct logAppendBlockRequest
663 // {
664 // logAppendBlockRequest()
665 // : header(5, 1)
666 // , command(1)
667 // {
668 // }
669 
670 // const crtp header;
671 // const uint8_t command;
672 // uint8_t id;
673 // logBlockItem items[16];
674 // } __attribute__((packed));
675 
676 // struct logDeleteBlockRequest
677 // {
678 // logDeleteBlockRequest()
679 // : header(5, 1)
680 // , command(2)
681 // {
682 // }
683 
684 // const crtp header;
685 // const uint8_t command;
686 // uint8_t id;
687 // } __attribute__((packed));
688 
689 struct crtpLogStartRequest
690 {
692  uint8_t id,
693  uint8_t period)
694  : header(5, 1)
695  , command(3)
696  , id(id)
697  , period(period)
698  {
699  }
700 
701  const crtp header;
702  const uint8_t command;
703  uint8_t id;
704  uint8_t period; // in increments of 10ms
705 } __attribute__((packed));
707 
708 struct crtpLogStopRequest
709 {
711  uint8_t id)
712  : header(5, 1)
713  , command(4)
714  , id(id)
715  {
716  }
717 
718  const crtp header;
719  const uint8_t command;
720  uint8_t id;
721 } __attribute__((packed));
723 
724 struct crtpLogResetRequest
725 {
727  : header(5, 1)
728  , command(5)
729  {
730  }
731 
732  const crtp header;
733  const uint8_t command;
734 } __attribute__((packed));
736 
744 
745 };
746 
748 {
749  static bool match(const Crazyradio::Ack& response) {
750  return response.size == 4 &&
751  crtp(response.data[0]) == crtp(5, 1);
752  }
753 
754  crtp header;
755  uint8_t command;
756  uint8_t requestByte1;
757  uint8_t result; // one of crtpLogControlResult
758 } __attribute__((packed));
760 
761 struct crtpLogDataResponse
762 {
763  static bool match(const Crazyradio::Ack& response) {
764  return response.size > 4 &&
765  crtp(response.data[0]) == crtp(5, 2);
766  }
767 
768  crtp header;
769  uint8_t blockId;
770  uint8_t timestampLo;
771  uint16_t timestampHi;
772  uint8_t data[26];
773 } __attribute__((packed));
775 
776 // V2
779 {
781  : header(5, 0)
782  , command(3)
783  {
784  }
785 
786  bool operator==(const crtpLogGetInfoV2Request& other) const {
787  return header == other.header && command == other.command;
788  }
789 
791 
792  const crtp header;
793  const uint8_t command;
794 } __attribute__((packed));
796 
798 {
799  static bool match(const Crazyradio::Ack& response) {
800  return response.size == 10 &&
801  crtp(response.data[0]) == crtp(5, 0) &&
802  response.data[1] == 3;
803  }
804 
806  // Number of log items contained in the log table of content
807  uint16_t log_len;
808  // CRC values of the log TOC memory content. This is a fingerprint of the copter build that can be used to cache the TOC
809  uint32_t log_crc;
810  // Maximum number of log packets that can be programmed in the copter
811  uint8_t log_max_packet;
812  // Maximum number of operation programmable in the copter. An operation is one log variable retrieval programming
813  uint8_t log_max_ops;
814 } __attribute__((packed));
816 
819 {
820  crtpLogGetItemV2Request(uint16_t id)
821  : header(5, 0)
822  , command(2)
823  , id(id)
824  {
825  }
826 
827  bool operator==(const crtpLogGetItemV2Request& other) const {
828  return header == other.header && command == other.command && id == other.id;
829  }
830 
832 
833  const crtp header;
834  const uint8_t command;
835  uint16_t id;
836 } __attribute__((packed));
838 
840 {
841  static bool match(const Crazyradio::Ack& response) {
842  return response.size > 6 &&
843  crtp(response.data[0]) == crtp(5, 0) &&
844  response.data[1] == 2;
845  }
846 
848  uint8_t type;
849  char text[27]; // group, name
850 } __attribute__((packed));
852 
853 struct logBlockItemV2 {
854  uint8_t logType;
855  uint16_t id;
856 } __attribute__((packed));
857 
859 {
861  : header(5, 1)
862  , command(6)
863  {
864  }
865 
866  const crtp header;
867  const uint8_t command;
868  uint8_t id;
870 } __attribute__((packed));
872 
874 {
876  : header(5, 1)
877  , command(7)
878  {
879  }
880 
881  const crtp header;
882  const uint8_t command;
883  uint8_t id;
885 } __attribute__((packed));
887 
888 // Port 0x06 (External Position Update)
889 
891 {
893  float x,
894  float y,
895  float z)
896  : header(0x06, 0)
897  , x(x)
898  , y(y)
899  , z(z)
900  {
901  }
902  const crtp header;
903  float x;
904  float y;
905  float z;
906 } __attribute__((packed));
908 
910 {
912  : header(0x06, 2)
913  {
914  }
915  const crtp header;
916  struct {
917  uint8_t id;
918  int16_t x; // mm
919  int16_t y; // mm
920  int16_t z; // mm
921  } __attribute__((packed)) positions[4];
922 } __attribute__((packed));
924 
926 {
928  : header(0x06, 1)
929  {
930  }
931  const crtp header;
932  const uint8_t type = 3;
933 } __attribute__((packed));
935 
937 {
939  : header(0x06, 1)
940  {
941  }
942  const crtp header;
943  const uint8_t type = 4;
944 } __attribute__((packed));
946 
948 {
950  float x,
951  float y,
952  float z,
953  float qx,
954  float qy,
955  float qz,
956  float qw)
957  : header(0x06, 1)
958  , x(x)
959  , y(y)
960  , z(z)
961  , qx(qx)
962  , qy(qy)
963  , qz(qz)
964  , qw(qw)
965  {
966  }
967  const crtp header;
968  const uint8_t type = 8;
969  float x;
970  float y;
971  float z;
972  float qx;
973  float qy;
974  float qz;
975  float qw;
976 } __attribute__((packed));
978 
980 {
982  : header(0x06, 1)
983  {
984  }
985  const crtp header;
986  const uint8_t type = 9;
987  struct {
988  uint8_t id; // last 8 bit of the Crazyflie address
989  int16_t x; // mm
990  int16_t y; // mm
991  int16_t z; // mm
992  uint32_t quat; // compressed quaternion, see quatcompress.h
993  } __attribute__((packed)) poses[2];
994 } __attribute__((packed));
996 
997 struct crtpStopRequest
998 {
999  crtpStopRequest();
1000  const crtp header;
1001  uint8_t type;
1002 } __attribute__((packed));
1004 
1006 {
1008  float vx,
1009  float vy,
1010  float yawrate,
1011  float zDistance);
1012  const crtp header;
1013  uint8_t type;
1014  float vx;
1015  float vy;
1016  float yawrate;
1017  float zDistance;
1018 } __attribute__((packed));
1020 
1022 {
1024  float x,
1025  float y,
1026  float z,
1027  float yaw);
1028  const crtp header;
1029  uint8_t type;
1030  float x;
1031  float y;
1032  float z;
1033  float yaw;
1034 } __attribute__((packed));
1036 
1037 // Port 0x07 (Generic Setpoint)
1038 
1040 {
1042  float x, float y, float z,
1043  float vx, float vy, float vz,
1044  float ax, float ay, float az,
1045  float qx, float qy, float qz, float qw,
1046  float rollRate, float pitchRate, float yawRate);
1047  const crtp header;
1048  uint8_t type;
1049  int16_t x;
1050  int16_t y;
1051  int16_t z;
1052  int16_t vx;
1053  int16_t vy;
1054  int16_t vz;
1055  int16_t ax;
1056  int16_t ay;
1057  int16_t az;
1058  int32_t quat; // compressed quaternion, xyzw
1059  int16_t omegax;
1060  int16_t omegay;
1061  int16_t omegaz;
1062 } __attribute__((packed));
1064 
1066 {
1068  float x, float y, float z, float yawRate)
1069  : header(0X07, 0), type(1), x(x), y(y), z(z), yawRate(yawRate)
1070  {
1071  }
1072  const crtp header;
1073  uint8_t type;
1074  float x;
1075  float y;
1076  float z;
1077  float yawRate;
1078 }__attribute__((packed));
1082 {
1084  : header(0x07, 1), type(0), remainValidMillisecs(remainValidMillisecs)
1085  {
1086  }
1087  const crtp header;
1088  uint8_t type;
1089  uint32_t remainValidMillisecs;
1090 }__attribute__((packed));
1093 // Port 0x08 (High-level Setpoints)
1096 {
1098  uint8_t groupMask)
1099  : header(0x08, 0)
1100  , command(0)
1101  , groupMask(groupMask)
1102  {
1103  }
1104 
1105  const crtp header;
1106  const uint8_t command;
1107  uint8_t groupMask;
1108 } __attribute__((packed));
1110 
1114  uint8_t groupMask,
1115  float height,
1116  float duration)
1117  : header(0x08, 0)
1118  , command(1)
1119  , groupMask(groupMask)
1120  , height(height)
1121  , duration(duration)
1122  {
1123  }
1124 
1125  const crtp header;
1126  const uint8_t command;
1127  uint8_t groupMask; // mask for which CFs this should apply to
1128  float height; // m (absolute)
1129  float duration; // s (time it should take until target height is reached)
1130 } __attribute__((packed));
1132 
1134 {
1136  uint8_t groupMask,
1137  float height,
1138  float duration)
1139  : header(0x08, 0)
1140  , command(2)
1141  , groupMask(groupMask)
1142  , height(height)
1143  , duration(duration)
1144  {
1145  }
1146 
1147  const crtp header;
1148  const uint8_t command;
1149  uint8_t groupMask; // mask for which CFs this should apply to
1150  float height; // m (absolute)
1151  float duration; // s (time it should take until target height is reached)
1152 } __attribute__((packed));
1154 
1156 {
1158  uint8_t groupMask)
1159  : header(0x08, 0)
1160  , command(3)
1161  , groupMask(groupMask)
1162  {
1163  }
1164 
1165  const crtp header;
1166  const uint8_t command;
1167  uint8_t groupMask; // mask for which CFs this should apply to
1168 } __attribute__((packed));
1170 
1172 {
1174  uint8_t groupMask,
1175  bool relative,
1176  float x,
1177  float y,
1178  float z,
1179  float yaw,
1180  float duration)
1181  : header(0x08, 0)
1182  , command(4)
1183  , groupMask(groupMask)
1184  , relative(relative)
1185  , x(x)
1186  , y(y)
1187  , z(z)
1188  , yaw(yaw)
1189  , duration(duration)
1190  {
1191  }
1192 
1193  const crtp header;
1194  const uint8_t command;
1195  uint8_t groupMask; // mask for which CFs this should apply to
1196  uint8_t relative; // set to true, if position/yaw are relative to current setpoint
1197  float x; // m
1198  float y; // m
1199  float z; // m
1200  float yaw; // deg
1201  float duration; // sec
1202 } __attribute__((packed));
1204 
1206 {
1208  uint8_t groupMask,
1209  bool relative,
1210  bool reversed,
1211  uint8_t trajectoryId,
1212  float timescale)
1213  : header(0x08, 0)
1214  , command(5)
1215  , groupMask(groupMask)
1216  , relative(relative)
1217  , reversed(reversed)
1218  , trajectoryId(trajectoryId)
1219  , timescale(timescale)
1220  {
1221  }
1222 
1223  const crtp header;
1224  const uint8_t command;
1225  uint8_t groupMask; // mask for which CFs this should apply to
1226  uint8_t relative; // set to true, if trajectory should be shifted to current setpoint
1227  uint8_t reversed; // set to true, if trajectory should be executed in reverse
1228  uint8_t trajectoryId; // id of the trajectory (previously defined by COMMAND_DEFINE_TRAJECTORY)
1229  float timescale; // time factor; 1 = original speed; >1: slower; <1: faster
1230 } __attribute__((packed));
1232 
1235  TRAJECTORY_LOCATION_MEM = 1, // for trajectories that are uploaded dynamically
1236  // Future features might include trajectories on flash or uSD card
1237 };
1238 
1240  TRAJECTORY_TYPE_POLY4D = 0, // struct poly4d, see pptraj.h
1241  // Future types might include versions without yaw
1242 };
1243 
1244 struct trajectoryDescription
1245 {
1246  uint8_t trajectoryLocation; // one of TrajectoryLocation_e
1247  uint8_t trajectoryType; // one of TrajectoryType_e
1248  union
1249  {
1250  struct {
1251  uint32_t offset; // offset in uploaded memory
1252  uint8_t n_pieces;
1253  } __attribute__((packed)) mem; // if trajectoryLocation is TRAJECTORY_LOCATION_MEM
1255 } __attribute__((packed));
1256 
1258 {
1260  uint8_t trajectoryId)
1261  : header(0x08, 0)
1262  , command(6)
1263  , trajectoryId(trajectoryId)
1264  {
1265  }
1266 
1267  const crtp header;
1268  const uint8_t command;
1269  uint8_t trajectoryId;
1270  struct trajectoryDescription description;
1271 } __attribute__((packed));
1273 
1274 // Port 13 (Platform)
1275 
1277 {
1279  : header(0x0D, 1)
1280  {
1281  }
1282 
1283  const crtp header;
1284  const uint8_t cmd = 0;
1285 } __attribute__((packed));
1287 
1289 {
1291  int version;
1292 } __attribute__((packed));
1294 
1296 {
1298  : header(0x0D, 1)
1299  {
1300  }
1301 
1302  const crtp header;
1303  const uint8_t cmd = 1;
1304 } __attribute__((packed));
1306 
1308 {
1310  char version[30];
1311 } __attribute__((packed));
1313 
1315 {
1317  : header(0x0D, 1)
1318  {
1319  }
1320 
1321  const crtp header;
1322  const uint8_t cmd = 2;
1323 } __attribute__((packed));
1325 
1327 {
1329  char name[30];
1330 } __attribute__((packed));
1332 
1333 // The crazyflie-nrf firmware sends empty packets with the signal strength, if nothing else is in the queue
1334 struct crtpPlatformRSSIAck
1335 {
1336  static bool match(const Crazyradio::Ack& response) {
1337  return crtp(response.data[0]) == crtp(15, 3);
1338  }
1339 
1340  crtp header;
1341  uint8_t reserved;
1342  uint8_t rssi;
1343 };
crtpLogStopRequest(uint8_t id)
Definition: crtp.h:432
crtpHoverSetpointRequest(float vx, float vy, float yawrate, float zDistance)
crtpMemoryType memType
Definition: crtp.h:439
uint8_t trajectoryId
Definition: crtp.h:1113
crtpCommanderHighLevelSetGroupMaskRequest(uint8_t groupMask)
Definition: crtp.h:1092
float qy
Definition: crtp.h:456
Definition: crtp.h:480
Definition: crtp.h:54
static int const CRTP_MAXSIZE_RESPONSE
Definition: crtp.h:11
uint8_t error
crtpParamWriteRequest(uint8_t id, const T &value)
Definition: crtp.h:15
uint8_t link
Definition: crtp.h:38
float yawrate
Definition: crtp.h:441
logBlockItem items[14]
Definition: crtp.h:441
float vy
Definition: crtp.h:440
uint8_t res0
Definition: crtp.h:25
crtpMemoryWriteRequest(uint8_t memId, uint32_t memAddr)
Definition: crtp.h:432
crtpCommanderHighLevelStopRequest(uint8_t groupMask)
Definition: crtp.h:1092
crtpLogGetInfoV2Request()
Definition: crtp.h:432
crtpParamWriteV2Request(uint16_t id, const T &value)
Definition: crtp.h:218
crtpParamReadRequest(uint8_t id)
Definition: crtp.h:15
int16_t vz
Definition: crtp.h:445
uint8_t reversed
Definition: crtp.h:1112
const T value
Definition: crtp.h:26
float vx
Definition: crtp.h:439
uint8_t sign
Definition: crtp.h:24
uint32_t remainValidMillisecs
Definition: crtp.h:1086
float z
Definition: crtp.h:445
crtpGetDeviceTypeNameRequest()
Definition: crtp.h:1092
float zDistance
Definition: crtp.h:442
uint8_t timestampLo
Definition: crtp.h:439
crtpMemoryGetNumberRequest()
Definition: crtp.h:432
uint8_t type
Definition: crtp.h:23
const uint8_t command
Definition: crtp.h:279
uint8_t data[29]
Definition: crtp.h:363
Definition: crtp.h:17
uint32_t log_crc
Definition: crtp.h:442
crtpParamTocGetItemRequest request
Definition: crtp.h:21
crtpNotifySetpointsStopRequest(uint32_t remainValidMillisecs)
Definition: crtp.h:1080
TrajectoryType_e
float qw
Definition: crtp.h:458
typedef __attribute__
uint8_t blockId
Definition: crtp.h:438
const uint8_t cmd
Definition: crtp.h:362
int version
Definition: crtp.h:1093
uint32_t quat
Definition: crtp.h:991
uint8_t length
Definition: crtp.h:22
uint8_t log_len
Definition: crtp.h:440
const uint8_t command
Definition: crtp.h:239
crtpParamTocGetItemResponse Response
Definition: crtp.h:27
crtpLogCreateBlockV2Request()
Definition: crtp.h:432
crtpGetFirmwareVersionRequest()
Definition: crtp.h:1092
uint8_t size_
Definition: crtp.h:375
crtpCommanderHighLevelLandRequest(uint8_t groupMask, float height, float duration)
Definition: crtp.h:1092
Ack()
Definition: ITransport.h:1343
crtpFullStateSetpointRequest(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)
Definition: crtp.h:478
#define CHECKSIZE_WITH_STATE(s, stateSize)
Definition: crtp.h:9
Definition: crtp.h:479
ParamType
#define CHECKSIZE_RESPONSE(s)
Definition: crtp.h:12
const crtp header
Definition: crtp.h:581
const uint8_t command
Definition: crtp.h:582
uint8_t reserved[12]
#define CHECKSIZE(s)
Definition: crtp.h:8
crtpExternalPositionUpdate(float x, float y, float z)
Definition: crtp.h:432
const uint8_t command
Definition: crtp.h:834
crtpEmergencyStopWatchdogRequest()
Definition: crtp.h:432
crtpGetProtocolVersionRequest()
Definition: crtp.h:1092
uint8_t responseSize_
Definition: crtp.h:376
crtpParamSetByNameRequest(const char *group, const char *name, const T &value)
uint8_t logType
Definition: crtp.h:432
constexpr crtp(uint8_t port, uint8_t channel)
crtpCommanderHighLevelTakeoffRequest(uint8_t groupMask, float height, float duration)
Definition: crtp.h:1092
uint8_t period
Definition: crtp.h:445
uint8_t group
Definition: crtp.h:27
float yaw
Definition: crtp.h:442
float height
Definition: crtp.h:1107
crtpPositionSetpointRequest(float x, float y, float z, float yaw)
char name[30]
Definition: crtp.h:1093
uint8_t result
Definition: crtp.h:440
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:15
crtpLogGetInfoRequest()
Definition: crtp.h:432
uint8_t log_max_packet
Definition: crtp.h:444
crtpExternalPosePacked()
Definition: crtp.h:432
uint8_t readonly
Definition: crtp.h:26
uint8_t size() const
Definition: crtp.h:365
uint8_t channel
Definition: crtp.h:37
crtpExternalPositionPacked()
Definition: crtp.h:432
void quatdecompress(uint32_t comp, float q[4])
Definition: crtp.cpp:45
uint8_t n_pieces
Definition: crtp.h:1249
int16_t omegax
Definition: crtp.h:450
uint32_t crc
Definition: crtp.h:23
const uint8_t command
Definition: crtp.h:30
uint8_t relative
Definition: crtp.h:1115
crtpLogCreateBlockRequest()
Definition: crtp.h:432
float yawRate
Definition: crtp.h:442
const crtp header
Definition: crtp.h:792
crtpMemoryGetInfoRequest(uint8_t memId)
Definition: crtp.h:432
const crtp header
Definition: crtp.h:176
uint8_t log_max_ops
Definition: crtp.h:446
const uint8_t command
Definition: crtp.h:102
int16_t ay
Definition: crtp.h:447
uint8_t memId
Definition: crtp.h:441
int16_t omegay
Definition: crtp.h:451
const uint8_t command
Definition: crtp.h:623
crtpLogControlResult
float timescale
Definition: crtp.h:1114
uint8_t requestByte1
Definition: crtp.h:439
const uint8_t command
Definition: crtp.h:142
uint8_t port
Definition: crtp.h:39
crtpMemoryType
float duration
Definition: crtp.h:1108
union @10 trajectoryIdentifier
uint32_t offset
Definition: crtp.h:1248
uint8_t responseSize() const
Definition: crtp.h:369
uint64_t memAddr
Definition: crtp.h:441
const crtp header
Definition: crtp.h:833
crtpLogStartRequest(uint8_t id, uint8_t period)
Definition: crtp.h:432
Definition: crtp.h:481
uint32_t memSize
Definition: crtp.h:440
int16_t az
Definition: crtp.h:448
float x
Definition: crtp.h:443
crtpExternalPoseUpdate(float x, float y, float z, float qx, float qy, float qz, float qw)
Definition: crtp.h:432
const crtp header
Definition: crtp.h:622
uint8_t id
Definition: crtp.h:31
crtpParamReadV2Request(uint16_t id)
Definition: crtp.h:218
uint8_t trajectoryLocation
Definition: crtp.h:1092
crtpVelocityWorldSetpointRequest(float x, float y, float z, float yawRate)
Definition: crtp.h:432
const uint8_t command
Definition: crtp.h:793
crtpParamTocGetItemRequest(uint8_t id)
Definition: crtp.h:15
crtpLogGetItemRequest(uint8_t id)
Definition: crtp.h:432
const uint8_t id
Definition: crtp.h:177
const crtp header
Definition: crtp.h:29
float qz
Definition: crtp.h:457
uint8_t numberOfMemories
Definition: crtp.h:439
crtpParamTocGetInfoRequest()
Definition: crtp.h:15
uint8_t groupMask
Definition: crtp.h:1102
TrajectoryLocation_e
int16_t ax
Definition: crtp.h:446
int16_t omegaz
Definition: crtp.h:452
crtpStopRequest()
crtpLogResetRequest()
Definition: crtp.h:432
uint16_t timestampHi
Definition: crtp.h:440
char text[28]
Definition: crtp.h:28
crtpEmergencyStopRequest()
Definition: crtp.h:432
const uint16_t id
Definition: crtp.h:314
static int const CRTP_MAX_DATA_SIZE
Definition: crtp.h:6
bool operator==(const crtp &other) const
const crtp header
Definition: crtp.h:313
static int const CRTP_MAXSIZE
Definition: crtp.h:7
float y
Definition: crtp.h:444
crtpCommanderHighLevelGoToRequest(uint8_t groupMask, bool relative, float x, float y, float z, float yaw, float duration)
Definition: crtp.h:1092
float qx
Definition: crtp.h:455
uint8_t trajectoryType
Definition: crtp.h:1093
crtpCommanderHighLevelStartTrajectoryRequest(uint8_t groupMask, bool relative, bool reversed, uint8_t trajectoryId, float timescale)
Definition: crtp.h:1092
uint8_t status
Definition: crtp.h:440
uint8_t numParam
Definition: crtp.h:22
crtpMemoryReadRequest(uint8_t memId, uint32_t memAddr, uint8_t length)
Definition: crtp.h:432
crtpLogGetItemV2Request(uint16_t id)
Definition: crtp.h:432
crtpLogAppendBlockV2Request()
Definition: crtp.h:432
crtpParamTocGetItemV2Request(uint16_t id)
Definition: crtp.h:218
crtpParamTocGetInfoV2Request()
Definition: crtp.h:218
crtpCommanderHighLevelDefineTrajectoryRequest(uint8_t trajectoryId)
Definition: crtp.h:1092


crazyflie_tools
Author(s): Wolfgang Hoenig
autogenerated on Mon Sep 28 2020 03:40:15