Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
#include <string>
#include <vector>

#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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
#include <string>
#include <vector>

#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
{
Expand Down
13 changes: 5 additions & 8 deletions rviz_common/include/rviz_common/view_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#include <QString> // NOLINT: cpplint is unable to handle the include order here
#include <Qt> // NOLINT: cpplint is unable to handle the include order here
#include <QVariant> // NOLINT: cpplint is unable to handle the include order here
#include <rclcpp/service.hpp>
#include <std_srvs/srv/empty.hpp>
// rclcpp/service.hpp and std_srvs are intentionally excluded from this public header.
// reset_time_srv_ is stored as std::shared_ptr<void> and cast in view_controller.cpp.

#include "rviz_common/properties/property.hpp"
#include "rviz_common/visibility_control.hpp"
Expand Down Expand Up @@ -286,12 +286,9 @@ private Q_SLOTS:
// Default cursors for the most common actions
QMap<CursorType, QCursor> standard_cursors_;

rclcpp::Service<std_srvs::srv::Empty>::SharedPtr reset_time_srv_;

void resetService(
const std::shared_ptr<rmw_request_id_t>,
const std::shared_ptr<std_srvs::srv::Empty::Request>,
const std::shared_ptr<std_srvs::srv::Empty::Response>);
// Type-erased service handle — concrete type is rclcpp::Service<std_srvs::srv::Empty>.
// Stored as void to avoid pulling rclcpp/service.hpp + std_srvs into this public header.
std::shared_ptr<void> reset_time_srv_;
};

} // namespace rviz_common
Expand Down
4 changes: 3 additions & 1 deletion rviz_common/include/rviz_common/visualization_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
#include <QString> // 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"
Expand Down
23 changes: 11 additions & 12 deletions rviz_common/src/rviz_common/view_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>
Expand All @@ -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"
Expand Down Expand Up @@ -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<void> so rclcpp/service.hpp stays out of the public header.
reset_time_srv_ = node->create_service<std_srvs::srv::Empty>(
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<rmw_request_id_t>,
const std::shared_ptr<std_srvs::srv::Empty::Request>,
const std::shared_ptr<std_srvs::srv::Empty::Response>)
{
resetTime();
});
}
}

Expand Down Expand Up @@ -251,14 +258,6 @@ void ViewController::handleKeyEvent(QKeyEvent * event, RenderPanel * panel)
}
}

void ViewController::resetService(
const std::shared_ptr<rmw_request_id_t>,
const std::shared_ptr<std_srvs::srv::Empty::Request>,
const std::shared_ptr<std_srvs::srv::Empty::Response>)
{
resetTime();
}

void ViewController::resetTime()
{
rviz_common::VisualizationManager * vis_manager =
Expand Down
1 change: 1 addition & 0 deletions rviz_default_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#ifndef RVIZ_DEFAULT_PLUGINS__TOOLS__FOCUS__FOCUS_TOOL_HPP_
#define RVIZ_DEFAULT_PLUGINS__TOOLS__FOCUS__FOCUS_TOOL_HPP_

#include <OgreVector.h> // Ogre::Vector3 used in processMouseEvent/setStatusFrom signatures

#include <QCursor>

#include "rviz_common/tool.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,29 @@
#include <string>
#include <vector>

#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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include <QString> // 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#include <QString> // 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
#include <QString> // NOLINT: cpplint is unable to handle the include order here
#include <QToolTip> // NOLINT: cpplint cannot handle the include order here

#include "tf2_ros/transform_listener.hpp"
// tf2_ros/buffer.hpp needed: getBuffer() returns shared_ptr<tf2_ros::Buffer> which
// is assigned to shared_ptr<tf2::BufferCore> — 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
#include <string>
#include <vector>

// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,3 @@ void ThirdPersonFollowerViewController::updateTargetSceneNode()

} // namespace view_controllers
} // namespace rviz_default_plugins

#include <pluginlib/class_list_macros.hpp> // NOLINT(build/include_order)

PLUGINLIB_EXPORT_CLASS(
rviz_default_plugins::view_controllers::ThirdPersonFollowerViewController,
rviz_common::ViewController)
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pluginlib/class_list_macros.hpp> // NOLINT(build/include_order)
PLUGINLIB_EXPORT_CLASS(
rviz_default_plugins::view_controllers::FPSViewController, rviz_common::ViewController)
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,3 @@ void FrameViewController::onTargetFrameChanged(

} // namespace view_controllers
} // namespace rviz_default_plugins

#include <pluginlib/class_list_macros.hpp> // NOLINT(build/include_order)
PLUGINLIB_EXPORT_CLASS(
rviz_default_plugins::view_controllers::FrameViewController, rviz_common::ViewController)
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,3 @@ void OrbitViewController::move(float x, float y, float z) // NOLINT(build/inclu

} // namespace view_controllers
} // namespace rviz_default_plugins

#include <pluginlib/class_list_macros.hpp> // NOLINT(build/include_order)
PLUGINLIB_EXPORT_CLASS(
rviz_default_plugins::view_controllers::OrbitViewController, rviz_common::ViewController)
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,3 @@ void FixedOrientationOrthoViewController::move(float dx, float dy)

} // namespace view_controllers
} // namespace rviz_default_plugins

#include <pluginlib/class_list_macros.hpp> // NOLINT(build/include_order)
PLUGINLIB_EXPORT_CLASS(
rviz_default_plugins::view_controllers::FixedOrientationOrthoViewController,
rviz_common::ViewController)
Original file line number Diff line number Diff line change
@@ -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 <pluginlib/class_list_macros.hpp> // 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)
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,3 @@ void XYOrbitViewController::handleMouseEvent(rviz_common::ViewportMouseEvent & e

} // namespace view_controllers
} // namespace rviz_default_plugins

#include <pluginlib/class_list_macros.hpp> // NOLINT
PLUGINLIB_EXPORT_CLASS(
rviz_default_plugins::view_controllers::XYOrbitViewController,
rviz_common::ViewController)
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@
#include <string>
#include <vector>

#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:
Expand Down