diff --git a/common/tier4_string_viewer_rviz_plugin/CMakeLists.txt b/common/tier4_string_viewer_rviz_plugin/CMakeLists.txt new file mode 100644 index 000000000..410cddc62 --- /dev/null +++ b/common/tier4_string_viewer_rviz_plugin/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.14) +project(tier4_string_viewer_rviz_plugin) + +find_package(autoware_cmake REQUIRED) +autoware_package() + +find_package(Qt5 REQUIRED Core Widgets) +set(QT_LIBRARIES Qt5::Widgets) +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +add_definitions(-DQT_NO_KEYWORDS) + +ament_auto_add_library(${PROJECT_NAME} SHARED + src/string_viewer_panel.hpp + src/string_viewer_panel.cpp +) +target_link_libraries(${PROJECT_NAME} + ${QT_LIBRARIES} +) +pluginlib_export_plugin_description_file(rviz_common plugins/plugin_description.xml) + +ament_auto_package( + INSTALL_TO_SHARE + icons + plugins +) diff --git a/common/tier4_string_viewer_rviz_plugin/README.md b/common/tier4_string_viewer_rviz_plugin/README.md new file mode 100644 index 000000000..b483155b3 --- /dev/null +++ b/common/tier4_string_viewer_rviz_plugin/README.md @@ -0,0 +1,16 @@ +# tier4_datetime_rviz_plugin + +## Purpose + +This plugin displays the ROS Time and Wall Time in rviz. + +## Assumptions / Known limits + +TBD. + +## Usage + +1. Start rviz and select panels/Add new panel. + ![select_panel](./images/select_panels.png) +2. Select tier4_datetime_rviz_plugin/AutowareDateTimePanel and press OK. + ![select_datetime_plugin](./images/select_datetime_plugin.png) diff --git a/common/tier4_string_viewer_rviz_plugin/icons/classes/AutowareDateTimePanel.png b/common/tier4_string_viewer_rviz_plugin/icons/classes/AutowareDateTimePanel.png new file mode 100644 index 000000000..9431c2d42 Binary files /dev/null and b/common/tier4_string_viewer_rviz_plugin/icons/classes/AutowareDateTimePanel.png differ diff --git a/common/tier4_string_viewer_rviz_plugin/images/select_datetime_plugin.png b/common/tier4_string_viewer_rviz_plugin/images/select_datetime_plugin.png new file mode 100644 index 000000000..6485b9737 Binary files /dev/null and b/common/tier4_string_viewer_rviz_plugin/images/select_datetime_plugin.png differ diff --git a/common/tier4_string_viewer_rviz_plugin/images/select_panels.png b/common/tier4_string_viewer_rviz_plugin/images/select_panels.png new file mode 100644 index 000000000..a691602c4 Binary files /dev/null and b/common/tier4_string_viewer_rviz_plugin/images/select_panels.png differ diff --git a/common/tier4_string_viewer_rviz_plugin/package.xml b/common/tier4_string_viewer_rviz_plugin/package.xml new file mode 100644 index 000000000..c07950e1a --- /dev/null +++ b/common/tier4_string_viewer_rviz_plugin/package.xml @@ -0,0 +1,28 @@ + + + + tier4_string_viewer_rviz_plugin + 0.0.0 + The tier4_string_viewer_rviz_plugin package + Takagi, Isamu + Apache License 2.0 + + ament_cmake_auto + autoware_cmake + + libqt5-core + libqt5-gui + libqt5-widgets + qtbase5-dev + rclcpp + rviz_common + tier4_debug_msgs + + ament_lint_auto + autoware_lint_common + + + ament_cmake + + + diff --git a/common/tier4_string_viewer_rviz_plugin/plugins/plugin_description.xml b/common/tier4_string_viewer_rviz_plugin/plugins/plugin_description.xml new file mode 100644 index 000000000..61be94ce2 --- /dev/null +++ b/common/tier4_string_viewer_rviz_plugin/plugins/plugin_description.xml @@ -0,0 +1,9 @@ + + + + StringViewerPanel + + + diff --git a/common/tier4_string_viewer_rviz_plugin/src/string_viewer_panel.cpp b/common/tier4_string_viewer_rviz_plugin/src/string_viewer_panel.cpp new file mode 100644 index 000000000..12ef68ab1 --- /dev/null +++ b/common/tier4_string_viewer_rviz_plugin/src/string_viewer_panel.cpp @@ -0,0 +1,49 @@ +// Copyright 2024 TIER IV, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "string_viewer_panel.hpp" + +#include +#include +#include + +#include + +StringViewerPanel::StringViewerPanel(QWidget * parent) : rviz_common::Panel(parent) +{ + contents_ = new QLabel; + + auto * layout = new QHBoxLayout(this); + layout->addWidget(contents_); + setLayout(layout); +} + +void StringViewerPanel::onInitialize() +{ + raw_node_ = this->getDisplayContext()->getRosNodeAbstraction().lock()->get_raw_node(); + + sub_string_ = raw_node_->create_subscription( + "/planning/scenario_planning/lane_driving/behavior_planning/behavior_path_planner/debug/" + "internal_state", + rclcpp::QoS{1}, std::bind(&StringViewerPanel::on_string, this, std::placeholders::_1)); +} + +void StringViewerPanel::on_string(const tier4_debug_msgs::msg::StringStamped::ConstSharedPtr msg) +{ + contents_->setText(msg->data.c_str()); + contents_->setWordWrap(true); +} + +#include +PLUGINLIB_EXPORT_CLASS(StringViewerPanel, rviz_common::Panel) diff --git a/common/tier4_string_viewer_rviz_plugin/src/string_viewer_panel.hpp b/common/tier4_string_viewer_rviz_plugin/src/string_viewer_panel.hpp new file mode 100644 index 000000000..f56956ebc --- /dev/null +++ b/common/tier4_string_viewer_rviz_plugin/src/string_viewer_panel.hpp @@ -0,0 +1,46 @@ +// Copyright 2024 TIER IV, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef STRING_VIEWER_PANEL_HPP_ +#define STRING_VIEWER_PANEL_HPP_ + +#include +#include +#include +#include + +#include + +class QLineEdit; + +class StringViewerPanel : public rviz_common::Panel +{ + Q_OBJECT + +public: + explicit StringViewerPanel(QWidget * parent = nullptr); + + void onInitialize() override; + +private: + void on_string(const tier4_debug_msgs::msg::StringStamped::ConstSharedPtr msg); + + QLabel * contents_; + + rclcpp::Node::SharedPtr raw_node_; + + rclcpp::Subscription::SharedPtr sub_string_; +}; + +#endif // STRING_VIEWER_PANEL_HPP_