A subscriber is able to get the messages broadcasted by the publisher.

This source file in Python will subscribe to ROS 2 messages:

#include <iostream>
#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/float32.hpp"

// declare a void function to Callback the message
void chatterCallback(const std_msgs::msg::Float32::SharedPtr msg)
  std::cout << "I heard: [" << msg->data << "]" << std::endl;

// create a subscriber
int main(int argc, char * argv[])
  rclcpp::init(argc, argv);
  // create a node
  auto node = rclcpp::Node::make_shared("listener_float");
  // create the subscription and call the Callback function
  auto sub = node->create_subscription<std_msgs::msg::Float32>(
    "chatter", chatterCallback, rmw_qos_profile_default);

  // spin: Blocking call, do work indefinitely as it comes in.
  // spin_once: Do one "cycle" of work, with optional timeout.
  // spin_some: Do all the work that is immediately available to the executor.


  return 0;

Do you need more computing capacity? Stay tuned