Skip to content

Commit

Permalink
Use PlotGroups explicitly
Browse files Browse the repository at this point in the history
If this commit is applied then plotJuggler groups will be used instead
of series so that if a topic is keyed then it is easy to add its
instance to the group.
Stored all groups pointer into an unordered map so that I can find back
the group based on topic names.

Note that I have used default separator "/", might be an issue if it
changes.

Issue: [eProsima#56]
Signed-off-by: Manuel Valch <manuelValch@proton.me>
  • Loading branch information
manuelValch committed Jun 15, 2024
1 parent 9b48a51 commit 8066b70
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
28 changes: 24 additions & 4 deletions plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,38 @@ bool FastDdsDataStreamer::timeSeriesCreation()
std::vector<types::DatumLabel> 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<PJ::PlotGroup>(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<types::DatumLabel> 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<PJ::PlotGroup>(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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ class FastDdsDataStreamer :
bool running_;

constexpr static const char* CONFIGURATION_SETTINGS_PREFIX_ = "FastDDSVisualizerPlugin";

std::unordered_map<std::string, std::shared_ptr<PJ::PlotGroup>> plot_groups_;
};

} /* namespace datastreamer */
Expand Down

0 comments on commit 8066b70

Please sign in to comment.