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)
22  , port(port)
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;
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 
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  }
231 
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 
276  typedef crtpParamTocGetInfoV2Response Response;
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)
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 
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 
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 
579  typedef crtpLogGetInfoResponse Response;
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 {
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 
620  typedef crtpLogGetItemResponse Response;
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;
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 
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 
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 
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 
755  uint8_t command;
756  uint8_t requestByte1;
757  uint8_t result; // one of crtpLogControlResult
758 } __attribute__((packed));
760 
762 {
763  static bool match(const Crazyradio::Ack& response) {
764  return response.size > 4 &&
765  crtp(response.data[0]) == crtp(5, 2);
766  }
767 
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 
790  typedef crtpLogGetInfoV2Response Response;
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 {
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 
831  typedef crtpLogGetItemV2Response Response;
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 
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));
923 CHECKSIZE(crtpExternalPositionPacked)
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));
995 CHECKSIZE(crtpExternalPosePacked)
996 
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 
1065 // Port 0x08 (High-level Setpoints)
1066 
1068 {
1070  uint8_t groupMask)
1071  : header(0x08, 0)
1072  , command(0)
1073  , groupMask(groupMask)
1074  {
1075  }
1076 
1077  const crtp header;
1078  const uint8_t command;
1079  uint8_t groupMask;
1080 } __attribute__((packed));
1082 
1084 {
1086  uint8_t groupMask,
1087  float height,
1088  float duration)
1089  : header(0x08, 0)
1090  , command(1)
1091  , groupMask(groupMask)
1092  , height(height)
1093  , duration(duration)
1094  {
1095  }
1096 
1097  const crtp header;
1098  const uint8_t command;
1099  uint8_t groupMask; // mask for which CFs this should apply to
1100  float height; // m (absolute)
1101  float duration; // s (time it should take until target height is reached)
1102 } __attribute__((packed));
1104 
1106 {
1108  uint8_t groupMask,
1109  float height,
1110  float duration)
1111  : header(0x08, 0)
1112  , command(2)
1113  , groupMask(groupMask)
1114  , height(height)
1115  , duration(duration)
1116  {
1117  }
1118 
1119  const crtp header;
1120  const uint8_t command;
1121  uint8_t groupMask; // mask for which CFs this should apply to
1122  float height; // m (absolute)
1123  float duration; // s (time it should take until target height is reached)
1124 } __attribute__((packed));
1126 
1128 {
1130  uint8_t groupMask)
1131  : header(0x08, 0)
1132  , command(3)
1133  , groupMask(groupMask)
1134  {
1135  }
1136 
1137  const crtp header;
1138  const uint8_t command;
1139  uint8_t groupMask; // mask for which CFs this should apply to
1140 } __attribute__((packed));
1142 
1144 {
1146  uint8_t groupMask,
1147  bool relative,
1148  float x,
1149  float y,
1150  float z,
1151  float yaw,
1152  float duration)
1153  : header(0x08, 0)
1154  , command(4)
1155  , groupMask(groupMask)
1156  , relative(relative)
1157  , x(x)
1158  , y(y)
1159  , z(z)
1160  , yaw(yaw)
1161  , duration(duration)
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  uint8_t relative; // set to true, if position/yaw are relative to current setpoint
1169  float x; // m
1170  float y; // m
1171  float z; // m
1172  float yaw; // deg
1173  float duration; // sec
1174 } __attribute__((packed));
1176 
1178 {
1180  uint8_t groupMask,
1181  bool relative,
1182  bool reversed,
1183  uint8_t trajectoryId,
1184  float timescale)
1185  : header(0x08, 0)
1186  , command(5)
1187  , groupMask(groupMask)
1188  , relative(relative)
1189  , reversed(reversed)
1190  , trajectoryId(trajectoryId)
1191  , timescale(timescale)
1192  {
1193  }
1194 
1195  const crtp header;
1196  const uint8_t command;
1197  uint8_t groupMask; // mask for which CFs this should apply to
1198  uint8_t relative; // set to true, if trajectory should be shifted to current setpoint
1199  uint8_t reversed; // set to true, if trajectory should be executed in reverse
1200  uint8_t trajectoryId; // id of the trajectory (previously defined by COMMAND_DEFINE_TRAJECTORY)
1201  float timescale; // time factor; 1 = original speed; >1: slower; <1: faster
1202 } __attribute__((packed));
1204 
1207  TRAJECTORY_LOCATION_MEM = 1, // for trajectories that are uploaded dynamically
1208  // Future features might include trajectories on flash or uSD card
1209 };
1210 
1212  TRAJECTORY_TYPE_POLY4D = 0, // struct poly4d, see pptraj.h
1213  // Future types might include versions without yaw
1214 };
1215 
1217 {
1218  uint8_t trajectoryLocation; // one of TrajectoryLocation_e
1219  uint8_t trajectoryType; // one of TrajectoryType_e
1220  union
1221  {
1222  struct {
1223  uint32_t offset; // offset in uploaded memory
1224  uint8_t n_pieces;
1225  } __attribute__((packed)) mem; // if trajectoryLocation is TRAJECTORY_LOCATION_MEM
1227 } __attribute__((packed));
1228 
1230 {
1232  uint8_t trajectoryId)
1233  : header(0x08, 0)
1234  , command(6)
1235  , trajectoryId(trajectoryId)
1236  {
1237  }
1238 
1239  const crtp header;
1240  const uint8_t command;
1241  uint8_t trajectoryId;
1243 } __attribute__((packed));
1245 
1246 // Port 13 (Platform)
1247 
1249 {
1251  : header(0x0D, 1)
1252  {
1253  }
1254 
1255  const crtp header;
1256  const uint8_t cmd = 0;
1257 } __attribute__((packed));
1259 
1261 {
1263  int version;
1264 } __attribute__((packed));
1266 
1268 {
1270  : header(0x0D, 1)
1271  {
1272  }
1273 
1274  const crtp header;
1275  const uint8_t cmd = 1;
1276 } __attribute__((packed));
1278 
1280 {
1282  char version[30];
1283 } __attribute__((packed));
1285 
1287 {
1289  : header(0x0D, 1)
1290  {
1291  }
1292 
1293  const crtp header;
1294  const uint8_t cmd = 2;
1295 } __attribute__((packed));
1297 
1299 {
1301  char name[30];
1302 } __attribute__((packed));
1304 
1305 // The crazyflie-nrf firmware sends empty packets with the signal strength, if nothing else is in the queue
1307 {
1308  static bool match(const Crazyradio::Ack& response) {
1309  return crtp(response.data[0]) == crtp(15, 3);
1310  }
1311 
1313  uint8_t reserved;
1314  uint8_t rssi;
1315 };
crtpParamWriteRequest(uint8_t id, const T &value)
Definition: crtp.h:184
crtpHoverSetpointRequest(float vx, float vy, float yawrate, float zDistance)
crtpParamTocGetItemResponse Response
Definition: crtp.h:236
uint8_t trajectoryId
Definition: crtp.h:453
int version
Definition: crtp.h:433
float qy
Definition: crtp.h:456
crtpLogGetInfoResponse Response
Definition: crtp.h:579
uint8_t logType
Definition: crtp.h:854
Definition: crtp.h:480
uint8_t id
Definition: crtp.h:644
Definition: crtp.h:54
static int const CRTP_MAXSIZE_RESPONSE
Definition: crtp.h:11
uint8_t error
uint8_t link
Definition: crtp.h:38
float yawrate
Definition: crtp.h:441
float vy
Definition: crtp.h:440
uint8_t res0
Definition: crtp.h:25
bool operator==(const crtpParamTocGetItemRequest &other) const
Definition: crtp.h:95
const crtp header
Definition: crtp.h:366
int16_t vz
Definition: crtp.h:445
uint8_t reversed
Definition: crtp.h:452
const T value
Definition: crtp.h:26
uint8_t responseSize() const
Definition: crtp.h:374
float vx
Definition: crtp.h:439
uint8_t sign
Definition: crtp.h:24
crtpGetFirmwareVersionRequest request
Definition: crtp.h:1281
float z
Definition: crtp.h:445
float zDistance
Definition: crtp.h:442
bool operator==(const crtpLogGetItemRequest &other) const
Definition: crtp.h:616
uint8_t timestampLo
Definition: crtp.h:770
crtpMemoryGetNumberRequest()
Definition: crtp.h:432
uint32_t memAddr
Definition: crtp.h:559
uint8_t type
Definition: crtp.h:23
const uint8_t command
Definition: crtp.h:279
crtpLogGetInfoV2Response Response
Definition: crtp.h:790
crtpLogGetItemResponse Response
Definition: crtp.h:620
const crtp header
Definition: crtp.h:511
Definition: crtp.h:17
bool operator==(const crtpParamTocGetInfoRequest &other) const
Definition: crtp.h:135
crtpLogGetItemV2Request(uint16_t id)
Definition: crtp.h:820
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:148
crtpParamTocGetInfoV2Response Response
Definition: crtp.h:276
TrajectoryType_e
Definition: crtp.h:1211
float qw
Definition: crtp.h:458
typedef __attribute__
bool operator==(const crtpParamReadRequest &other) const
Definition: crtp.h:170
const uint16_t id
Definition: crtp.h:331
const uint8_t command
Definition: crtp.h:867
const uint8_t cmd
Definition: crtp.h:362
crtpCommanderHighLevelTakeoffRequest(uint8_t groupMask, float height, float duration)
Definition: crtp.h:1085
crtpParamTocGetItemV2Request request
Definition: crtp.h:252
uint8_t data[32]
Definition: ITransport.h:19
uint8_t period
Definition: crtp.h:704
uint8_t length
Definition: crtp.h:22
const uint8_t command
Definition: crtp.h:239
bool operator==(const crtpLogGetInfoV2Request &other) const
Definition: crtp.h:786
uint8_t size_
Definition: crtp.h:375
uint8_t reserved
Definition: crtp.h:1313
const uint8_t command
Definition: crtp.h:882
crtpParamTocGetItemRequest request
Definition: crtp.h:115
uint8_t id
Definition: crtp.h:720
uint8_t trajectoryType
Definition: crtp.h:1219
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
crtpLogGetItemV2Response Response
Definition: crtp.h:831
#define CHECKSIZE_WITH_STATE(s, stateSize)
Definition: crtp.h:9
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:588
const crtp header
Definition: crtp.h:718
uint32_t memAddr
Definition: crtp.h:527
Definition: crtp.h:479
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:799
ParamType
Definition: crtp.h:73
#define CHECKSIZE_RESPONSE(s)
Definition: crtp.h:12
const crtp header
Definition: crtp.h:193
const crtp header
Definition: crtp.h:581
crtpCommanderHighLevelStopRequest(uint8_t groupMask)
Definition: crtp.h:1129
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:630
const uint8_t command
Definition: crtp.h:582
const crtp header
Definition: crtp.h:985
#define CHECKSIZE(s)
Definition: crtp.h:8
const uint8_t command
Definition: crtp.h:834
uint8_t size
Definition: ITransport.h:21
bool operator==(const crtpLogGetItemV2Request &other) const
Definition: crtp.h:827
uint8_t responseSize_
Definition: crtp.h:376
crtpParamSetByNameRequest(const char *group, const char *name, const T &value)
crtpLogGetItemRequest(uint8_t id)
Definition: crtp.h:609
constexpr crtp(uint8_t port, uint8_t channel)
Definition: crtp.h:19
uint8_t log_max_packet
Definition: crtp.h:811
bool operator==(const crtpParamTocGetItemV2Request &other) const
Definition: crtp.h:232
uint8_t period
Definition: crtp.h:445
uint8_t data[29]
Definition: crtp.h:363
uint16_t id
Definition: crtp.h:855
uint8_t requestByte1
Definition: crtp.h:756
uint8_t group
Definition: crtp.h:27
float yaw
Definition: crtp.h:442
float height
Definition: crtp.h:447
crtpPositionSetpointRequest(float x, float y, float z, float yaw)
char name[30]
Definition: crtp.h:433
const uint8_t command
Definition: crtp.h:656
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:15
uint32_t memAddr
Definition: crtp.h:545
uint8_t readonly
Definition: crtp.h:26
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:486
crtpLogGetInfoRequest request
Definition: crtp.h:594
bool operator==(const crtpParamTocGetInfoV2Request &other) const
Definition: crtp.h:272
const crtp header
Definition: crtp.h:967
crtpLogStartRequest(uint8_t id, uint8_t period)
Definition: crtp.h:691
crtpParamTocGetItemResponse Response
Definition: crtp.h:99
uint8_t channel
Definition: crtp.h:37
void quatdecompress(uint32_t comp, float q[4])
Definition: crtp.cpp:45
uint8_t trajectoryLocation
Definition: crtp.h:1218
crtpExternalPositionUpdate(float x, float y, float z)
Definition: crtp.h:892
crtpParamTocGetInfoV2Request request
Definition: crtp.h:291
const crtp header
Definition: crtp.h:732
const uint8_t command
Definition: crtp.h:30
uint8_t relative
Definition: crtp.h:455
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:62
const crtp header
Definition: crtp.h:931
uint16_t timestampHi
Definition: crtp.h:771
crtpCommanderHighLevelGoToRequest(uint8_t groupMask, bool relative, float x, float y, float z, float yaw, float duration)
Definition: crtp.h:1145
crtpGetDeviceTypeNameRequest request
Definition: crtp.h:1300
const crtp header
Definition: crtp.h:792
const crtp header
Definition: crtp.h:701
crtpLogStopRequest(uint8_t id)
Definition: crtp.h:710
const uint8_t command
Definition: crtp.h:733
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:841
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:246
const crtp header
Definition: crtp.h:176
const uint8_t command
Definition: crtp.h:102
crtpMemoryType memType
Definition: crtp.h:493
uint8_t length
Definition: crtp.h:514
int16_t ay
Definition: crtp.h:447
uint8_t memId
Definition: crtp.h:441
const crtp header
Definition: crtp.h:1000
crtpCommanderHighLevelDefineTrajectoryRequest(uint8_t trajectoryId)
Definition: crtp.h:1231
crtpParamWriteV2Request(uint16_t id, const T &value)
Definition: crtp.h:321
const uint8_t command
Definition: crtp.h:623
crtpCommanderHighLevelSetGroupMaskRequest(uint8_t groupMask)
Definition: crtp.h:1069
uint32_t log_crc
Definition: crtp.h:598
crtpLogControlResult
Definition: crtp.h:737
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:285
float timescale
Definition: crtp.h:454
uint8_t size() const
Definition: crtp.h:370
crtpParamTocGetItemRequest request
Definition: crtp.h:21
uint8_t size
Definition: crtp.h:44
const uint8_t command
Definition: crtp.h:142
uint8_t port
Definition: crtp.h:39
crtpMemoryType
Definition: crtp.h:476
float duration
Definition: crtp.h:448
union @10 trajectoryIdentifier
uint8_t responseSize() const
Definition: crtp.h:369
uint64_t memAddr
Definition: crtp.h:441
const crtp header
Definition: crtp.h:833
uint8_t log_max_ops
Definition: crtp.h:602
Definition: crtp.h:481
crtpLogGetInfoRequest request
Definition: crtp.h:805
crtpParamValueResponse Response
Definition: crtp.h:174
crtpExternalPoseUpdate(float x, float y, float z, float qx, float qy, float qz, float qw)
Definition: crtp.h:949
crtpMemoryGetInfoRequest request
Definition: crtp.h:492
int16_t az
Definition: crtp.h:448
float x
Definition: crtp.h:443
crtpMemoryGetInfoRequest(uint8_t memId)
Definition: crtp.h:463
uint32_t offset
Definition: crtp.h:1223
uint8_t rssi
Definition: crtp.h:1314
const crtp header
Definition: crtp.h:622
uint32_t memAddr
Definition: crtp.h:513
crtpParamValueV2Response Response
Definition: crtp.h:311
crtpCommanderHighLevelLandRequest(uint8_t groupMask, float height, float duration)
Definition: crtp.h:1107
uint8_t type
Definition: crtp.h:1001
const uint8_t command
Definition: crtp.h:793
crtpParamTocGetInfoRequest request
Definition: crtp.h:154
const uint8_t id
Definition: crtp.h:177
const uint8_t command
Definition: crtp.h:719
uint8_t n_pieces
Definition: crtp.h:1224
const crtp header
Definition: crtp.h:330
float qz
Definition: crtp.h:457
uint8_t numberOfMemories
Definition: crtp.h:439
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:552
crtpParamReadV2Request(uint16_t id)
Definition: crtp.h:300
uint8_t groupMask
Definition: crtp.h:442
TrajectoryLocation_e
Definition: crtp.h:1205
crtpCommanderHighLevelStartTrajectoryRequest(uint8_t groupMask, bool relative, bool reversed, uint8_t trajectoryId, float timescale)
Definition: crtp.h:1179
int16_t ax
Definition: crtp.h:446
uint8_t blockId
Definition: crtp.h:769
const uint8_t command
Definition: crtp.h:471
crtpMemoryWriteRequest(uint8_t memId, uint32_t memAddr)
Definition: crtp.h:535
const crtp header
Definition: crtp.h:29
crtpStopRequest()
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:749
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:1308
crtpParamTocGetInfoResponse Response
Definition: crtp.h:139
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:109
const uint8_t command
Definition: crtp.h:702
crtpLogGetItemV2Request request
Definition: crtp.h:847
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:763
crtpGetProtocolVersionRequest request
Definition: crtp.h:1262
bool operator==(const crtpParamReadV2Request &other) const
Definition: crtp.h:307
logBlockItem items[14]
Definition: crtp.h:441
crtpMemoryReadRequest(uint8_t memId, uint32_t memAddr, uint8_t length)
Definition: crtp.h:501
static bool match(const Crazyradio::Ack &response)
Definition: crtp.h:520
const uint16_t id
Definition: crtp.h:314
static int const CRTP_MAX_DATA_SIZE
Definition: crtp.h:6
const crtp header
Definition: crtp.h:655
bool operator==(const crtp &other) const
Definition: crtp.h:33
const crtp header
Definition: crtp.h:1012
crtpParamTocGetItemRequest(uint8_t id)
Definition: crtp.h:87
const crtp header
Definition: crtp.h:313
uint8_t header
Definition: crtp.h:47
static int const CRTP_MAXSIZE
Definition: crtp.h:7
float y
Definition: crtp.h:444
char text[28]
Definition: crtp.h:28
float qx
Definition: crtp.h:455
uint8_t logType
Definition: crtp.h:643
crtpParamReadRequest(uint8_t id)
Definition: crtp.h:163
const crtp header
Definition: crtp.h:543
struct trajectoryDescription description
Definition: crtp.h:443
crtpLogGetItemRequest request
Definition: crtp.h:636
uint8_t status
Definition: crtp.h:440
uint8_t log_max_packet
Definition: crtp.h:600
const uint8_t id
Definition: crtp.h:194
uint8_t id
Definition: crtp.h:703
const crtp header
Definition: crtp.h:470
crtpParamTocGetItemV2Request(uint16_t id)
Definition: crtp.h:218
bool operator==(const crtpLogGetInfoRequest &other) const
Definition: crtp.h:575


crazyflie_cpp
Author(s): Wolfgang Hoenig
autogenerated on Fri Nov 1 2019 03:39:56