diff --git a/mock/cpp_mock_scenarios/launch/mock_test.launch.py b/mock/cpp_mock_scenarios/launch/mock_test.launch.py index 07474b2928f..4b4b4573caf 100644 --- a/mock/cpp_mock_scenarios/launch/mock_test.launch.py +++ b/mock/cpp_mock_scenarios/launch/mock_test.launch.py @@ -151,9 +151,9 @@ def generate_launch_description(): arguments=[("__log_level:=warn")], ), Node( - package="openscenario_visualization", - executable="openscenario_visualization_node", - name="openscenario_visualization_node", + package="traffic_simulator", + executable="visualization_node", + name="visualizer", output="screen", ), Node( diff --git a/openscenario/openscenario_visualization/CHANGELOG.rst b/rviz_plugins/openscenario_visualization/CHANGELOG.rst similarity index 100% rename from openscenario/openscenario_visualization/CHANGELOG.rst rename to rviz_plugins/openscenario_visualization/CHANGELOG.rst diff --git a/openscenario/openscenario_visualization/CMakeLists.txt b/rviz_plugins/openscenario_visualization/CMakeLists.txt similarity index 79% rename from openscenario/openscenario_visualization/CMakeLists.txt rename to rviz_plugins/openscenario_visualization/CMakeLists.txt index c58057ffdbe..459e794f473 100644 --- a/openscenario/openscenario_visualization/CMakeLists.txt +++ b/rviz_plugins/openscenario_visualization/CMakeLists.txt @@ -35,15 +35,6 @@ include_directories(include SYSTEM ${OGRE_INCLUDE_DIRS}) -ament_auto_add_library(openscenario_visualization_component SHARED - src/openscenario_visualization_component.cpp -) - -ament_auto_add_executable(openscenario_visualization_node - src/openscenario_visualization_node.cpp -) -target_link_libraries(openscenario_visualization_node openscenario_visualization_component) - add_definitions(-DQT_NO_KEYWORDS) qt5_wrap_ui(UIC_FILES src/ui/context_panel_plugin.ui) @@ -63,10 +54,6 @@ target_include_directories(openscenario_visualization_rviz_plugin PRIVATE "${OGR install(DIRECTORY icons DESTINATION share/openscenario_visualization) install(DIRECTORY include/ DESTINATION include) -ament_export_libraries(openscenario_visualization_component) - -rclcpp_components_register_nodes(openscenario_visualization_component "openscenario_visualization::OpenscenarioVisualizationComponent") - if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) ament_lint_auto_find_test_dependencies() diff --git a/openscenario/openscenario_visualization/icons/classes/ContextPanel.png b/rviz_plugins/openscenario_visualization/icons/classes/ContextPanel.png similarity index 100% rename from openscenario/openscenario_visualization/icons/classes/ContextPanel.png rename to rviz_plugins/openscenario_visualization/icons/classes/ContextPanel.png diff --git a/openscenario/openscenario_visualization/img/rviz.png b/rviz_plugins/openscenario_visualization/img/rviz.png similarity index 100% rename from openscenario/openscenario_visualization/img/rviz.png rename to rviz_plugins/openscenario_visualization/img/rviz.png diff --git a/openscenario/openscenario_visualization/include/openscenario_visualization/context_panel_plugin.hpp b/rviz_plugins/openscenario_visualization/include/openscenario_visualization/context_panel_plugin.hpp similarity index 100% rename from openscenario/openscenario_visualization/include/openscenario_visualization/context_panel_plugin.hpp rename to rviz_plugins/openscenario_visualization/include/openscenario_visualization/context_panel_plugin.hpp diff --git a/openscenario/openscenario_visualization/include/openscenario_visualization_condition_groups_plugin/jsk_overlay_utils.hpp b/rviz_plugins/openscenario_visualization/include/openscenario_visualization_condition_groups_plugin/jsk_overlay_utils.hpp similarity index 100% rename from openscenario/openscenario_visualization/include/openscenario_visualization_condition_groups_plugin/jsk_overlay_utils.hpp rename to rviz_plugins/openscenario_visualization/include/openscenario_visualization_condition_groups_plugin/jsk_overlay_utils.hpp diff --git a/openscenario/openscenario_visualization/include/openscenario_visualization_condition_groups_plugin/openscenario_visualization_condition_groups_plugin.hpp b/rviz_plugins/openscenario_visualization/include/openscenario_visualization_condition_groups_plugin/openscenario_visualization_condition_groups_plugin.hpp similarity index 100% rename from openscenario/openscenario_visualization/include/openscenario_visualization_condition_groups_plugin/openscenario_visualization_condition_groups_plugin.hpp rename to rviz_plugins/openscenario_visualization/include/openscenario_visualization_condition_groups_plugin/openscenario_visualization_condition_groups_plugin.hpp diff --git a/openscenario/openscenario_visualization/package.xml b/rviz_plugins/openscenario_visualization/package.xml similarity index 100% rename from openscenario/openscenario_visualization/package.xml rename to rviz_plugins/openscenario_visualization/package.xml diff --git a/openscenario/openscenario_visualization/plugins.xml b/rviz_plugins/openscenario_visualization/plugins.xml similarity index 100% rename from openscenario/openscenario_visualization/plugins.xml rename to rviz_plugins/openscenario_visualization/plugins.xml diff --git a/openscenario/openscenario_visualization/src/context_panel_plugin.cpp b/rviz_plugins/openscenario_visualization/src/context_panel_plugin.cpp similarity index 100% rename from openscenario/openscenario_visualization/src/context_panel_plugin.cpp rename to rviz_plugins/openscenario_visualization/src/context_panel_plugin.cpp diff --git a/openscenario/openscenario_visualization/src/openscenario_visualization_condition_groups_plugin/jsk_overlay_utils.cpp b/rviz_plugins/openscenario_visualization/src/openscenario_visualization_condition_groups_plugin/jsk_overlay_utils.cpp similarity index 100% rename from openscenario/openscenario_visualization/src/openscenario_visualization_condition_groups_plugin/jsk_overlay_utils.cpp rename to rviz_plugins/openscenario_visualization/src/openscenario_visualization_condition_groups_plugin/jsk_overlay_utils.cpp diff --git a/openscenario/openscenario_visualization/src/openscenario_visualization_condition_groups_plugin/openscenario_visualization_condition_groups_plugin.cpp b/rviz_plugins/openscenario_visualization/src/openscenario_visualization_condition_groups_plugin/openscenario_visualization_condition_groups_plugin.cpp similarity index 100% rename from openscenario/openscenario_visualization/src/openscenario_visualization_condition_groups_plugin/openscenario_visualization_condition_groups_plugin.cpp rename to rviz_plugins/openscenario_visualization/src/openscenario_visualization_condition_groups_plugin/openscenario_visualization_condition_groups_plugin.cpp diff --git a/openscenario/openscenario_visualization/src/ui/context_panel_plugin.ui b/rviz_plugins/openscenario_visualization/src/ui/context_panel_plugin.ui similarity index 100% rename from openscenario/openscenario_visualization/src/ui/context_panel_plugin.ui rename to rviz_plugins/openscenario_visualization/src/ui/context_panel_plugin.ui diff --git a/simulation/traffic_simulator/CMakeLists.txt b/simulation/traffic_simulator/CMakeLists.txt index 122d3bd60a9..a561cf83ccf 100644 --- a/simulation/traffic_simulator/CMakeLists.txt +++ b/simulation/traffic_simulator/CMakeLists.txt @@ -58,6 +58,19 @@ ament_auto_add_library(traffic_simulator SHARED src/traffic_lights/traffic_light_publisher.cpp ) +ament_auto_add_library(visualization_component SHARED + src/visualization/visualization_component.cpp +) + +ament_auto_add_executable(visualization_node + src/visualization/visualization_node.cpp +) +target_link_libraries(visualization_node visualization_component) + +ament_export_libraries(visualization_component) + +rclcpp_components_register_nodes(visualization_component "traffic_simulator::VisualizationComponent") + target_link_libraries(traffic_simulator tinyxml2 pugixml diff --git a/simulation/traffic_simulator/include/traffic_simulator/api/api.hpp b/simulation/traffic_simulator/include/traffic_simulator/api/api.hpp index 86843200f1d..1c27a73d5c2 100644 --- a/simulation/traffic_simulator/include/traffic_simulator/api/api.hpp +++ b/simulation/traffic_simulator/include/traffic_simulator/api/api.hpp @@ -286,7 +286,7 @@ class API const lane_change::TrajectoryShape trajectory_shape, const lane_change::Constraint & constraint); -// clang-format off + // clang-format off #define FORWARD_TO_ENTITY_MANAGER(NAME) \ /*! \ @brief Forward to arguments to the EntityManager::NAME function. \ diff --git a/simulation/traffic_simulator/include/traffic_simulator/entity/entity_base.hpp b/simulation/traffic_simulator/include/traffic_simulator/entity/entity_base.hpp index ad9547569dd..a5d52d205a8 100644 --- a/simulation/traffic_simulator/include/traffic_simulator/entity/entity_base.hpp +++ b/simulation/traffic_simulator/include/traffic_simulator/entity/entity_base.hpp @@ -61,7 +61,7 @@ class EntityBase virtual void cancelRequest(); -// clang-format off + // clang-format off #define DEFINE_GETTER(NAME, TYPE, RETURN_VARIABLE) \ /** \ @brief Get NAME of the entity. \ @@ -84,7 +84,7 @@ class EntityBase // clang-format on #undef DEFINE_GETTER -// clang-format off + // clang-format off #define DEFINE_CHECK_FUNCTION(FUNCTION_NAME, BOOL_VARIABLE) \ /** \ @note This function was defined by DEFINE_CHECK_FUNCTION function. \ diff --git a/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp b/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp index 44fb81c32ee..881f34f9d2e 100644 --- a/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp +++ b/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp @@ -243,7 +243,7 @@ class EntityManager } } -// clang-format off + // clang-format off #define FORWARD_TO_HDMAP_UTILS(NAME) \ /*! \ @brief Forward to arguments to the HDMapUtils::NAME function. \ @@ -264,7 +264,7 @@ class EntityManager #undef FORWARD_TO_HDMAP_UTILS -// clang-format off + // clang-format off #define FORWARD_TO_ENTITY(IDENTIFIER, ...) \ /*! \ @brief Forward to arguments to the EntityBase::IDENTIFIER function. \ diff --git a/openscenario/openscenario_visualization/include/openscenario_visualization/openscenario_visualization_component.hpp b/simulation/traffic_simulator/include/traffic_simulator/visualization/visualization_component.hpp similarity index 59% rename from openscenario/openscenario_visualization/include/openscenario_visualization/openscenario_visualization_component.hpp rename to simulation/traffic_simulator/include/traffic_simulator/visualization/visualization_component.hpp index fd60a6ef788..f136192e043 100644 --- a/openscenario/openscenario_visualization/include/openscenario_visualization/openscenario_visualization_component.hpp +++ b/simulation/traffic_simulator/include/traffic_simulator/visualization/visualization_component.hpp @@ -16,8 +16,8 @@ * @brief definition of visualizer component */ -#ifndef OPENSCENARIO_VISUALIZATION__OPENSCENARIO_VISUALIZATION_COMPONENT_HPP_ -#define OPENSCENARIO_VISUALIZATION__OPENSCENARIO_VISUALIZATION_COMPONENT_HPP_ +#ifndef TRAFFIC_SIMULATOR__VISUALIZATION__VISUALIZATION_COMPONENT_HPP_ +#define TRAFFIC_SIMULATOR__VISUALIZATION__VISUALIZATION_COMPONENT_HPP_ #if __cplusplus extern "C" { @@ -27,38 +27,33 @@ extern "C" { // demos/composition/include/composition/visibility_control.h at https://github.com/ros2/demos #if defined _WIN32 || defined __CYGWIN__ #ifdef __GNUC__ -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_EXPORT \ - __attribute__((dllexport)) -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_IMPORT \ - __attribute__((dllimport)) +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_EXPORT __attribute__((dllexport)) +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_IMPORT __attribute__((dllimport)) #else -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_EXPORT __declspec(dllexport) -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_IMPORT __declspec(dllimport) +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_EXPORT __declspec(dllexport) +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_IMPORT __declspec(dllimport) #endif -#ifdef OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_BUILDING_DLL -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC \ - OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_EXPORT +#ifdef TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_BUILDING_DLL +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC \ + TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_EXPORT #else -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC \ - OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_IMPORT +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC \ + TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_IMPORT #endif -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC_TYPE \ - OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_LOCAL +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC_TYPE \ + TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_LOCAL #else -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_EXPORT \ - __attribute__((visibility("default"))) -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_IMPORT +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_EXPORT __attribute__((visibility("default"))) +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_IMPORT #if __GNUC__ >= 4 -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC \ - __attribute__((visibility("default"))) -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_LOCAL \ - __attribute__((visibility("hidden"))) +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC __attribute__((visibility("default"))) +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_LOCAL __attribute__((visibility("hidden"))) #else -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_LOCAL +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_LOCAL #endif -#define OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC_TYPE +#define TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC_TYPE #endif #if __cplusplus @@ -72,16 +67,16 @@ extern "C" { #include #include -namespace openscenario_visualization +namespace traffic_simulator { /** * @brief ROS 2 component for visualizing simulation result. */ -class OpenscenarioVisualizationComponent : public rclcpp::Node +class VisualizationComponent : public rclcpp::Node { public: - OPENSCENARIO_VISUALIZATION_OPENSCENARIO_VISUALIZATION_COMPONENT_PUBLIC - explicit OpenscenarioVisualizationComponent(const rclcpp::NodeOptions &); + TRAFFIC_SIMULATOR_VISUALIZATION_COMPONENT_PUBLIC + explicit VisualizationComponent(const rclcpp::NodeOptions &); private: /** @@ -128,6 +123,6 @@ class OpenscenarioVisualizationComponent : public rclcpp::Node */ std::unordered_map markers_; }; -} // namespace openscenario_visualization +} // namespace traffic_simulator -#endif // OPENSCENARIO_VISUALIZATION__OPENSCENARIO_VISUALIZATION_COMPONENT_HPP_ +#endif // TRAFFIC_SIMULATOR__VISUALIZATION__VISUALIZATION_COMPONENT_HPP_ diff --git a/openscenario/openscenario_visualization/src/openscenario_visualization_component.cpp b/simulation/traffic_simulator/src/visualization/visualization_component.cpp similarity index 95% rename from openscenario/openscenario_visualization/src/openscenario_visualization_component.cpp rename to simulation/traffic_simulator/src/visualization/visualization_component.cpp index 913553e50ff..8e708d367e2 100644 --- a/openscenario/openscenario_visualization/src/openscenario_visualization_component.cpp +++ b/simulation/traffic_simulator/src/visualization/visualization_component.cpp @@ -48,26 +48,25 @@ #include #include #include -#include +#include #include #include +#include #include -namespace openscenario_visualization +namespace traffic_simulator { -OpenscenarioVisualizationComponent::OpenscenarioVisualizationComponent( - const rclcpp::NodeOptions & options) -: Node("openscenario_visualization", options) +VisualizationComponent::VisualizationComponent(const rclcpp::NodeOptions & options) +: Node("visualization", options) { marker_pub_ = create_publisher("entity/marker", 1); entity_status_sub_ = this->create_subscription( "entity/status", 1, - std::bind( - &OpenscenarioVisualizationComponent::entityStatusCallback, this, std::placeholders::_1)); + std::bind(&VisualizationComponent::entityStatusCallback, this, std::placeholders::_1)); } -void OpenscenarioVisualizationComponent::entityStatusCallback( +void VisualizationComponent::entityStatusCallback( const traffic_simulator_msgs::msg::EntityStatusWithTrajectoryArray::ConstSharedPtr msg) { visualization_msgs::msg::MarkerArray current_marker; @@ -100,7 +99,7 @@ void OpenscenarioVisualizationComponent::entityStatusCallback( marker_pub_->publish(current_marker); } -const visualization_msgs::msg::MarkerArray OpenscenarioVisualizationComponent::generateDeleteMarker( +const visualization_msgs::msg::MarkerArray VisualizationComponent::generateDeleteMarker( std::string ns) { auto ret = visualization_msgs::msg::MarkerArray(); @@ -117,7 +116,7 @@ const visualization_msgs::msg::MarkerArray OpenscenarioVisualizationComponent::g return ret; } -const visualization_msgs::msg::MarkerArray OpenscenarioVisualizationComponent::generateMarker( +const visualization_msgs::msg::MarkerArray VisualizationComponent::generateMarker( const traffic_simulator_msgs::msg::EntityStatus & status, const std::vector & goal_pose, const traffic_simulator_msgs::msg::WaypointsArray & waypoints, @@ -449,8 +448,7 @@ const visualization_msgs::msg::MarkerArray OpenscenarioVisualizationComponent::g return ret; } -const visualization_msgs::msg::MarkerArray -OpenscenarioVisualizationComponent::generateDeleteMarker() const +const visualization_msgs::msg::MarkerArray VisualizationComponent::generateDeleteMarker() const { visualization_msgs::msg::MarkerArray ret; visualization_msgs::msg::Marker marker; @@ -458,6 +456,6 @@ OpenscenarioVisualizationComponent::generateDeleteMarker() const ret.markers.emplace_back(marker); return ret; } -} // namespace openscenario_visualization +} // namespace traffic_simulator -RCLCPP_COMPONENTS_REGISTER_NODE(openscenario_visualization::OpenscenarioVisualizationComponent) +RCLCPP_COMPONENTS_REGISTER_NODE(traffic_simulator::VisualizationComponent) diff --git a/openscenario/openscenario_visualization/src/openscenario_visualization_node.cpp b/simulation/traffic_simulator/src/visualization/visualization_node.cpp similarity index 89% rename from openscenario/openscenario_visualization/src/openscenario_visualization_node.cpp rename to simulation/traffic_simulator/src/visualization/visualization_node.cpp index afd9a99134d..dc768ad887e 100644 --- a/openscenario/openscenario_visualization/src/openscenario_visualization_node.cpp +++ b/simulation/traffic_simulator/src/visualization/visualization_node.cpp @@ -42,15 +42,14 @@ */ #include -#include #include +#include int main(int argc, char * argv[]) { rclcpp::init(argc, argv); rclcpp::NodeOptions options; - auto component = - std::make_shared(options); + auto component = std::make_shared(options); rclcpp::spin(component->get_node_base_interface()); rclcpp::shutdown(); return 0; diff --git a/test_runner/random_test_runner/launch/random_test.launch.py b/test_runner/random_test_runner/launch/random_test.launch.py index 7d67f58c712..55cb1629cbc 100644 --- a/test_runner/random_test_runner/launch/random_test.launch.py +++ b/test_runner/random_test_runner/launch/random_test.launch.py @@ -218,10 +218,10 @@ def launch_setup(self, context, *args, **kwargs): scenario_node, RegisterEventHandler(event_handler=shutdown_handler), Node( - package="openscenario_visualization", - executable="openscenario_visualization_node", + package="traffic_simulator", + executable="visualization_node", namespace="simulation", - name="openscenario_visualizer", + name="visualizer", output="screen", ), ] diff --git a/test_runner/scenario_test_runner/launch/scenario_test_runner.launch.py b/test_runner/scenario_test_runner/launch/scenario_test_runner.launch.py index 674f01d8666..dc95b256dfc 100755 --- a/test_runner/scenario_test_runner/launch/scenario_test_runner.launch.py +++ b/test_runner/scenario_test_runner/launch/scenario_test_runner.launch.py @@ -203,10 +203,10 @@ def description(): on_exit=ShutdownOnce(), ), Node( - package="openscenario_visualization", - executable="openscenario_visualization_node", + package="traffic_simulator", + executable="visualization_node", namespace="simulation", - name="openscenario_visualizer", + name="visualizer", output="screen", ), Node(