Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metrics_visualize_panel): make it possible to hide graph for each metrics #64

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions evaluation/tier4_metrics_rviz_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ ament_auto_package(
INSTALL_TO_SHARE
icons
plugins
config
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
curvature:
table: true
graph: false
point_interval:
table: true
graph: false
length:
table: true
graph: false
duration:
table: true
graph: false
velocity:
table: true
graph: false
acceleration:
table: true
graph: false
jerk:
table: true
graph: false
lateral_deviation:
table: true
graph: false
yaw_deviation:
table: true
graph: false
velocity_deviation:
table: true
graph: false
stability:
table: true
graph: false
stability_frechet:
table: true
graph: false
obstacle_distance:
table: true
graph: false
obstacle_ttc:
table: true
graph: false
modified_goal_longitudinal_deviation:
table: true
graph: false
modified_goal_lateral_deviation:
table: true
graph: false
modified_goal_yaw_deviation:
table: true
graph: false
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#include <diagnostic_msgs/msg/diagnostic_array.hpp>

#include <yaml-cpp/yaml.h>

#include <iostream>
#include <limits>
#include <string>
Expand Down Expand Up @@ -244,6 +246,9 @@ private Q_SLOTS:
// Stored metrics data
std::unordered_map<std::string, Metric> metrics_;

// Metrics configuration
YAML::Node config_;

// Utility functions for managing widget visibility based on topics
void updateWidgetVisibility(const std::string & target_topic, const bool show);
void showCurrentTopicWidgets();
Expand Down
1 change: 1 addition & 0 deletions evaluation/tier4_metrics_rviz_plugin/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<depend>qtbase5-dev</depend>
<depend>rclcpp</depend>
<depend>rviz_common</depend>
<depend>yaml-cpp</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "metrics_visualize_panel.hpp"

#include <ament_index_cpp/get_package_share_directory.hpp>
#include <rviz_common/display_context.hpp>

#include <X11/Xlib.h>
Expand Down Expand Up @@ -95,6 +96,11 @@

const auto period = std::chrono::milliseconds(static_cast<int64_t>(1e3 / 10));
timer_ = raw_node_->create_wall_timer(period, [&]() { onTimer(); });

const std::string yaml_filepath =
ament_index_cpp::get_package_share_directory("tier4_metrics_rviz_plugin") +
"/config/metrics_visualize_panel.param.yaml";
config_ = YAML::LoadFile(yaml_filepath);

Check warning on line 103 in evaluation/tier4_metrics_rviz_plugin/src/metrics_visualize_panel.cpp

View check run for this annotation

Codecov / codecov/patch

evaluation/tier4_metrics_rviz_plugin/src/metrics_visualize_panel.cpp#L101-L103

Added lines #L101 - L103 were not covered by tests
}

void MetricsVisualizePanel::updateWidgetVisibility(
Expand Down Expand Up @@ -224,12 +230,21 @@
QGridLayout * all_metrics_layout = dynamic_cast<QGridLayout *>(all_metrics_widget->layout());

// Add the widgets to the "All Metrics" tab layout
all_metrics_layout->addWidget(tableWidget, row, col);
all_metrics_layout->setRowStretch(row, false);
all_metrics_layout->addWidget(chartViewWidget, row + 1, col);
all_metrics_layout->setRowStretch(row + 1, true);
all_metrics_layout->setColumnStretch(col, true);

try {
if (config_[status.name]["table"].as<bool>()) {
all_metrics_layout->addWidget(tableWidget, row, col);

Check warning on line 235 in evaluation/tier4_metrics_rviz_plugin/src/metrics_visualize_panel.cpp

View check run for this annotation

Codecov / codecov/patch

evaluation/tier4_metrics_rviz_plugin/src/metrics_visualize_panel.cpp#L234-L235

Added lines #L234 - L235 were not covered by tests
}

if (config_[status.name]["graph"].as<bool>()) {
all_metrics_layout->addWidget(chartViewWidget, row + 1, col);

Check warning on line 239 in evaluation/tier4_metrics_rviz_plugin/src/metrics_visualize_panel.cpp

View check run for this annotation

Codecov / codecov/patch

evaluation/tier4_metrics_rviz_plugin/src/metrics_visualize_panel.cpp#L238-L239

Added lines #L238 - L239 were not covered by tests
}

all_metrics_layout->setRowStretch(row, false);
all_metrics_layout->setRowStretch(row + 1, true);
all_metrics_layout->setColumnStretch(col, true);
} catch (const YAML::Exception & e) {
std::cerr << "YAML error: " << e.what() << std::endl;
}

Check warning on line 247 in evaluation/tier4_metrics_rviz_plugin/src/metrics_visualize_panel.cpp

View check run for this annotation

Codecov / codecov/patch

evaluation/tier4_metrics_rviz_plugin/src/metrics_visualize_panel.cpp#L242-L247

Added lines #L242 - L247 were not covered by tests
// Also add the widgets to the topic_widgets_map_ for easy management
topic_widgets_map_[topic_name][status.name] = std::make_pair(tableWidget, chartViewWidget);
}
Expand Down
Loading