This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
doc:crazyflie:crtp:param [2014-11-25 16:17] macke created |
doc:crazyflie:crtp:param [2020-05-12 14:22] (current) kimberly |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <WRAP center round important 60%> | ||
+ | This page has deprecated and moved to the new documentation framework of the main Bitcraze website. Please go to [[https:// | ||
+ | </ | ||
+ | ====== Parameters ====== | ||
+ | The parameters system makes all the gettable and settable parameters of the copter accessible. The copter holds a table of parameters which can be retrieved. In this table every parameter name is associated with an ID and a group name. Three IDs are used to acces the TOC and the parameters: | ||
+ | |||
+ | ^ Port ^ Channel | ||
+ | | 2 | ||
+ | | 2 | ||
+ | | 2 | ||
+ | | 2 | ||
+ | |||
+ | ===== TOC access ===== | ||
+ | These messages permit to access the parameters table of content. The first byte of the message is a message ID, three messages ID are defined: | ||
+ | |||
+ | ^ Message ID ^ Meaning in upstream packets | ||
+ | | 0 | Reset TOC pointer | ||
+ | | 1 | Get next TOC element | ||
+ | | 3 | Get TOC CRC32 | Number of parameters, TOC CRC32 | | ||
+ | |||
+ | The upstream ID are commands and are sent alone. The downstream has the following formats: | ||
+ | |||
+ | < | ||
+ | Bytes | ||
+ | +---+------------+------+----------+--------------+ | ||
+ | | 0 | | | | | | ||
+ | +---+ Param ID | Type | Group | ||
+ | | 1 | | | | | | ||
+ | +---+------------+------+---+------+--------------+ | ||
+ | | 3 | Num. Param | CRC32 | | ||
+ | +---+------------+----------+ | ||
+ | Bytes | ||
+ | </ | ||
+ | |||
+ | The parameters are sequentially requested by the PC until the end. When the last parameter is reached it has the ID 0 'Last TOC element' | ||
+ | |||
+ | The CRC32 is a hash of the copter TOC. This is aimed at implementing caching of the TOC in the PC Utils to avoid fetching the full TOC each time the copter is connected. | ||
+ | |||
+ | The type is one byte describing the parameter type: | ||
+ | |||
+ | ^ Type code ^ C type ^ Python unpack | | ||
+ | | 0x08 | uint8_t | '< | ||
+ | | 0x09 | uint16_t | '< | ||
+ | | 0x0A | uint32_t | '< | ||
+ | | 0x0B | uint64_t | '< | ||
+ | | 0x00 | int8_t | '< | ||
+ | | 0x01 | int16_t | '< | ||
+ | | 0x02 | int32_t | '< | ||
+ | | 0x03 | int64_t | '< | ||
+ | | 0x05 | FP16 | '' | ||
+ | | 0x06 | float | '< | ||
+ | | 0x07 | double | '< | ||
+ | |||
+ | ===== Parameter read ===== | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | ^ Byte ^ Request fields ^ Content | ||
+ | | 0 | ID | ID of the parameter to read (see TOC) | | ||
+ | </ | ||
+ | |||
+ | <WRAP half column> | ||
+ | ^ Byte ^ Answer fields | ||
+ | | 0 | ID | ID of the parameter | | ||
+ | | 1-.. | value | Value of the parameter. Size and format is described in the TOC | | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | The read request is a simple packet on channel 1. Crazyflie answers with the value. | ||
+ | |||
+ | ===== Parameter write ===== | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | ^ Byte ^ Request fields ^ Content | ||
+ | | 0 | ID | ID of the parameter to write | | ||
+ | | 1-... | value | Value to write. Size and format is described in the TOC | | ||
+ | </ | ||
+ | |||
+ | <WRAP half column> | ||
+ | ^ Byte ^ Answer fields | ||
+ | | 0 | ID | ID of the parameter | | ||
+ | | 1-... | value | Value of the parameter. Size and format is described in the TOC | | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | The write request is a simple packet on channel 2. Crazyflie sends back the parameter value as an acknowledgement. | ||
+ | |||
+ | ===== Misc. commands ===== | ||
+ | |||
+ | The following misc commands are implemented: | ||
+ | |||
+ | ^ Code ^ Command ^ | ||
+ | | 0x00 | [[doc: | ||
+ | |||
+ | ==== Set by name ==== | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | ^ Byte ^ Request fields ^ Content | ||
+ | | 0 | SET_BY_NAME | ||
+ | | 1-n | group | Name of the group | | ||
+ | | n-(n+1) | ||
+ | | (n+1)-(n+m+1) | ||
+ | | (n+m+1)-(n+m+2) | ||
+ | | (n+m+2)-(n+m+3) | ||
+ | | (n+m+3)-... | ||
+ | </ | ||
+ | |||
+ | <WRAP half column> | ||
+ | ^ Byte ^ Answer fields | ||
+ | | 0 | SET_BY_NAME | ||
+ | | 1-n | group | Name of the group | | ||
+ | | n-(n+1) | ||
+ | | (n+1)-(n+m+1) | ||
+ | | (n+m+2) | ||
+ | | (n+m+3) | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | //Group// and //name// are ascii strings of size respectively //n// and //m//. The type corresponds to the TOC type of the parameter. It is checked for consistency. | ||
+ | |||
+ | This command is useful to set a parameter without having to fetch the full TOC. It is enough to know the group, name and type of the parameter to write it. |