mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-14 20:51:36 +08:00
logger: introduce optional topics
The current practice of adding topics to the default set isn't scalable, as it affects all setups. By making sure topics are advertised on init, logger can just discard topics that don't exist. This does not work for all topics, so topics are specifically marked as optional. It can be extended to more topics later on though. This reduces the list of topics by ~35 on a pixracer configured as quad, and reduces RAM usage by ~1KB.
This commit is contained in:
@@ -107,9 +107,15 @@ private:
|
||||
* @param name topic name
|
||||
* @param interval limit in milliseconds if >0, otherwise log as fast as the topic is updated.
|
||||
* @param instance orb topic instance
|
||||
* @param optional if true, the topic is only added if it exists
|
||||
* @return true on success
|
||||
*/
|
||||
bool add_topic(const char *name, uint16_t interval_ms = 0, uint8_t instance = 0);
|
||||
bool add_topic(const char *name, uint16_t interval_ms = 0, uint8_t instance = 0, bool optional = false);
|
||||
|
||||
bool add_optional_topic(const char *name, uint16_t interval_ms = 0, uint8_t instance = 0)
|
||||
{
|
||||
return add_topic(name, interval_ms, instance, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a topic to be logged.
|
||||
@@ -117,9 +123,17 @@ private:
|
||||
* @param interval limit in milliseconds if >0, otherwise log as fast as the topic is updated.
|
||||
* @param instance orb topic instance
|
||||
* @param max_num_instances the max multi-instance to add.
|
||||
* @param optional if true, the topic is only added if it exists
|
||||
* @return true on success
|
||||
*/
|
||||
bool add_topic_multi(const char *name, uint16_t interval_ms = 0, uint8_t max_num_instances = ORB_MULTI_MAX_INSTANCES);
|
||||
bool add_topic_multi(const char *name, uint16_t interval_ms = 0, uint8_t max_num_instances = ORB_MULTI_MAX_INSTANCES,
|
||||
bool optional = false);
|
||||
|
||||
bool add_optional_topic_multi(const char *name, uint16_t interval_ms = 0,
|
||||
uint8_t max_num_instances = ORB_MULTI_MAX_INSTANCES)
|
||||
{
|
||||
return add_topic_multi(name, interval_ms, max_num_instances, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a file containing a list of uORB topics to log, calling add_topic for each
|
||||
@@ -157,7 +171,7 @@ private:
|
||||
* add a logged topic (called by add_topic() above).
|
||||
* @return true on success
|
||||
*/
|
||||
bool add_topic(const orb_metadata *topic, uint16_t interval_ms = 0, uint8_t instance = 0);
|
||||
bool add_topic(const orb_metadata *topic, uint16_t interval_ms = 0, uint8_t instance = 0, bool optional = false);
|
||||
|
||||
RequestedSubscriptionArray _subscriptions;
|
||||
int _num_mission_subs{0};
|
||||
|
||||
Reference in New Issue
Block a user