diff --git a/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp b/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp index 7513ea6..a3194f1 100644 --- a/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp +++ b/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp @@ -245,18 +245,38 @@ bool FastDdsDataStreamer::timeSeriesCreation() std::vector numeric_series = fastdds_handler_.numeric_data_series_names(); for (const auto& series : numeric_series) { + std::size_t char_id = series.find_first_of("/"); + std::string topic_name = series.substr(0U, char_id); + std::string series_name = series.substr(char_id); + + if (plot_groups_.end() == plot_groups_.find(topic_name)) + { + // Create plotjuggler group + DEBUG("Creating plotjuggler group: " << topic_name); + plot_groups_.insert({topic_name, std::make_shared(topic_name)}); + } // Create a series - DEBUG("Creating numeric series: " << series); - dataMap().addNumeric(series); + DEBUG("Creating numeric series: " << series_name); + dataMap().addNumeric(series_name, plot_groups_.at(topic_name)); } // STRING std::vector string_series = fastdds_handler_.string_data_series_names(); for (const auto& series : string_series) { + std::size_t char_id = series.find_first_of("/"); + std::string topic_name = series.substr(0U, char_id); + std::string series_name = series.substr(char_id); + + if (plot_groups_.end() == plot_groups_.find(topic_name)) + { + // Create plotjuggler group + DEBUG("Creating plotjuggler group: " << topic_name); + plot_groups_.insert({topic_name, std::make_shared(topic_name)}); + } // Create a series - DEBUG("Creating string series: " << series); - dataMap().addStringSeries(series); + DEBUG("Creating string series: " << series_name); + dataMap().addStringSeries(series_name, plot_groups_.at(topic_name)); } return true; } diff --git a/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.hpp b/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.hpp index 2bb08ba..8b8b791 100644 --- a/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.hpp +++ b/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.hpp @@ -148,6 +148,8 @@ class FastDdsDataStreamer : bool running_; constexpr static const char* CONFIGURATION_SETTINGS_PREFIX_ = "FastDDSVisualizerPlugin"; + + std::unordered_map> plot_groups_; }; } /* namespace datastreamer */