mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 17:33:33 +08:00
logger: change SDLOG_PROFILE into a bitset
This is more flexible, allowing a combination of sets. The default enables the same set & rates as before
This commit is contained in:
@@ -531,7 +531,7 @@ bool Logger::copy_if_updated_multi(LoggerSubscription &sub, int multi_instance,
|
||||
return updated;
|
||||
}
|
||||
|
||||
void Logger::add_common_topics()
|
||||
void Logger::add_default_topics()
|
||||
{
|
||||
#ifdef CONFIG_ARCH_BOARD_SITL
|
||||
add_topic("vehicle_attitude_groundtruth", 10);
|
||||
@@ -740,36 +740,40 @@ void Logger::run()
|
||||
} else {
|
||||
|
||||
// get the logging profile
|
||||
SDLogProfile sdlog_profile = SDLogProfile::DEFAULT;
|
||||
SDLogProfileMask sdlog_profile = SDLogProfileMask::DEFAULT;
|
||||
|
||||
if (_sdlog_profile_handle != PARAM_INVALID) {
|
||||
param_get(_sdlog_profile_handle, &sdlog_profile);
|
||||
}
|
||||
if ((int32_t)sdlog_profile == 0) {
|
||||
PX4_WARN("No logging profile selected. Using default set");
|
||||
sdlog_profile = SDLogProfileMask::DEFAULT;
|
||||
}
|
||||
|
||||
// load appropriate topics for profile
|
||||
if (sdlog_profile == SDLogProfile::DEFAULT) {
|
||||
add_common_topics();
|
||||
add_estimator_replay_topics();
|
||||
// the order matters: if several profiles add the same topic, the logging rate of the last one will be used
|
||||
if (sdlog_profile & SDLogProfileMask::DEFAULT) {
|
||||
add_default_topics();
|
||||
}
|
||||
|
||||
} else if (sdlog_profile == SDLogProfile::THERMAL_CALIBRATION) {
|
||||
if (sdlog_profile & SDLogProfileMask::ESTIMATOR_REPLAY) {
|
||||
add_estimator_replay_topics();
|
||||
}
|
||||
|
||||
if (sdlog_profile & SDLogProfileMask::THERMAL_CALIBRATION) {
|
||||
add_thermal_calibration_topics();
|
||||
}
|
||||
|
||||
} else if (sdlog_profile == SDLogProfile::SYSTEM_IDENTIFICATION) {
|
||||
add_common_topics();
|
||||
if (sdlog_profile & SDLogProfileMask::SYSTEM_IDENTIFICATION) {
|
||||
add_system_identification_topics();
|
||||
}
|
||||
|
||||
} else if (sdlog_profile == SDLogProfile::HIGH_RATE) {
|
||||
add_common_topics();
|
||||
add_estimator_replay_topics();
|
||||
if (sdlog_profile & SDLogProfileMask::HIGH_RATE) {
|
||||
add_high_rate_topics();
|
||||
}
|
||||
|
||||
} else if (sdlog_profile == SDLogProfile::DEBUG_TOPICS) {
|
||||
add_common_topics();
|
||||
if (sdlog_profile & SDLogProfileMask::DEBUG_TOPICS) {
|
||||
add_debug_topics();
|
||||
|
||||
} else {
|
||||
add_common_topics();
|
||||
add_estimator_replay_topics();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,15 +61,20 @@ namespace px4
|
||||
namespace logger
|
||||
{
|
||||
|
||||
enum class SDLogProfile : int32_t {
|
||||
DEFAULT = 0,
|
||||
THERMAL_CALIBRATION,
|
||||
SYSTEM_IDENTIFICATION,
|
||||
HIGH_RATE,
|
||||
DEBUG_TOPICS,
|
||||
N_PROFILES
|
||||
enum class SDLogProfileMask : int32_t {
|
||||
DEFAULT = 1 << 0,
|
||||
ESTIMATOR_REPLAY = 1 << 1,
|
||||
THERMAL_CALIBRATION = 1 << 2,
|
||||
SYSTEM_IDENTIFICATION = 1 << 3,
|
||||
HIGH_RATE = 1 << 4,
|
||||
DEBUG_TOPICS = 1 << 5
|
||||
};
|
||||
|
||||
inline bool operator&(SDLogProfileMask a, SDLogProfileMask b)
|
||||
{
|
||||
return static_cast<int32_t>(a) & static_cast<int32_t>(b);
|
||||
}
|
||||
|
||||
struct LoggerSubscription {
|
||||
int fd[ORB_MULTI_MAX_INSTANCES];
|
||||
uint16_t msg_ids[ORB_MULTI_MAX_INSTANCES];
|
||||
@@ -268,7 +273,7 @@ private:
|
||||
*/
|
||||
int add_topics_from_file(const char *fname);
|
||||
|
||||
void add_common_topics();
|
||||
void add_default_topics();
|
||||
void add_estimator_replay_topics();
|
||||
void add_thermal_calibration_topics();
|
||||
void add_system_identification_topics();
|
||||
|
||||
@@ -71,22 +71,33 @@ PARAM_DEFINE_INT32(SDLOG_MODE, 0);
|
||||
/**
|
||||
* Logging Topic Profile
|
||||
*
|
||||
* Selects a set of topics appropriate for specific tasks.
|
||||
* This is an integer bitmask controlling the set and rates of logged topics.
|
||||
* The default allows for general log analysis and estimator replay, while
|
||||
* keeping the log file size reasonably small.
|
||||
*
|
||||
* This parameter is only for the new logger (SYS_LOGGER=1).
|
||||
* Enabling multiple sets leads to higher bandwidth requirements and larger log
|
||||
* files.
|
||||
*
|
||||
* @value 0 default
|
||||
* @value 1 thermal calibration
|
||||
* @value 2 system identification
|
||||
* @value 3 high rate
|
||||
* @value 4 debug topics
|
||||
* Set bits in the following positions to enable:
|
||||
* 0 : Set to true to use the default set (used for general log analysis)
|
||||
* 1 : Set to true to enable estimator (EKF2) replay topics
|
||||
* 2 : Set to true to enable topics for thermal calibration (raw IMU sensor data)
|
||||
* 3 : Set to true to enable topics for system identification (high rate actuator control and IMU data)
|
||||
* 4 : Set to true to enable full rates for analysis of fast maneuvers (RC, attitude, rates and actuators)
|
||||
* 5 : Set to true to enable debugging topics (debug_*.msg topics, for custom code)
|
||||
*
|
||||
* @min 0
|
||||
* @max 4
|
||||
* @max 63
|
||||
* @bit 0 default set (log analysis)
|
||||
* @bit 1 estimator replay (EKF2)
|
||||
* @bit 2 thermal calibration
|
||||
* @bit 3 system identification
|
||||
* @bit 4 high rate
|
||||
* @bit 5 debug
|
||||
* @reboot_required true
|
||||
* @group SD Logging
|
||||
*/
|
||||
PARAM_DEFINE_INT32(SDLOG_PROFILE, 0);
|
||||
PARAM_DEFINE_INT32(SDLOG_PROFILE, 3);
|
||||
|
||||
/**
|
||||
* Maximum number of log directories to keep
|
||||
|
||||
Reference in New Issue
Block a user