flightdb
– Flight Controller Database, logging and param system¶
Flight Controller Database Interface
Access to the parameter and logging systems on CodeAIR’s Crazyflie flight controller.
See also Crazyflie Client Library
-
class
codeair.flightdb.
LogManager
[source]¶ Interface to query the CF logging framework:
Retrieve the list of available logging items (TOC) : [(id, type, group, name), …]
Register new logging configs (log blocks)
Start/Stop logging
Also handle fetching of Param TOC, since logic is identical.
This class uses crtp – Crazy Real Time Protocol to implement the log interface
-
check_catalog_crcs
()[source]¶ Read CRCs from flight controller, return True if they match catalog import
-
decode_log
(blk_id, timestamp_ms, data)[source]¶ Decode received log values for this block, updating self.cache.
-
enable
(do_enable)[source]¶ Resume / pause logging. NOTE: Must register_items() FIRST, before enable!
-
fetch_toc
(port, info_only=False)[source]¶ Request TOC info, either PARAM or LOG based on port (CRTP_PORT_LOG or CRTP_PORT_PARAM)
-
generate_catalog
(filename='new_flight_catalog.py')[source]¶ Create Python file with log/param TOCs to bake into new CodeAIR builds
-
register_items
(item_list, rate=0.1)[source]¶ Register and start logging the given list of items. Removes all prior logging. Rate is seconds. item_list contains strings of form ‘group.variable’.
Internals:
The Crazyflie allows up to 16 “log blocks” to be registered.
You register a log block by supplying a list of [TYPE8:ID16] tuples referring to TOC items.
The resulting LOG_CH reports for a block must fit within a 30 byte packet, where 4 bytes are consumed with [BLK_ID_8, TIMESTAMP_24], leaving 26 bytes cumulative payload for log values. This means the max number of IDs you can register in a block depends on the size of the items (8/16/32 bits).
Ex: you could register up to 6 32-bit items in a log block.
Our Python API exposes a single function to register an id_list, hiding the underlying “log block” system.
We don’t support dynamically appending/deleting discrete blocks. All are created/removed at once.
Currently we don’t support different rates for different params. The underlying system has a rate for each block.
Currently supports only a single log block.
TODO: Extend to create up to max (16) blocks to support more log items.
Protocol:
CRTP(CRTP_PORT_LOG, CONTROL_CH)
Create block: ( CONTROL_CREATE_BLOCK_V2_8, BLK_ID_8, [TYPE_8, ID_16]*n )
Delete all: (CONTROL_RESET)
Notes: Successful registration will initialize -
self.cache # {'name': None,...} # Dict keyed by names from all blocks self.log_blocks = [ [name0, name1,...], # list of names in this block decode_fmt_str, # struct format str for decoding this log block val_sz, # = struct.calcsize(decode_fmt_str) reg_fields, # registration fields (packet payload) ]
- Returns
True if id_list can be registered, False if it would exceed logging payload limits or if list contains an invalid ID.
- Return type
-
class
codeair.flightdb.
ParamManager
(log_mgr)[source]¶ Interface to query the CF parameter framework. Unlike logging, we don’t register for events in the param system.