log

Enables logging of variables from the Crazyflie.

When a Crazyflie is connected it’s possible to download a TableOfContent of all the variables that can be logged. Using this it’s possible to add logging configurations where selected variables are sent to the client at a specified period.

Terminology

Term Description
Log configuration A configuration with a period and a number of variables that are present in the TOC.
Stored as The size and type of the variable as declared in the Crazyflie firmware.
Fetch as The size and type that a variable should be fetched as. This does not have to be the same as the size and type it’s stored as.

States of a configuration

State Description
Created on host When a configuration is created the contents is checked so that all the variables are present in the TOC. If not then the configuration cannot be created.
Created on CF When the configuration is deemed valid it is added to the Crazyflie. At this time the memory constraint is checked and the status returned.
Started on CF Any added block that is not started can be started. Once started the Crazyflie will send back logdata periodically according to the specified period when it’s created.
Stopped on CF Any started configuration can be stopped. The memory taken by the configuration on the Crazyflie is NOT freed, the only effect is that the Crazyflie will stop sending logdata back to the host.
Deleted on CF Any block that is added can be deleted. When this is done the memory taken by the configuration is freed on the Crazyflie. The configuration will have to be re-added to be used again.

Classes

Log

Log(crazyflie=None)

Create log configuration


Class variables

MAX_BLOCKS

MAX_VARIABLES

Methods

def add_config(self, logconf)

Add a log configuration to the logging framework.

When doing this the contents of the log configuration will be validated and listeners for new log configurations will be notified. When validating the configuration the variables are checked against the TOC to see that they actually exist. If they don’t then the configuration cannot be used. Since a valid TOC is required, a Crazyflie has to be connected when calling this method, otherwise it will fail.


def refresh_toc(self, refresh_done_callback, toc_cache)

Start refreshing the table of loggale variables


def reset(self)

Reset the log system and remove all log blocks


LogTocElement

LogTocElement(ident=0, data=None)

An element in the Log TOC.

TocElement creator. Data is the binary payload of the element.


Class variables

types

Static methods

def get_cstring_from_id(ident)

Return the C-storage name given the variable type id


def get_id_from_cstring(name)

Return variable type id given the C-storage name


def get_size_from_id(ident)

Return the size in bytes given the variable type id


def get_unpack_string_from_id(ident)

Return the Python unpack string given the variable type id