diff --git a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp index 40b33d38b..8bc9a86bc 100644 --- a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp +++ b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp @@ -114,6 +114,10 @@ class DDSRECORDER_YAML_DllAPI RecorderConfiguration const Yaml& yml, const ddspipe::yaml::YamlReaderVersion& version); + void load_output_configuration_( + const Yaml& yml, + const ddspipe::yaml::YamlReaderVersion& version); + void load_controller_configuration_( const Yaml& yml, const ddspipe::yaml::YamlReaderVersion& version); diff --git a/ddsrecorder_yaml/src/cpp/recorder/YamlReader.cpp b/ddsrecorder_yaml/src/cpp/recorder/YamlReader.cpp index 88c487386..5e472ec65 100644 --- a/ddsrecorder_yaml/src/cpp/recorder/YamlReader.cpp +++ b/ddsrecorder_yaml/src/cpp/recorder/YamlReader.cpp @@ -15,6 +15,7 @@ #include #include +#include #include @@ -30,6 +31,14 @@ YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + const std::set tags = { + RECORDER_COMPRESSION_SETTINGS_ALGORITHM_TAG, + RECORDER_COMPRESSION_SETTINGS_LEVEL_TAG, + RECORDER_COMPRESSION_SETTINGS_FORCE_TAG, + }; + + YamlValidator::validate_tags(yml, tags); + mcap::McapWriterOptions mcap_writer_options{"ros2"}; // Parse optional compression algorithm diff --git a/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp b/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp index ed0a56a68..f2f991055 100644 --- a/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp +++ b/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -122,6 +123,14 @@ void RecorderConfiguration::load_ddsrecorder_configuration_( recorder_configuration->app_metadata = ""; recorder_configuration->is_repeater = false; + const std::set tags{ + RECORDER_RECORDER_TAG, + SPECS_TAG, + RECORDER_DDS_TAG, + RECORDER_REMOTE_CONTROLLER_TAG}; + + YamlValidator::validate_tags(yml, tags); + ///// // Get optional Recorder configuration options if (YamlReader::is_tag_present(yml, RECORDER_RECORDER_TAG)) @@ -136,7 +145,6 @@ void RecorderConfiguration::load_ddsrecorder_configuration_( ///// // Get optional specs configuration - // WARNING: Parse builtin topics (dds tag) AFTER specs, as some topic-specific default values are set there if (YamlReader::is_tag_present(yml, SPECS_TAG)) { auto specs_yml = YamlReader::get_value_in_tag(yml, SPECS_TAG); @@ -153,7 +161,7 @@ void RecorderConfiguration::load_ddsrecorder_configuration_( // Block ROS 2 services (RPC) topics // RATIONALE: - // At the time of this writting, services in ROS 2 behave in the following manner: a ROS 2 service + // At the time of this writing, services in ROS 2 behave in the following manner: a ROS 2 service // client awaits to discover a server, and it is then when a request is sent to this (and only this) server, // from which a response is expected. // Hence, if these topics are not blocked, the client would wrongly believe DDS-Recorder is a server, thus @@ -210,6 +218,18 @@ void RecorderConfiguration::load_recorder_configuration_( const Yaml& yml, const YamlReaderVersion& version) { + const std::set tags{ + RECORDER_OUTPUT_TAG, + RECORDER_BUFFER_SIZE_TAG, + RECORDER_EVENT_WINDOW_TAG, + RECORDER_LOG_PUBLISH_TIME_TAG, + RECORDER_ONLY_WITH_TYPE_TAG, + RECORDER_COMPRESSION_SETTINGS_TAG, + RECORDER_RECORD_TYPES_TAG, + RECORDER_ROS2_TYPES_TAG}; + + YamlValidator::validate_tags(yml, tags); + if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_TAG)) { auto output_yml = YamlReader::get_value_in_tag(yml, RECORDER_OUTPUT_TAG); @@ -337,10 +357,60 @@ void RecorderConfiguration::load_recorder_configuration_( } } +void RecorderConfiguration::load_output_configuration_( + const Yaml& yml, + const YamlReaderVersion& version) +{ + const std::set tags{ + RECORDER_OUTPUT_PATH_FILE_TAG, + RECORDER_OUTPUT_FILE_NAME_TAG, + RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG, + RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG}; + + YamlValidator::validate_tags(yml, tags); + + ///// + // Get optional file path + if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_PATH_FILE_TAG)) + { + output_filepath = YamlReader::get(yml, RECORDER_OUTPUT_PATH_FILE_TAG, version); + } + + ///// + // Get optional file name + if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_FILE_NAME_TAG)) + { + output_filename = YamlReader::get(yml, RECORDER_OUTPUT_FILE_NAME_TAG, version); + } + + ///// + // Get optional timestamp format + if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG)) + { + output_timestamp_format = YamlReader::get(yml, RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG, version); + } + + ///// + // Get optional timestamp format + if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG)) + { + output_local_timestamp = YamlReader::get(yml, RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG, version); + } +} + void RecorderConfiguration::load_controller_configuration_( const Yaml& yml, const YamlReaderVersion& version) { + const std::set tags{ + RECORDER_REMOTE_CONTROLLER_ENABLE_TAG, + DOMAIN_ID_TAG, + RECORDER_REMOTE_CONTROLLER_INITIAL_STATE_TAG, + RECORDER_REMOTE_CONTROLLER_COMMAND_TOPIC_NAME_TAG, + RECORDER_REMOTE_CONTROLLER_STATUS_TOPIC_NAME_TAG}; + + YamlValidator::validate_tags(yml, tags); + // Get optional enable remote controller if (YamlReader::is_tag_present(yml, RECORDER_REMOTE_CONTROLLER_ENABLE_TAG)) { @@ -383,6 +453,14 @@ void RecorderConfiguration::load_specs_configuration_( const Yaml& yml, const YamlReaderVersion& version) { + const std::set tags{ + NUMBER_THREADS_TAG, + SPECS_QOS_TAG, + RECORDER_SPECS_MAX_PENDING_SAMPLES_TAG, + RECORDER_SPECS_CLEANUP_PERIOD_TAG}; + + YamlValidator::validate_tags(yml, tags); + // Get number of threads if (YamlReader::is_tag_present(yml, NUMBER_THREADS_TAG)) { @@ -393,7 +471,7 @@ void RecorderConfiguration::load_specs_configuration_( // Get optional Topic QoS if (YamlReader::is_tag_present(yml, SPECS_QOS_TAG)) { - YamlReader::fill(topic_qos, YamlReader::get_value_in_tag(yml, SPECS_QOS_TAG), version); + topic_qos = YamlReader::get(yml, SPECS_QOS_TAG, version); TopicQoS::default_topic_qos.set_value(topic_qos); } @@ -401,6 +479,7 @@ void RecorderConfiguration::load_specs_configuration_( if (YamlReader::is_tag_present(yml, RECORDER_SPECS_MAX_PENDING_SAMPLES_TAG)) { max_pending_samples = YamlReader::get(yml, RECORDER_SPECS_MAX_PENDING_SAMPLES_TAG, version); + if (max_pending_samples < -1) { throw eprosima::utils::ConfigurationException( @@ -434,6 +513,18 @@ void RecorderConfiguration::load_dds_configuration_( const Yaml& yml, const YamlReaderVersion& version) { + const std::set tags{ + DOMAIN_ID_TAG, + WHITELIST_INTERFACES_TAG, + TRANSPORT_DESCRIPTORS_TRANSPORT_TAG, + IGNORE_PARTICIPANT_FLAGS_TAG, + ALLOWLIST_TAG, + BLOCKLIST_TAG, + TOPICS_TAG, + BUILTIN_TAG}; + + YamlValidator::validate_tags(yml, tags); + // Get optional DDS domain if (YamlReader::is_tag_present(yml, DOMAIN_ID_TAG)) {