Skip to content

Commit 2656150

Browse files
authored
feat(metrics): make it possible to hide graph for each metrics (autowarefoundation#64)
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent be9ef42 commit 2656150

File tree

5 files changed

+79
-6
lines changed

5 files changed

+79
-6
lines changed

evaluation/tier4_metrics_rviz_plugin/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ ament_auto_package(
2828
INSTALL_TO_SHARE
2929
icons
3030
plugins
31+
config
3132
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
curvature:
2+
table: true
3+
graph: false
4+
point_interval:
5+
table: true
6+
graph: false
7+
length:
8+
table: true
9+
graph: false
10+
duration:
11+
table: true
12+
graph: false
13+
velocity:
14+
table: true
15+
graph: false
16+
acceleration:
17+
table: true
18+
graph: false
19+
jerk:
20+
table: true
21+
graph: false
22+
lateral_deviation:
23+
table: true
24+
graph: false
25+
yaw_deviation:
26+
table: true
27+
graph: false
28+
velocity_deviation:
29+
table: true
30+
graph: false
31+
stability:
32+
table: true
33+
graph: false
34+
stability_frechet:
35+
table: true
36+
graph: false
37+
obstacle_distance:
38+
table: true
39+
graph: false
40+
obstacle_ttc:
41+
table: true
42+
graph: false
43+
modified_goal_longitudinal_deviation:
44+
table: true
45+
graph: false
46+
modified_goal_lateral_deviation:
47+
table: true
48+
graph: false
49+
modified_goal_yaw_deviation:
50+
table: true
51+
graph: false

evaluation/tier4_metrics_rviz_plugin/include/metrics_visualize_panel.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
#include <diagnostic_msgs/msg/diagnostic_array.hpp>
3737

38+
#include <yaml-cpp/yaml.h>
39+
3840
#include <iostream>
3941
#include <limits>
4042
#include <string>
@@ -244,6 +246,9 @@ private Q_SLOTS:
244246
// Stored metrics data
245247
std::unordered_map<std::string, Metric> metrics_;
246248

249+
// Metrics configuration
250+
YAML::Node config_;
251+
247252
// Utility functions for managing widget visibility based on topics
248253
void updateWidgetVisibility(const std::string & target_topic, const bool show);
249254
void showCurrentTopicWidgets();

evaluation/tier4_metrics_rviz_plugin/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<depend>qtbase5-dev</depend>
2323
<depend>rclcpp</depend>
2424
<depend>rviz_common</depend>
25+
<depend>yaml-cpp</depend>
2526

2627
<test_depend>ament_lint_auto</test_depend>
2728
<test_depend>autoware_lint_common</test_depend>

evaluation/tier4_metrics_rviz_plugin/src/metrics_visualize_panel.cpp

+21-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "metrics_visualize_panel.hpp"
1717

18+
#include <ament_index_cpp/get_package_share_directory.hpp>
1819
#include <rviz_common/display_context.hpp>
1920

2021
#include <X11/Xlib.h>
@@ -95,6 +96,11 @@ void MetricsVisualizePanel::onInitialize()
9596

9697
const auto period = std::chrono::milliseconds(static_cast<int64_t>(1e3 / 10));
9798
timer_ = raw_node_->create_wall_timer(period, [&]() { onTimer(); });
99+
100+
const std::string yaml_filepath =
101+
ament_index_cpp::get_package_share_directory("tier4_metrics_rviz_plugin") +
102+
"/config/metrics_visualize_panel.param.yaml";
103+
config_ = YAML::LoadFile(yaml_filepath);
98104
}
99105

100106
void MetricsVisualizePanel::updateWidgetVisibility(
@@ -224,12 +230,21 @@ void MetricsVisualizePanel::onMetrics(
224230
QGridLayout * all_metrics_layout = dynamic_cast<QGridLayout *>(all_metrics_widget->layout());
225231

226232
// Add the widgets to the "All Metrics" tab layout
227-
all_metrics_layout->addWidget(tableWidget, row, col);
228-
all_metrics_layout->setRowStretch(row, false);
229-
all_metrics_layout->addWidget(chartViewWidget, row + 1, col);
230-
all_metrics_layout->setRowStretch(row + 1, true);
231-
all_metrics_layout->setColumnStretch(col, true);
232-
233+
try {
234+
if (config_[status.name]["table"].as<bool>()) {
235+
all_metrics_layout->addWidget(tableWidget, row, col);
236+
}
237+
238+
if (config_[status.name]["graph"].as<bool>()) {
239+
all_metrics_layout->addWidget(chartViewWidget, row + 1, col);
240+
}
241+
242+
all_metrics_layout->setRowStretch(row, false);
243+
all_metrics_layout->setRowStretch(row + 1, true);
244+
all_metrics_layout->setColumnStretch(col, true);
245+
} catch (const YAML::Exception & e) {
246+
std::cerr << "YAML error: " << e.what() << std::endl;
247+
}
233248
// Also add the widgets to the topic_widgets_map_ for easy management
234249
topic_widgets_map_[topic_name][status.name] = std::make_pair(tableWidget, chartViewWidget);
235250
}

0 commit comments

Comments
 (0)