diff --git a/rviz_common/include/rviz_common/ros_integration/ros_node_abstraction.hpp b/rviz_common/include/rviz_common/ros_integration/ros_node_abstraction.hpp index fba133344..cebe73029 100644 --- a/rviz_common/include/rviz_common/ros_integration/ros_node_abstraction.hpp +++ b/rviz_common/include/rviz_common/ros_integration/ros_node_abstraction.hpp @@ -37,7 +37,11 @@ #include #include -#include "rclcpp/rclcpp.hpp" +// Use targeted headers instead of rclcpp/rclcpp.hpp: +// rclcpp/node.hpp — for rclcpp::Node::SharedPtr +// rclcpp/node_options.hpp — for rclcpp::NodeOptions constructor parameter +#include "rclcpp/node.hpp" +#include "rclcpp/node_options.hpp" #include "rviz_common/ros_integration/ros_node_abstraction_iface.hpp" #include "rviz_common/visibility_control.hpp" diff --git a/rviz_common/include/rviz_common/ros_integration/ros_node_abstraction_iface.hpp b/rviz_common/include/rviz_common/ros_integration/ros_node_abstraction_iface.hpp index 43b81a73c..fce3423b0 100644 --- a/rviz_common/include/rviz_common/ros_integration/ros_node_abstraction_iface.hpp +++ b/rviz_common/include/rviz_common/ros_integration/ros_node_abstraction_iface.hpp @@ -37,7 +37,9 @@ #include #include -#include "rclcpp/rclcpp.hpp" +// Only rclcpp::Node::SharedPtr is needed here — use the narrow header +// instead of rclcpp/rclcpp.hpp to minimize transitive includes for all consumers. +#include "rclcpp/node.hpp" namespace rviz_common { diff --git a/rviz_common/include/rviz_common/view_controller.hpp b/rviz_common/include/rviz_common/view_controller.hpp index 04d020d99..492386acd 100644 --- a/rviz_common/include/rviz_common/view_controller.hpp +++ b/rviz_common/include/rviz_common/view_controller.hpp @@ -42,8 +42,8 @@ #include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here -#include -#include +// rclcpp/service.hpp and std_srvs are intentionally excluded from this public header. +// reset_time_srv_ is stored as std::shared_ptr and cast in view_controller.cpp. #include "rviz_common/properties/property.hpp" #include "rviz_common/visibility_control.hpp" @@ -286,12 +286,9 @@ private Q_SLOTS: // Default cursors for the most common actions QMap standard_cursors_; - rclcpp::Service::SharedPtr reset_time_srv_; - - void resetService( - const std::shared_ptr, - const std::shared_ptr, - const std::shared_ptr); + // Type-erased service handle — concrete type is rclcpp::Service. + // Stored as void to avoid pulling rclcpp/service.hpp + std_srvs into this public header. + std::shared_ptr reset_time_srv_; }; } // namespace rviz_common diff --git a/rviz_common/include/rviz_common/visualization_manager.hpp b/rviz_common/include/rviz_common/visualization_manager.hpp index 55483ad9c..e3af9df45 100644 --- a/rviz_common/include/rviz_common/visualization_manager.hpp +++ b/rviz_common/include/rviz_common/visualization_manager.hpp @@ -38,8 +38,10 @@ #include // NOLINT: cpplint is unable to handle the include order here #include "rclcpp/clock.hpp" +#include "rclcpp/executors/single_threaded_executor.hpp" #include "rclcpp/time.hpp" -#include "tf2_ros/transform_listener.hpp" +// tf2_ros/transform_listener.hpp is not included here — TransformListener only +// appears in a doc comment. Include it in the .cpp file if needed. #include "rviz_common/bit_allocator.hpp" #include "rviz_common/config.hpp" diff --git a/rviz_common/src/rviz_common/view_controller.cpp b/rviz_common/src/rviz_common/view_controller.cpp index 85ffbe216..a9610e84f 100644 --- a/rviz_common/src/rviz_common/view_controller.cpp +++ b/rviz_common/src/rviz_common/view_controller.cpp @@ -28,7 +28,6 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. - #include "rviz_common/view_controller.hpp" #include @@ -43,6 +42,9 @@ #include "rviz_rendering/render_window.hpp" +#include "rclcpp/service.hpp" +#include "std_srvs/srv/empty.hpp" + #include "rviz_common/display_context.hpp" #include "rviz_common/load_resource.hpp" #include "rviz_common/properties/bool_property.hpp" @@ -132,11 +134,16 @@ void ViewController::initialize(DisplayContext * context) auto ros_node_abstraction = context_->getRosNodeAbstraction().lock(); if (ros_node_abstraction) { auto node = ros_node_abstraction->get_raw_node(); + // Store as std::shared_ptr so rclcpp/service.hpp stays out of the public header. reset_time_srv_ = node->create_service( ros_node_abstraction->get_node_name() + "/reset_time", - std::bind( - &ViewController::resetService, this, - std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + [this]( + const std::shared_ptr, + const std::shared_ptr, + const std::shared_ptr) + { + resetTime(); + }); } } @@ -251,14 +258,6 @@ void ViewController::handleKeyEvent(QKeyEvent * event, RenderPanel * panel) } } -void ViewController::resetService( - const std::shared_ptr, - const std::shared_ptr, - const std::shared_ptr) -{ - resetTime(); -} - void ViewController::resetTime() { rviz_common::VisualizationManager * vis_manager = diff --git a/rviz_default_plugins/CMakeLists.txt b/rviz_default_plugins/CMakeLists.txt index 11ea5b205..824942634 100644 --- a/rviz_default_plugins/CMakeLists.txt +++ b/rviz_default_plugins/CMakeLists.txt @@ -247,6 +247,7 @@ set(rviz_default_plugins_source_files src/rviz_default_plugins/view_controllers/orbit/orbit_view_controller.cpp src/rviz_default_plugins/view_controllers/ortho/fixed_orientation_ortho_view_controller.cpp src/rviz_default_plugins/view_controllers/xy_orbit/xy_orbit_view_controller.cpp + src/rviz_default_plugins/view_controllers/view_controller_registration.cpp ) add_library(rviz_default_plugins SHARED diff --git a/rviz_default_plugins/include/rviz_default_plugins/tools/focus/focus_tool.hpp b/rviz_default_plugins/include/rviz_default_plugins/tools/focus/focus_tool.hpp index e4215aa50..04d1a3b76 100644 --- a/rviz_default_plugins/include/rviz_default_plugins/tools/focus/focus_tool.hpp +++ b/rviz_default_plugins/include/rviz_default_plugins/tools/focus/focus_tool.hpp @@ -31,6 +31,8 @@ #ifndef RVIZ_DEFAULT_PLUGINS__TOOLS__FOCUS__FOCUS_TOOL_HPP_ #define RVIZ_DEFAULT_PLUGINS__TOOLS__FOCUS__FOCUS_TOOL_HPP_ +#include // Ogre::Vector3 used in processMouseEvent/setStatusFrom signatures + #include #include "rviz_common/tool.hpp" diff --git a/rviz_default_plugins/include/rviz_default_plugins/transformation/tf_wrapper.hpp b/rviz_default_plugins/include/rviz_default_plugins/transformation/tf_wrapper.hpp index 984d9c12f..cc3dda6a1 100644 --- a/rviz_default_plugins/include/rviz_default_plugins/transformation/tf_wrapper.hpp +++ b/rviz_default_plugins/include/rviz_default_plugins/transformation/tf_wrapper.hpp @@ -35,14 +35,29 @@ #include #include -#include "tf2_ros/buffer.hpp" -#include "tf2_ros/create_timer_ros.hpp" -#include "tf2_ros/transform_listener.hpp" -#include "tf2_geometry_msgs/tf2_geometry_msgs.hpp" +// Minimal tf2 headers — only what the public API actually needs. +// Heavy impl headers (buffer.hpp, transform_listener.hpp, create_timer_ros.hpp, +// tf2_geometry_msgs.hpp) are included in tf_wrapper.cpp only. +#include "geometry_msgs/msg/pose_stamped.hpp" +#include "geometry_msgs/msg/transform_stamped.hpp" +#include "tf2/time.hpp" +#include "tf2_ros/async_buffer_interface.hpp" // TransformStampedFuture, TransformReadyCallback #include "rviz_common/transformation/frame_transformer.hpp" #include "rviz_default_plugins/visibility_control.hpp" +namespace tf2_ros +{ +class Buffer; +class TransformListener; +} // namespace tf2_ros + +namespace rclcpp +{ +class Clock; +class Node; +} // namespace rclcpp + namespace rviz_default_plugins { namespace transformation diff --git a/rviz_default_plugins/src/rviz_default_plugins/displays/laser_scan/laser_scan_display.cpp b/rviz_default_plugins/src/rviz_default_plugins/displays/laser_scan/laser_scan_display.cpp index 451148398..ccdddfa9f 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/displays/laser_scan/laser_scan_display.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/displays/laser_scan/laser_scan_display.cpp @@ -35,7 +35,7 @@ #include // NOLINT: cpplint is unable to handle the include order here -#include "tf2_ros/buffer.hpp" +#include "tf2/exceptions.hpp" #include "rviz_common/properties/int_property.hpp" #include "rviz_common/properties/status_property.hpp" diff --git a/rviz_default_plugins/src/rviz_default_plugins/displays/robot_model/robot_model_display.cpp b/rviz_default_plugins/src/rviz_default_plugins/displays/robot_model/robot_model_display.cpp index c35e6e175..45644006f 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/displays/robot_model/robot_model_display.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/displays/robot_model/robot_model_display.cpp @@ -40,7 +40,7 @@ #include // NOLINT: cpplint is unable to handle the include order here -#include "tf2_ros/transform_listener.hpp" +// tf2_ros/transform_listener.hpp removed: no tf2_ros:: types used directly here. #include "rviz_common/display_context.hpp" #include "rviz_common/properties/enum_property.hpp" diff --git a/rviz_default_plugins/src/rviz_default_plugins/displays/tf/tf_display.cpp b/rviz_default_plugins/src/rviz_default_plugins/displays/tf/tf_display.cpp index 351f8e029..fe0e97164 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/displays/tf/tf_display.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/displays/tf/tf_display.cpp @@ -48,7 +48,9 @@ #include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint cannot handle the include order here -#include "tf2_ros/transform_listener.hpp" +// tf2_ros/buffer.hpp needed: getBuffer() returns shared_ptr which +// is assigned to shared_ptr — requires full inheritance knowledge. +// tf2_ros/transform_listener.hpp removed: no TransformListener types used here. #include "tf2_ros/buffer.hpp" #include "rviz_rendering/objects/arrow.hpp" diff --git a/rviz_default_plugins/src/rviz_default_plugins/transformation/tf_wrapper.cpp b/rviz_default_plugins/src/rviz_default_plugins/transformation/tf_wrapper.cpp index 75f77ff51..8b738a4e7 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/transformation/tf_wrapper.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/transformation/tf_wrapper.cpp @@ -35,6 +35,15 @@ #include #include +// Full tf2 implementation headers — intentionally kept out of tf_wrapper.hpp. +#include "tf2_geometry_msgs/tf2_geometry_msgs.hpp" +#include "tf2_ros/buffer.hpp" +#include "tf2_ros/create_timer_ros.hpp" +#include "tf2_ros/transform_listener.hpp" + +#include "rclcpp/clock.hpp" +#include "rclcpp/node.hpp" + namespace rviz_default_plugins { namespace transformation diff --git a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/follower/third_person_follower_view_controller.cpp b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/follower/third_person_follower_view_controller.cpp index 0a5fd4c37..168f1a296 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/follower/third_person_follower_view_controller.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/follower/third_person_follower_view_controller.cpp @@ -58,9 +58,3 @@ void ThirdPersonFollowerViewController::updateTargetSceneNode() } // namespace view_controllers } // namespace rviz_default_plugins - -#include // NOLINT(build/include_order) - -PLUGINLIB_EXPORT_CLASS( - rviz_default_plugins::view_controllers::ThirdPersonFollowerViewController, - rviz_common::ViewController) diff --git a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/fps/fps_view_controller.cpp b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/fps/fps_view_controller.cpp index a206f9df7..ba76ab366 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/fps/fps_view_controller.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/fps/fps_view_controller.cpp @@ -260,7 +260,3 @@ void FPSViewController::move(float x, float y, float z) // NOLINT (this is not } } // namespace view_controllers } // namespace rviz_default_plugins - -#include // NOLINT(build/include_order) -PLUGINLIB_EXPORT_CLASS( - rviz_default_plugins::view_controllers::FPSViewController, rviz_common::ViewController) diff --git a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/frame/frame_view_controller.cpp b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/frame/frame_view_controller.cpp index 7fe901091..20cc7dc17 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/frame/frame_view_controller.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/frame/frame_view_controller.cpp @@ -165,7 +165,3 @@ void FrameViewController::onTargetFrameChanged( } // namespace view_controllers } // namespace rviz_default_plugins - -#include // NOLINT(build/include_order) -PLUGINLIB_EXPORT_CLASS( - rviz_default_plugins::view_controllers::FrameViewController, rviz_common::ViewController) diff --git a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/orbit/orbit_view_controller.cpp b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/orbit/orbit_view_controller.cpp index 68e4053ec..aa9198949 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/orbit/orbit_view_controller.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/orbit/orbit_view_controller.cpp @@ -394,7 +394,3 @@ void OrbitViewController::move(float x, float y, float z) // NOLINT(build/inclu } // namespace view_controllers } // namespace rviz_default_plugins - -#include // NOLINT(build/include_order) -PLUGINLIB_EXPORT_CLASS( - rviz_default_plugins::view_controllers::OrbitViewController, rviz_common::ViewController) diff --git a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/ortho/fixed_orientation_ortho_view_controller.cpp b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/ortho/fixed_orientation_ortho_view_controller.cpp index 4db913ec8..f3ec3db38 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/ortho/fixed_orientation_ortho_view_controller.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/ortho/fixed_orientation_ortho_view_controller.cpp @@ -232,8 +232,3 @@ void FixedOrientationOrthoViewController::move(float dx, float dy) } // namespace view_controllers } // namespace rviz_default_plugins - -#include // NOLINT(build/include_order) -PLUGINLIB_EXPORT_CLASS( - rviz_default_plugins::view_controllers::FixedOrientationOrthoViewController, - rviz_common::ViewController) diff --git a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/view_controller_registration.cpp b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/view_controller_registration.cpp new file mode 100644 index 000000000..72f65b685 --- /dev/null +++ b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/view_controller_registration.cpp @@ -0,0 +1,57 @@ +// Copyright (c) 2024, Open Source Robotics Foundation, Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +// Consolidated pluginlib exports for all view controllers. +// Keeping PLUGINLIB_EXPORT_CLASS in a single TU means pluginlib/class_list_macros.hpp +// (~347 headers) is parsed exactly once instead of once per view controller .cpp file. + +#include "rviz_default_plugins/view_controllers/follower/third_person_follower_view_controller.hpp" +#include "rviz_default_plugins/view_controllers/fps/fps_view_controller.hpp" +#include "rviz_default_plugins/view_controllers/frame/frame_view_controller.hpp" +#include "rviz_default_plugins/view_controllers/orbit/orbit_view_controller.hpp" +#include "rviz_default_plugins/view_controllers/ortho/fixed_orientation_ortho_view_controller.hpp" +#include "rviz_default_plugins/view_controllers/xy_orbit/xy_orbit_view_controller.hpp" + +#include // NOLINT(build/include_order) + +PLUGINLIB_EXPORT_CLASS( + rviz_default_plugins::view_controllers::ThirdPersonFollowerViewController, + rviz_common::ViewController) +PLUGINLIB_EXPORT_CLASS( + rviz_default_plugins::view_controllers::FPSViewController, rviz_common::ViewController) +PLUGINLIB_EXPORT_CLASS( + rviz_default_plugins::view_controllers::FrameViewController, rviz_common::ViewController) +PLUGINLIB_EXPORT_CLASS( + rviz_default_plugins::view_controllers::OrbitViewController, rviz_common::ViewController) +PLUGINLIB_EXPORT_CLASS( + rviz_default_plugins::view_controllers::FixedOrientationOrthoViewController, + rviz_common::ViewController) +PLUGINLIB_EXPORT_CLASS( + rviz_default_plugins::view_controllers::XYOrbitViewController, + rviz_common::ViewController) diff --git a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/xy_orbit/xy_orbit_view_controller.cpp b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/xy_orbit/xy_orbit_view_controller.cpp index 122847341..9ad9b0fb8 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/view_controllers/xy_orbit/xy_orbit_view_controller.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/view_controllers/xy_orbit/xy_orbit_view_controller.cpp @@ -230,8 +230,3 @@ void XYOrbitViewController::handleMouseEvent(rviz_common::ViewportMouseEvent & e } // namespace view_controllers } // namespace rviz_default_plugins - -#include // NOLINT -PLUGINLIB_EXPORT_CLASS( - rviz_default_plugins::view_controllers::XYOrbitViewController, - rviz_common::ViewController) diff --git a/rviz_visual_testing_framework/include/rviz_visual_testing_framework/visual_test_fixture.hpp b/rviz_visual_testing_framework/include/rviz_visual_testing_framework/visual_test_fixture.hpp index 98a2739ed..8c6c7e887 100644 --- a/rviz_visual_testing_framework/include/rviz_visual_testing_framework/visual_test_fixture.hpp +++ b/rviz_visual_testing_framework/include/rviz_visual_testing_framework/visual_test_fixture.hpp @@ -34,18 +34,16 @@ #include #include -#include "rclcpp/rclcpp.hpp" -#include "rclcpp/clock.hpp" -#include "std_msgs/msg/header.hpp" -#include "geometry_msgs/msg/transform_stamped.hpp" -#include "tf2/LinearMath/Quaternion.hpp" -#include "tf2_ros/static_transform_broadcaster.hpp" +// NOTE: rclcpp, tf2_ros, geometry_msgs, std_msgs are NOT included here intentionally. +// VisualTestFixture itself uses none of those types. Tests that publish messages +// should include visual_test_publisher.hpp or transform_publisher.hpp directly. #include "rviz_visual_testing_framework/internal/display_handler.hpp" #include "rviz_visual_testing_framework/internal/executor.hpp" #include "rviz_visual_testing_framework/internal/visual_test.hpp" #include "rviz_visual_testing_framework/page_objects/page_object_with_window.hpp" + class VisualTestFixture : public testing::Test { public: