🤖
Introduction to ROS2 and Robotics
  • Introduction
  • ROS2
    • Index
    • IDE and CMake Setup
      • How to add additional include search path
    • ROS2 Building Blocks
      • ROS Workspace and Package Layout
      • Launch File
      • tf2
      • Quality of Service
      • Configurations
        • Rviz Configuration
      • Built-in Types
        • Built-in Message Type
    • ROS Architecture
      • Intra-process Communication
    • Navigation and Planning
      • Navigation Stack and Concepts
      • Navigation2 Implementation Overview
        • 🏗️Cost Map
        • Obstacle Avoidance and DWB Controller
      • DWB Controller
      • Page 5
    • How to launch the Nav2 stack
    • ROS2 Control
      • Online Resources
      • Overview of Codebase
    • 🍳Cookbook
      • Useful Commands
      • How to specify parameters
      • How to build the workspace
      • 🏗️How to publish message to a topic from command line?
      • How to inspect service and make a service call
      • How to properly terminate ROS and Gazebo
      • How to add and remove models in Gazebo simulation dynamically
      • 🚧How to spin nodes
    • 🛒Tutorials
      • Services and Communication between ROS2 and Gazebo
      • Subscription and Message Filters Demo
      • Executor and Spin Explained
      • Lifecycle Node Demo
      • Robotic Arm Demo
      • ⚒️Multiple Robotic Arms Simulation Demo
      • 🚧Introduction to xacro
    • Page
    • 🍺Tech Blog
      • Difference between URDF and SDF and how to convert
  • Gazebo
    • Index
    • Terminology
    • GUI
    • World Frame and Axis
    • Cookbook
    • Page 1
  • Programming in Robotics
    • C++
      • CMake
    • Python
    • Rust
  • Mathematics in Robotics
    • Linear Algebra
    • Matrix Properties
    • Probability
      • Expectation-Maximization Algorithm
    • Multivariable Function and Derivatives
  • Physics in Robotics
  • Control of Dynamic Systems
    • Dynamic Response and Transfer Function
    • Block Diagram
    • PID Controller
  • Robot Modeling and Control
    • Rotation and Homogeneous Transformation
  • Probabilistic Robotics
    • Bayes Filter
    • Kalman Filter
    • Particle Filter
    • Discrete Bayes Filter
    • Motion Model
    • Perception Model
    • Localization
    • SLAM
  • Miscellany
  • Concept Index
    • Quaternions
Powered by GitBook
On this page
  1. ROS2
  2. ROS Architecture

Intra-process Communication

PreviousROS ArchitectureNextNavigation and Planning

Last updated 1 year ago

Related Readings

The ROS2 Design - Intra-process Communication is a design doc but it captures the main ideas in the actual implementation. Note that for ROS Humble, the intra-process communication is still an experimental feature.

The key of the intra-processs is to keep the message object inside the memory and avoid copy. In this article, we will take a look at the source code and see how the code determine when to make a copy and when to use a pointer.

Let's start with the publisher.publish method:

The control is then passed to another publish method with different signature. It determins if we need to perform inter-process publication. Let's focus on the intra-process communication and take a look at the do_intra_process_ros_message_publish method.

So jump to do_intra_process_ros_message_publish method:

Not too much info here. Move on to do_intra_process_publish method:

Things getting interesting. In this function, we can see many key concepts in the design:

  • The sub_ids are related to the subscriptions. And we can see there are two types of subscriptions. The ones that own the message and the ones that share (or observe) the message.

  • We see the word buffers in some of the method names.

  • Note that for subscriptions that take the ownship of the message, we pass the original unique_ptr of the message to them; for subscriptions that share (or observe) the message, a shared pointer is constructed. Depending on the scenario, we can either convert the unique_ptr to the shared_ptr or we need to construct a copy.

The next question is how to control the type of the subscription?

The buffer type is resolved in the resolve_intra_process_buffer_type.hpp file:

We can either specify the buffer type explicitly or ask the code to determine the buffer type based on the parameter type of the callback function of the subscriber.

ROS2 Design - Intra-process Communication
C++ Smart Pointers Lecture