To see some of these examples in use, visit the ROS 2 Tutorials page: https://index.ros.org/doc/ros2/Tutorials/
ros2 run examples_rclcpp_minimal_publisher publisher_member_function
ros2 run examples_rclcpp_minimal_subscriber subscriber_member_function
ros2 run examples_rclcpp_minimal_action_server action_server_member_functions
ros2 run examples_rclcpp_minimal_action_client action_client_member_functions