Skip to content

granular rclcpp/rclcpp.hpp and include what you use - #454

Open
ahcorde wants to merge 1 commit into
rollingfrom
ahcorde/rolling/granular_includes
Open

granular rclcpp/rclcpp.hpp and include what you use#454
ahcorde wants to merge 1 commit into
rollingfrom
ahcorde/rolling/granular_includes

Conversation

@ahcorde

@ahcorde ahcorde commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

Granular rclcpp/rclcpp.hpp also in documentation

Did you use Generative AI?

Claude Opus 4.8

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>

@fujitatomoya fujitatomoya left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with green CI.

@ahcorde

ahcorde commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Pulls: #454, ros2/demos#806, ros2/message_filters#328, ros2/rosbag2#2483, ros2/realtime_support#151, ros/robot_state_publisher#254, ros2/geometry2#984, ros2/ros2_tracing#263, ros2/rmw_zenoh#1043, ros2/rclcpp#3249, ros2/rviz#1854
Gist: https://gist.githubusercontent.com/ahcorde/6e2c1cab51fc5d52b71e9010c493924d/raw/0bccb788339608e2fac25bcf37201b3fa7a169bb/ros2.repos
BUILD args: --packages-above-and-dependencies action_tutorials_cpp action_tutorials_py composition demo_nodes_cpp_native demo_nodes_cpp demo_nodes_py dummy_map_server dummy_robot_bringup dummy_sensors image_tools intra_process_demo lifecycle lifecycle_py logging_demo pendulum_control pendulum_msgs quality_of_service_demo_cpp quality_of_service_demo_py topic_monitor topic_statistics_demo launch_testing_examples examples_rclcpp_minimal_action_client examples_rclcpp_minimal_action_server examples_rclcpp_minimal_composition examples_rclcpp_cbg_executor examples_rclcpp_multithreaded_executor examples_rclcpp_async_client examples_rclcpp_minimal_client examples_rclcpp_minimal_service examples_rclcpp_minimal_timer examples_rclcpp_minimal_publisher examples_rclcpp_minimal_subscriber examples_rclcpp_wait_set examples_rclpy_minimal_action_client examples_rclpy_minimal_action_server examples_rclpy_executors examples_rclpy_guard_conditions examples_rclpy_minimal_client examples_rclpy_minimal_service examples_rclpy_minimal_publisher examples_rclpy_minimal_subscriber examples_rclpy_pointcloud_publisher message_filters rosbag2_compression_zstd rosbag2_examples_cpp rosbag2_examples_py rosbag2_performance_benchmarking rosbag2_performance_benchmarking_msgs rosbag2_py rosbag2_test_common rosbag2_tests rosbag2_transport tlsf_cpp robot_state_publisher test_tf2 tf2_bullet tf2_kdl tf2_ros tf2_sensor_msgs lttngpy test_tracetools tracetools rmw_zenoh_cpp test_rmw_zenoh_cpp zenoh_security_tools rclcpp rviz2 rviz_common rviz_visual_testing_framework
TEST args: --packages-above action_tutorials_cpp action_tutorials_py composition demo_nodes_cpp_native demo_nodes_cpp demo_nodes_py dummy_map_server dummy_robot_bringup dummy_sensors image_tools intra_process_demo lifecycle lifecycle_py logging_demo pendulum_control pendulum_msgs quality_of_service_demo_cpp quality_of_service_demo_py topic_monitor topic_statistics_demo launch_testing_examples examples_rclcpp_minimal_action_client examples_rclcpp_minimal_action_server examples_rclcpp_minimal_composition examples_rclcpp_cbg_executor examples_rclcpp_multithreaded_executor examples_rclcpp_async_client examples_rclcpp_minimal_client examples_rclcpp_minimal_service examples_rclcpp_minimal_timer examples_rclcpp_minimal_publisher examples_rclcpp_minimal_subscriber examples_rclcpp_wait_set examples_rclpy_minimal_action_client examples_rclpy_minimal_action_server examples_rclpy_executors examples_rclpy_guard_conditions examples_rclpy_minimal_client examples_rclpy_minimal_service examples_rclpy_minimal_publisher examples_rclpy_minimal_subscriber examples_rclpy_pointcloud_publisher message_filters rosbag2_compression_zstd rosbag2_examples_cpp rosbag2_examples_py rosbag2_performance_benchmarking rosbag2_performance_benchmarking_msgs rosbag2_py rosbag2_test_common rosbag2_tests rosbag2_transport tlsf_cpp robot_state_publisher test_tf2 tf2_bullet tf2_kdl tf2_ros tf2_sensor_msgs lttngpy test_tracetools tracetools rmw_zenoh_cpp test_rmw_zenoh_cpp zenoh_security_tools rclcpp rviz2 rviz_common rviz_visual_testing_framework
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20307

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@wjwwood wjwwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on the fence about the trade-off of avoiding rclcpp.hpp here in the examples. I can see the argument for doing it even here, but I also think the impact to user experience is unfortunately. Specifically I'm concerned about them feeling like they need to know (or know how to figure out) which headers they need in which situations, and while copying an example is fine, when they start to expand the scope of the example they copied (these are meant to be starting points for users to work off of) I'm afraid they'll struggle to know what they need to include and in which situations.

Tooling (IWYU linters) and AI agents might make this less of a concern these days though. On the other hand, I'd like to keep the "lightweight, ai-free" user archetype in mind as long as we can.

Overall, I'm ok with this change, but I think we should be thoughtful about it. Maybe there's a middle ground where we have some headers for common use cases that keep compile time impacts in mind. Either way, that idea (and others) are out of scope for this pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants