diff --git a/plotjuggler_plugins/PluginsZcm/config_zcm.cpp b/plotjuggler_plugins/PluginsZcm/config_zcm.cpp
index f93b9169b..5234d31e8 100644
--- a/plotjuggler_plugins/PluginsZcm/config_zcm.cpp
+++ b/plotjuggler_plugins/PluginsZcm/config_zcm.cpp
@@ -53,6 +53,11 @@ QString ConfigZCM::getLibraries() const
}
}
+QString ConfigZCM::getDataPrefix() const
+{
+ return ui->lineEditDataPrefix->text();
+}
+
void ConfigZCM::on_radioEnvironmentLibrary_toggled(bool checked)
{
if (checked)
diff --git a/plotjuggler_plugins/PluginsZcm/config_zcm.h b/plotjuggler_plugins/PluginsZcm/config_zcm.h
index 442795730..04a05e80c 100644
--- a/plotjuggler_plugins/PluginsZcm/config_zcm.h
+++ b/plotjuggler_plugins/PluginsZcm/config_zcm.h
@@ -16,6 +16,7 @@ class ConfigZCM : public QWidget
~ConfigZCM();
QString getLibraries() const;
+ QString getDataPrefix() const;
private slots:
void on_radioEnvironmentLibrary_toggled(bool checked);
diff --git a/plotjuggler_plugins/PluginsZcm/config_zcm.ui b/plotjuggler_plugins/PluginsZcm/config_zcm.ui
index 2aefbd8d2..5d69185d2 100644
--- a/plotjuggler_plugins/PluginsZcm/config_zcm.ui
+++ b/plotjuggler_plugins/PluginsZcm/config_zcm.ui
@@ -7,13 +7,13 @@
0
0
553
- 264
+ 200
Form
-
+
0
@@ -26,6 +26,49 @@
0
+ -
+
+
-
+
+
+ <html><head/><body><p><span style=" font-weight:700;">Data Prefix:</span></p></body></html>
+
+
+
+ -
+
+
+
+ 200
+ 26
+
+
+
+
+ 100
+ 28
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
-
@@ -78,6 +121,9 @@
-
+
+ QAbstractScrollArea::AdjustToContents
+
QAbstractItemView::NoEditTriggers
@@ -137,12 +183,6 @@
Qt::Vertical
-
-
- 20
- 40
-
-
diff --git a/plotjuggler_plugins/PluginsZcm/dataload_zcm.cpp b/plotjuggler_plugins/PluginsZcm/dataload_zcm.cpp
index 9cfd44342..0002b2864 100644
--- a/plotjuggler_plugins/PluginsZcm/dataload_zcm.cpp
+++ b/plotjuggler_plugins/PluginsZcm/dataload_zcm.cpp
@@ -28,7 +28,9 @@ DataLoadZcm::DataLoadZcm()
_ui->setupUi(_dialog);
_config_widget = new ConfigZCM("DataLoadZcm", _dialog);
+ _config_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
_ui->mainLayout->insertWidget(0, _config_widget, 1);
+ _ui->mainLayout->setStretchFactor(_config_widget, 0);
_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
@@ -269,6 +271,8 @@ bool DataLoadZcm::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_data
vector> strings;
ProcessUsr usr = { numerics, strings };
+ string prefix = _config_widget->getDataPrefix().toStdString() + "/";
+
auto processEvent = [&](const zcm::LogEvent* evt) {
if (_selected_channels.find(evt->channel) == _selected_channels.end())
{
@@ -277,9 +281,10 @@ bool DataLoadZcm::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_data
if (evt->datalen == 0)
{
- auto itr = plot_data.numeric.find(evt->channel);
+ string chan(prefix + evt->channel);
+ auto itr = plot_data.numeric.find(chan);
if (itr == plot_data.numeric.end())
- itr = plot_data.addNumeric(evt->channel);
+ itr = plot_data.addNumeric(chan);
itr->second.pushBack({ (double)evt->timestamp / 1e6, 0 });
return;
}
@@ -288,16 +293,18 @@ bool DataLoadZcm::readDataFromFile(FileLoadInfo* info, PlotDataMapRef& plot_data
types, processData, &usr);
for (auto& n : usr.numerics)
{
- auto itr = plot_data.numeric.find(n.first);
+ string chan(prefix + n.first);
+ auto itr = plot_data.numeric.find(chan);
if (itr == plot_data.numeric.end())
- itr = plot_data.addNumeric(n.first);
+ itr = plot_data.addNumeric(chan);
itr->second.pushBack({ (double)evt->timestamp / 1e6, n.second });
}
for (auto& s : usr.strings)
{
- auto itr = plot_data.strings.find(s.first);
+ string chan(prefix + s.first);
+ auto itr = plot_data.strings.find(chan);
if (itr == plot_data.strings.end())
- itr = plot_data.addStringSeries(s.first);
+ itr = plot_data.addStringSeries(chan);
itr->second.pushBack({ (double)evt->timestamp / 1e6, s.second });
}
diff --git a/plotjuggler_plugins/PluginsZcm/datastream_zcm.cpp b/plotjuggler_plugins/PluginsZcm/datastream_zcm.cpp
index 131e0c696..8febd2627 100644
--- a/plotjuggler_plugins/PluginsZcm/datastream_zcm.cpp
+++ b/plotjuggler_plugins/PluginsZcm/datastream_zcm.cpp
@@ -131,6 +131,7 @@ bool DataStreamZcm::start(QStringList*)
}
}
+ _prefix = _config_widget->getDataPrefix().toStdString() + "/";
_zcm->start();
_running = true;
return true;
@@ -227,24 +228,27 @@ void DataStreamZcm::handler(const zcm::ReceiveBuffer* rbuf, const string& channe
{
zcm::Introspection::processEncodedType(channel, rbuf->data, rbuf->data_size, "/",
*_types.get(), processData, this);
+
{
std::lock_guard lock(mutex());
for (auto& n : _numerics)
{
- auto itr = dataMap().numeric.find(n.first);
+ auto chan = _prefix + n.first;
+ auto itr = dataMap().numeric.find(chan);
if (itr == dataMap().numeric.end())
{
- itr = dataMap().addNumeric(n.first);
+ itr = dataMap().addNumeric(chan);
}
itr->second.pushBack({ double(rbuf->recv_utime) / 1e6, n.second });
}
for (auto& s : _strings)
{
- auto itr = dataMap().strings.find(s.first);
+ auto chan = _prefix + s.first;
+ auto itr = dataMap().strings.find(chan);
if (itr == dataMap().strings.end())
{
- itr = dataMap().addStringSeries(s.first);
+ itr = dataMap().addStringSeries(chan);
}
itr->second.pushBack({ double(rbuf->recv_utime) / 1e6, s.second });
}
diff --git a/plotjuggler_plugins/PluginsZcm/datastream_zcm.h b/plotjuggler_plugins/PluginsZcm/datastream_zcm.h
index 86233e729..1449f3915 100644
--- a/plotjuggler_plugins/PluginsZcm/datastream_zcm.h
+++ b/plotjuggler_plugins/PluginsZcm/datastream_zcm.h
@@ -54,6 +54,7 @@ private slots:
void handler(const zcm::ReceiveBuffer* rbuf, const std::string& channel);
+ std::string _prefix;
bool _running;
QString _types_library;
QString _subscribe_string;