Logging

The Crazyflie’s logging feature allows data to be streamed from the Crazyflie to a PC. By defining so called Log Blocks, the user can define which variables should be logged. A Log Block consists of several variables. A list of Logging groups and variables is available on the bitcraze website. Depending on your firmware version some variables might not be available.

Implementation and Usage

The logging framework is implemented as a ROS2 topic interface:

Warning

When sending onto these topics it is important to use the --once flag to ensure that the message is only sent once. Also when sending from Terminal topics often do not get received by the crazyflie. Check the output of the crazyflie node to ensure that the message was received.

Creating a Log Block

When a Crazyflie is connected, a ROS topic called cfID/create_log_block is available (where ID is the id of the Crazyflie). The msg definition is as follows and can be found here:

LogBlock.msg
string[] variables
string name

In variables you can add multiple log variables, e.g. pm.vbat. The name can be choosen freely. In the following we assume that we have chosen pm_log as the name.

ros2 topic pub /cf0/create_log_block crazyflie_interfaces/msg/LogBlock "variables: ['pm.vbat']
name: 'pm_log'" --once

After sending this, 3 new topics will be created:

  • cfID/log/pm_log/start

  • cfID/log/pm_log/stop

  • cfID/log/pm_log/data

Note

There is a maximum of 28 bytes available for each log block. Ensure that you do not have too many variables in your block.

Starting a LogBlock

The start topic starts the log block on the crazyflie with a defined logging periode. The type of the topic is encoded using a std_msgs/Int16.

Note

The unit is [10ms]. A frequency of 1 Hz is obtained by setting this to 100.

ros2 topic pub /cf0/log/pm_log/start std_msgs/msg/Int16 "data: 100" --once

Receiving Data

When the log block is started, the data streamed by the crazyflie is posted to the data topic as GenericLogBlock messages:

GenericLogBlock.msg
float64[] values

The values are sorted as described when the log block was created. The values are always of type float64, and need to be converted to the appropriate type if necessary.

ros2 topic echo /cf0/log/pm_log/data

Stopping a Log Block

A log block can be stopped by sending an Empty message to the provided topic.

ros2 topic pub /cf0/log/pm_log/stop std_msgs/msg/Empty --once

Note

When creating and starting log block with code it is important to add a delay between creating the log block and starting it. This is because the appropriate topics need to be created first.

Webots Implementation

When using the webots simulation, a limited subset of logging variables is available. Calling the cfID/get_logging_toc_info topic will print all available logging variables to the console. (You should avoid calling this on a hardware Crazyflie).

ros2 topic pub /cf0/get_logging_toc_info std_msgs/msg/Empty --once

Hardware Implementation

The cpp implementation automatically logs one log block to the topic /cfID/state consisting of the following variables:

If the crazyflie is also set to default (no external tracking) there will be an additional log block. This block will not be published as a GenericLogBlock topic but insted on the global /cf_positions topic.