Logging
-
class ULog
Class to handle the logging of data to a file in the ULog data format (https://docs.px4.io/main/en/dev_log/ulog_file_format.html). The interface is relatively simple. The user instantiates the object, runs the init() member function once, and then repeatedly calls the
write_msg()
member function to record the data to a file. The user can then use thepx4tools
python package to read the data from the file (typically it is converted to a CSV file). To increase the performance of the logging, the interaction with the file system is done in a separate thread. This way, the control thread doesn’t get backed up with I/O flushing.Public Functions
-
ULog() = default
Construct a new ULog object.
-
~ULog()
Destroy the ULog object.
-
int init(const std::filesystem::path &log_folder)
Initialize the ULog object. This function must be called before any other member functions. It creates the file, writes the header, and starts the logging thread. The created file is called logger.ulog, and it placed in the directory provided.
- Parameters:
log_filename – The name of the ULog file to create
- Returns:
int 0 if successful, -1 otherwise
Public Static Functions
-
static std::filesystem::path generate_incremented_run_dir(const std::filesystem::path &log_folder)
Creates a directory for logging data for a given run. This is run with a very simple naming scheme, where the directory is named
run<number>
, where<number>
is the first number that doesn’t already exist. The date or time is not used because the hardware usually doesn’t have a clock that is synchronized with local time.- Parameters:
log_folder – The base folder to create the run directory in
- Returns:
std::filesystem::path The path to the created directory
-
ULog() = default
-
struct ULogMsg
Base class for all ULog data structs. This sets the interface for how ULog data is processed to store on disk.
Subclassed by flyMS::ULogFlightMsg, flyMS::ULogGpsMsg, flyMS::ULogPosCntrlMsg
-
struct ULogFlightMsg : public flyMS::ULogMsg
Data struct for storing metrics that are used to evaluate the performance of the flight controller. This includes the system’s state, sensor data, setpoints, and control effort (motor commands) This struct inherits from ULogMsg and is used to write to the ULog file.
-
struct ULogFlightMsgData
The data fields that are recorded for the ULogFlightMsg. This struct is in serializable format.
-
struct ULogFlightMsgData
-
struct ULogGpsMsg : public flyMS::ULogMsg
Data struct for storing GPS data. This struct inherits from ULogMsg and is used to write to the ULog file. It contains the recorded GPS LLA data.
-
struct ULogGpsMsgData
-
struct ULogGpsMsgData
-
struct ULogPosCntrlMsg : public flyMS::ULogMsg
Data struct for storing the position and velocity of the vehicle. This struct inherits from ULogMsg and is used to write to the ULog file. This struct is only used when the flyMS system is receiving position and velocity data from an external source (e.g. VIO). It records here to show it’s consistency with the rest of the flyMS data.
-
struct ULogPosCntrlMsgData
The data fields that are recorded for the ULogPosCntrlMsg. This struct is in serializable format.
-
struct ULogPosCntrlMsgData