MCPcopy Create free account
hub / github.com/awesomebytes/rclcppyy

github.com/awesomebytes/rclcppyy @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
211 symbols 802 edges 32 files ⚖ BSD-2-Clause 65 documented · 31% ● updated 2mo agov0.3.0 · 2026-09-27★ 781 open issues

Browse by type

⨍ Functions 181◇ Types & classes 30
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

rclcppyy

CI

Keep the rclpy contract; opt into proven C++ paths. rclcppyy is a compatibility-first C++ backend for existing ROS 2 Python software. Its default profile keeps the exact stock node, context, executor, message classes, entity objects, and publish operation. Explicit profiles route an operation through C++ only when that route has contract and backend evidence. It is powered by cppyy, which calls C++ from Python directly via reflection and just-in-time compilation, and built on the cppyy_kit suite (docs: awesomebytes.github.io/cppyy_kit), which packages the same "mix Python and C++ with ease" machinery for ROS 2 and a family of C++ robotics libraries.

New to the two projects? Start with the user overview.

What it looks like

Take any ordinary rclpy node and add a single line at the top:

import rclcppyy; rclcppyy.enable_cpp_acceleration()

# Everything below remains ordinary rclpy code and ordinary rclpy objects.
import rclpy
from std_msgs.msg import String

rclpy.init()
node = rclpy.create_node('talker')
pub = node.create_publisher(String, 'chatter', 10)
node.create_timer(0.5, lambda: pub.publish(String(data='hello')))
rclpy.spin(node)

enable_cpp_acceleration() patches methods on the original rclpy classes. The publisher above remains a stock rclpy.Publisher registered with the stock node; the default compatible profile also leaves its stock Publisher.publish method authoritative. The subscription, timer, executor, context, and message class remain stock Python, and rclcppyy.status() makes those choices explicit.

Select same-handle C++ publishing only after measuring the application:

import rclcppyy
rclcppyy.enable_cpp_acceleration(profile="publisher_cpp")

That profile serializes with rclcpp::Serialization<T> and publishes through the existing native publisher handle. It creates no companion node or endpoint.

On Jazzy with Cyclone DDS, the narrower C++-owning message tier is explicit:

import rclcppyy
rclcppyy.enable_cpp_acceleration(profile="message_facade")

from std_msgs.msg import String, UInt64

These two late-imported generated-style classes own std_msgs::msg::String or std_msgs::msg::UInt64 C++ storage. Their stock publisher and subscription entities borrow the same native handles for C++ serialization and take, so the hot path does not perform Python-to-C++ whole-message conversion. All other message layouts, pre-activation class aliases, raw subscriptions, subscriptions with event callbacks or content filters, and custom publisher classes remain stock and are reported as such.

The experimental profile="direct_cpp" first slice goes further: on Jazzy with Cyclone DDS, unchanged Node subclasses can use actual rclcpp nodes, entities, and generated C++ messages. It supports std_srvs/SetBool by default and explicitly registered installed services such as std_srvs/srv/Trigger. Service clients offer call_async() and blocking call(); service and subscription callbacks receive owning native C++ values, without generated Python message conversion or serialization. The profile also defaults to a direct tf2_msgs/action/LookupTransform client and accepts explicitly registered installed actions. A first direct ActionServer slice supports synchronous callbacks, feedback, results, and cancellation on the direct single-threaded executor, with a mutually-exclusive callback group and default action QoS. Direct single-threaded executors are available, and the direct MultiThreadedExecutor is experimental. Enable this profile before importing rclpy.node, rclpy.executors, or supported interfaces. Unsupported options fail before entity creation.

What you get

  • In the compatible profile, existing node, graph, context, remapping, parameter, executor, and teardown behavior stays authoritative in rclpy.
  • Importing and enabling the compatible profile does not initialize cppyy, Cling, native factories, or the legacy companion-node implementation. Explicit C++ profiles and APIs load those dependencies only when first used.
  • rclcppyy.status() reports the backend selected for each routed entity and operation.
  • profile="publisher_cpp" explicitly enables the permissive same-handle C++ publisher route and reports any fallback to stock publishing.
  • profile="message_facade" opts String and UInt64 into C++-owning storage and direct same-handle publish/take on the reviewed Jazzy/Cyclone executor ABI.
  • profile="direct_cpp" is the bounded source-compatible correctness lane for a single native node authority and fully C++ pub/sub data representation.
  • profile="required_cpp" fails before creating an entity when no certified C++ route exists, so tests and benchmarks cannot pass through silent fallback.
  • The separate native lane exposes rclcpp and other C++ libraries directly when compatibility is not the primary constraint.
  • The backend selection and promotion guide defines when to use compatible, strict, managed native, and fused C++ execution lanes.

The native lane adds lifecycle management but does not replace the C++ API:

from std_msgs.msg import String
import rclcppyy

with rclcppyy.native(["my_program"]) as ros:
    options = ros.rclcpp.NodeOptions()
    node = ros.create_node("native_node", options=options, use_intra_process=True)
    publisher = node.create_publisher(String, "chatter", 10)
    executor = ros.create_executor("multi_threaded", threads=2)
    executor.add_node(node)
    lifecycle = ros.create_native_lifecycle_node("managed_worker")
    lifecycle.attach_executor(executor)
    container = ros.create_native_component_manager(
        executor, name="managed_container")
    relay = ros.create_fused_pipeline(
        node, String, String, "input", "output",
        'output.data = input.data + ":native";',
        delivery="latest",
    )

Nodes, options, publishers, callback groups, and executors in this block are the real cppyy-backed C++ objects. The session owns a custom rclcpp::Context, orders shutdown, and exposes ros.rclcpp as the unrestricted escape hatch. Loaned-message availability is queried per publisher with rclcppyy.publisher_capabilities(). The same session offers thin factories for typed C++ services, clients, action clients, lifecycle nodes, and standard AOT component containers; their original C++ objects remain available through explicit raw accessors.

Measure routes on the target workload rather than assuming that crossing into C++ is automatically faster:

pixi run bench

The benchmark runner requires machine-readable publisher and subscriber backend evidence and decoded wire-value evidence before it records a result. Its default compatibility comparison is Python/Python; the controlled relay benchmark has a separate publisher_cpp lane. The same-handle route is correctness-certified but is not advertised as a performance win. Native-message and fused C++ paths must clear workload-specific performance gates before they are advertised. See the benchmark evidence guide for the repeated local gate. That guide also indexes the controlled pub/sub, service, client, timer, and action CPU protocols, with C++-representation lanes reported separately from conversion or activation-only compatibility lanes.

For the full, consolidated and freshly-measured benchmark set — across the whole suite, including the freeze/AOT optimization ladder — see the cppyy_kit benchmarks page.

Install (pixi / conda — no build needed)

rclcppyy is published as ros-jazzy-rclcppyy on the prefix.dev awesomebytes channel. Check GitHub Releases or Prefix for the currently published version. To use it (no clone, no colcon build), add the channel and the package to your own pixi workspace:

# pixi.toml
[workspace]
channels = ["https://repo.prefix.dev/awesomebytes", "robostack-jazzy", "conda-forge"]
platforms = ["linux-64"]

[dependencies]
ros-jazzy-rclcppyy = "*"

Or in one line:

pixi add -c https://repo.prefix.dev/awesomebytes -c robostack-jazzy -c conda-forge ros-jazzy-rclcppyy

Then import rclcppyy; rclcppyy.enable_cpp_acceleration() works out of the box — no LD_LIBRARY_PATH or activation setup required. Message packages you publish or subscribe (e.g. ros-jazzy-std-msgs) are separate dependencies, as in any ROS 2 project. Installing rclcppyy pulls its runtime deps ros-jazzy-rclcpp-kit and cppyy-kit (the suite) transitively.

What routes through C++, and what stays rclpy

The default compatible profile keeps the stock contract and records every current boundary. It intentionally leaves Publisher.publish on stock rclpy.

Explicit same-handle C++ route:

  • profile="publisher_cpp" is permissive and reports fallback.
  • profile="required_cpp" fails closed when this route cannot be prepared or completed.
  • Both operate on the existing rcl_publisher_t; neither creates a companion node or publisher.
Transparent path Backend evidence Wire evidence Performance status
compatible Publisher.publish publisher python; subscriber python flat and nested workloads validate the same decoded value contract stock authority; activation-overhead characterization only
publisher_cpp / required_cpp on the existing stock handle publisher cpp; stock subscriber python dedicated round trips validate decoded values and backend completion no benefit advertised; controlled results remain raw evidence

No compatible path currently advertises a performance benefit. C++ routing is a backend fact; a benefit requires separate, repeated, architecture-specific evidence.

Stays on stock rclpy in the compatible and optimized profiles:

  • Nodes, contexts, graph identity, message classes, subscriptions, timers, spin, services, actions, parameters, lifecycle nodes, callback groups, and executors.
  • Publisher creation, publishing, and destruction, QoS, event callbacks, callback groups, and override options in compatible and optimized profiles.

Known walls:

  • Activation patches methods process-globally and irreversibly. Call it once before creating nodes. Existing Node aliases and subclasses retain their class identity because the original class is patched rather than replaced.
  • profile="publisher_cpp" and profile="required_cpp" currently support the publisher route; required mode rejects subscriptions and timers. profile="optimized" preserves stock publishing and opts into 100 ms bounded waits for rclpy.spin() and direct stock single- and multi-threaded executor spin() calls. This prevents a missed signal guard wake from leaving an invalid Context blocked indefinitely, at the cost of periodic idle wake-ups. It is a reliability mitigation, not a C++ route or performance claim.
  • profile="direct_cpp" defaults to std_msgs/String, UInt64, and std_srvs/SetBool, plus the tf2_msgs/LookupTransform action client. Additional installed message, service, and action interfaces can be registered by canonical name. It supports native default, mutually-exclusive, and reentrant callback groups; the direct single-threaded executor; and an experimental direct MultiThreadedExecutor. The first direct ActionServer slice is limited to synchronous callbacks on the single-threaded executor, with a mutually-exclusive group and default QoS. Service clients support call_async() and blocking call(); blocking calls need another thread to service the executor, as in stock rclpy. Callback-group subclasses that override Python scheduling hooks fail closed. Service introspection and uncovered options remain unsupported. The direct profile is not yet a general rclpy replacement. The subscription callback copy is measured by the dedicated direct-cpp-rclcppyy controlled relay lane. Service/client copy and crossing counts are exposed as correctness evidence; no service performance benefit is claimed yet.
  • rclcppyy.Node remains the legacy companion-node prototype. It is not the transparent compatibility architecture and should not be used for new compatibility work.
  • The first rclcpp bringup JIT-compiles headers. The suite ships a zero-config Cling PCH cache (cppyy_kit auto-PCH) that makes subsequent process starts far cheaper (a warm rclcpp bringup measured ~1.73 s → ~0.064 s); see the Freeze & Cache docs and the benchmarks page.
  • C++ routing is opt-in per process; without the one-line call, your code is ordinary rclpy.

Inspect backend decisions

rclcppyy.status() returns a JSON-serializable process snapshot of the backend selected for routed nodes, entities, and operations:

report = rclcppyy.status()
for entity in report["entities"]:
    print(entity["backend"], entity["reason"], entity["policies"])

Each decision reports cpp, python, or unsupported, along with active policies and value-only metadata such as the entity type, topic, and message type. History is bounded to the latest 256 records per category; aggregate counts and dropped-record counts remain available for long-running processes.

Powered by the cppyy_kit suite

As of 0.2.0, rclcppyy is the ROS 2 drop-in product in a larger fam

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 105
Method 76
Class 30

Languages

Python100%

Modules by API surface

rclcppyy/rosbag2_py_compat.py28 symbols
rclcppyy/node.py25 symbols
rclcppyy/bringup_rclcpp.py19 symbols
rclcppyy/rosbag2_cpp.py13 symbols
rclcppyy/monkeypatch_messages.py13 symbols
scripts/benchmarks/bench_pub_rclcppyy.py9 symbols
rclcppyy/serialization.py8 symbols
scripts/benchmarks/bench_sub_rclcppyy_monkeypatched.py7 symbols
scripts/benchmarks/bench_sub_rclcppyy.py7 symbols
roscon_uk_2025/presentation/2_pointcloud_voxelgrid.py6 symbols
scripts/create_stubs.py5 symbols
scripts/big_messages_demos/demo_images.py5 symbols

For agents

$ claude mcp add rclcppyy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page