Class DataAccessManager

Class Documentation

class DataAccessManager

Public Functions

explicit DataAccessManager(rclcpp::Node *node)
json publish_to_topic(const std::string &topic_path, const std::string &msg_type, const json &data, double timeout_sec = 5.0)

Publish data to a specific topic.

Parameters:
  • topic_path – Full topic path (e.g., /chassis/brakes/command)

  • msg_type – ROS 2 message type (e.g., std_msgs/msg/Float32)

  • data – JSON data to publish

  • timeout_sec – Timeout for the publish operation

Returns:

JSON with publish status

json get_topic_sample_with_fallback(const std::string &topic_name, double timeout_sec = -1.0)

Get topic sample with fallback to metadata on timeout.

If the topic is publishing, returns actual data with type info. If the topic times out, returns metadata (type, schema, pub/sub counts) instead of error.

Parameters:
  • topic_name – Full topic path (e.g., “/powertrain/engine/temperature”)

  • timeout_sec – Timeout for data retrieval. Use -1.0 to use the topic_sample_timeout_sec parameter (default)

Throws:

TopicNotAvailableException – if topic doesn’t exist or metadata cannot be retrieved

Returns:

JSON object with one of two structures:

  • status=”data”: {topic, timestamp, data, status, type, type_info, publisher_count, subscriber_count}

  • status=”metadata_only”: {topic, timestamp, status, type, type_info, publisher_count, subscriber_count}

inline TypeIntrospection *get_type_introspection() const

Get the type introspection instance.

inline NativeTopicSampler *get_native_sampler() const

Get the native topic sampler instance.

Used by DiscoveryManager to build component-topic mappings.

json get_topic_sample_native(const std::string &topic_name, double timeout_sec = 1.0)

Get single topic sample using native rclcpp APIs.

Fast path for single topic sampling with publisher count check.

Parameters:
  • topic_name – Full topic path

  • timeout_sec – Timeout for sampling (only used if topic has publishers)

Returns:

JSON with topic data or metadata

inline double get_topic_sample_timeout() const

Get the configured topic sample timeout.

Returns:

Timeout in seconds for topic sampling