C++ SDK mapping¶
This guide is written for the Python SDK, but the same node model ships as a C++ SDK: one class extending NodeBase, the same four required hooks, the same schema file, the same wire format on every edge. After this page you can read any Python page of this guide and apply it in C++: every hook and helper named in the guide is mapped to its C++ name below, the differences that change how you write code are called out, and you know where the C++ skeleton and API reference live.
Same model, two languages¶
| Same in both SDKs | Reference |
|---|---|
| Lifecycle states, what the engine calls, the stop teardown order, cooperative pause | Lifecycle and states |
Schema file: fields, port keys, rosType, executionContext.className, static configuration |
Schema file reference |
Trigger types, the Start fan-out after a successful execute, the Error fan-out on failure, custom trigger ports |
Triggers |
| Two configuration channels: a static string map and typed entries | Configuration |
| Messages are ROS 2 objects; one slot per input port, overwritten by every message | Dataflow |
| Health check hook, health message, immediate health push | Health reporting |
| Simulation mode toggle | Simulation mode |
| Zero-code data visualization of every visualizable output | Data visualization |
Python leads API and contract changes; the C++ tree follows. Both SDKs live in the same repository and are released together under one version number.
Custom gRPC services¶
GrpcServiceRegistration::create<GeneratedService>(factory) couples an owned
generated service to its descriptor. Register with setGrpcServices() before
start(), or pass registrations as the third argument to
NodeManagerService::run(nodes, config, registrations).
Since SDK 2.47.0
authentication is required since SDK 2.47.0 (see Authentication).
The factory receives const NodeServiceConfig& and returns
std::unique_ptr<GeneratedService::Service> or an owned subclass. The host
constructs it once after configuration and retains it until gRPC serving stops.
Use the synchronous generated service implementation; unary and all three
streaming shapes work with the normal gRPC APIs.
Include <neuraverse_sdk/GrpcServiceRegistration.hpp>. Link your generated
protobuf messages, service bindings, and descriptors into the consumer binary;
missing descriptor linkage fails startup. The standalone C++ CRUD example
builds against the installed SDK and shares its proto with Python.
Generate bindings with neuraverse-generate-protos --proto-dir proto --cpp-out
build/generated in the SDK builder environment. The C++ example and test host
use this script through CMake, passing the compiler/plugin paths from their
native toolchain. Add --python-out generated/python to also generate clients
for Python when its SDK dependencies are installed.
See Custom gRPC services for lifetime and
discovery semantics. C++ preserves the listener's existing TLS/mTLS settings. Existing two-argument
run() calls remain valid. Who may call the service is decided by the
Authentication argument, described next.
Authentication¶
Since SDK 2.47.0
Every NodeServiceApi call on a C++ node requires a valid bearer JWT, as on a Python node.
Earlier C++ nodes accepted calls from any caller that could reach the gRPC port.
The check cannot be switched off. A call without a valid authorization: Bearer <token> metadata entry returns UNAUTHENTICATED ("Missing or invalid authorization header" or "Invalid token: ..."). When the identity provider's key set (JWKS) cannot be fetched and no keys are cached, the call returns UNAVAILABLE. Without TLS the token travels unencrypted, so the startup log warns about an insecure listener.
Configure it through NodeServiceConfig.jwt (header <neuraverse_sdk/models/config/JwtConfig.hpp>) or through environment variables with the Python names. The environment overrides the struct. C++ has no YAML; the keys match the Python jwt block. Names are case-sensitive.
| Variable | Meaning | Default |
|---|---|---|
jwt__domain |
Identity provider domain. Issuer and JWKS URL derive from it as https://<domain>/ and https://<domain>/.well-known/jwks.json. |
none |
jwt__auth_type |
Authorization scheme. | Bearer |
jwt__algorithm |
Accepted signing algorithm. Only RS, PS and ES families; HS* is rejected at startup. | RS256 |
jwt__jwks_ttl_days |
How long fetched keys are cached. | 1 |
jwt__token_cache_size |
Validated tokens kept in the cache. | 1000 |
jwt__applications |
All applications as one JSON object. | none |
jwt__applications__<app>__audience |
Required aud for tokens of that application. |
none |
jwt__applications__<app>__domain, __issuer, __jwks_url |
Per application overrides. spire and neura_gym need issuer and jwks_url. |
from jwt__domain |
jwt__applications__<app>__algorithms |
Accepted algorithms for that application. | jwt__algorithm |
jwt__applications__<app>__required_token_use |
Required token_use claim. |
access for neura_gym, otherwise none |
With no application configured, every call is rejected and startup logs a warning. A node behind the engine needs the browser session application spa and the machine-to-machine application m2m_default. On the dev environment both use the audience tf-neuraverse-infra-auth-api:
jwt__domain=account.dev.neuraverse.com
jwt__applications__spa__audience=tf-neuraverse-infra-auth-api
jwt__applications__m2m_default__audience=tf-neuraverse-infra-auth-api
The application is picked from the token's claims; a service_id claim selects the application of that name.
Differences from the Python validator:
| Aspect | Python | C++ |
|---|---|---|
| Algorithms | any the library supports | RS, PS and ES only |
kid header |
optional | required |
exp |
checked | required and checked exactly |
nbf |
no leeway | 60 s leeway |
aud |
skipped when the token has none | required whenever an audience is configured |
service_id claim |
selects an application | selects the application of that name |
Custom services¶
GrpcServiceRegistration::create<Svc>(Authentication, factory) takes the policy as its first argument:
| Value | Effect |
|---|---|
neuraverse::sdk::Authentication::InHandlers |
Every handler must authenticate the caller itself. |
neuraverse::sdk::Authentication::None |
The service is open to every caller. Startup logs a warning. |
gRPC does not let the SDK gate synchronous handlers on an insecure listener, so with InHandlers each handler starts with this guard from <neuraverse_sdk/Authentication.hpp>:
if (auto denied = neuraverse::sdk::authenticate(context); !denied.ok())
return denied;
Pass an AuthenticatedCaller* as second argument to read the token's subject and claims. The policy applies per service, not per method. The C++ SDK's examples/custom_services shows the guard in every handler.
Hooks¶
Your class extends neuraverse::sdk::NodeBase (header <neuraverse_sdk/NodeBase.hpp>). The four required hooks are pure virtual, so a class that misses one does not compile.
NodeBase enforces the author boundary at compile time. Public members are the ones you call (the "Helpers you call" table below). Protected members are the hooks you override, plus a handful of setters meant to be used from inside those hooks. Everything else, including every data member (state_machine_, trigger_, node_id_, ...), is private, reachable only through NodeController/NodesRegistry. A subclass that called a lifecycle method such as configure() or execute(), or read a formerly protected field directly, no longer compiles; override the hooks and use the public getters instead. Overriding a hook under public: in your own subclass still compiles, though the examples below keep hooks protected:.
Two members changed access in 2.46.0: getNodeVersion() and setProjectId() moved from public to protected.
| Python | C++ | Notes |
|---|---|---|
on_configure(self, config, dynamic_config=None) |
void onConfigure(const NodeConfigStringMap& config, const NodeConfigEntryMap* dynamic_config = nullptr) |
Required. NodeConfigStringMap is google::protobuf::Map<std::string, std::string>; NodeConfigEntryMap is google::protobuf::Map<std::string, NodeConfigEntry>. dynamic_config is nullptr when the graph carries no typed entries. |
on_execute(self, trigger_context=None) |
void onExecute() (required) and void onExecute(const std::optional<TriggerContext>&) (optional overload) |
The SDK always calls the context overload; its default forwards to the no-arg form. Override the overload to read the incoming context, for example on an Error input. |
on_stop_execution(self, trigger_context=None) |
void onStopExecution() and void onStopExecution(const std::optional<TriggerContext>&) (optional overload) |
Optional, since SDK 2.43.0. Ends the current run: signal a blocking onExecute() (notify a condition variable, set a flag). Runs at most once per run, also on an idle node. Replaces the removed onStopRequested(). |
on_stop(self, trigger_context=None) |
void onStop() and void onStop(const std::optional<TriggerContext>&) (optional overload) |
Deprecated since SDK 2.43.0, no longer pure virtual. Runs once per lifecycle on the hard stop, after the teardown steps and before onCleanup(). |
on_get_configuration(self) -> dict[str, NodeConfigEntry] |
NodeConfigEntryMap onGetConfiguration() |
Required. Return typed NodeConfigEntry values, never plain strings. |
on_pause(self) |
void onPause() |
Optional. Fires only when the state actually changes to PAUSED. |
on_resume(self) |
void onResume() |
Optional. |
on_cleanup(self) |
void onCleanup() |
Optional. Final step of the hard stop, after the transports are destroyed; release what onConfigure() acquired. |
on_toggle_simulation_mode(self, is_simulation) |
void onToggleSimulationMode(bool isSimulation) |
Optional. |
on_health_check(self) -> bool |
bool onHealthCheck() |
Optional. Default reports healthy. A throwing hook is treated as unhealthy, not propagated. |
on_get_data_visualization_topics(self) |
NodeVisualizationsTopics onGetDataVisualizationTopics() |
Optional. Same shape: a struct holding topics, a map from name to NodeVisualizationsTopic{topic_name, visualization_type}. |
on_start_data_visualization(self, topic_names) |
void onStartDataVisualization(const std::vector<std::string>& topic_names) |
Optional notification; exceptions are logged and swallowed. |
on_stop_data_visualization(self) |
void onStopDataVisualization() |
Optional notification. |
service hook on_prepare_node_dependencies on NodeServiceBase |
no C++ equivalent | The C++ SDK has no service-level hook class. Do once-per-process work in main() before calling NodeManagerService::run. See Service-level hooks for the Python side. |
The hard-stop teardown order is the same list as on the Lifecycle page, with one C++ difference: after onStopExecution() the execute worker is joined (not just shut down) before the state machine and streams are stopped, so onCleanup() always runs after onExecute() returned. Every hard stop waits up to stop_execution_join_timeout_s for onExecute() first, so nodes that join their own worker thread both at the end of onExecute() and in onCleanup() neither hang nor crash; on timeout the SDK logs a warning and tears down anyway. The migration table for C++ nodes is in Migrating to stop execution.
Pause is cooperative in C++ as well. pause() marks the node PAUSED and calls onPause(); triggers, dataflow and the execute worker keep running. Poll isPaused() from a blocking onExecute() or stop the work in onPause(). Resume returns the node to the state it was paused from, and onPause() / onResume() fire only on the call that actually transitions the node. Since 2.48.0 the state machine logs transitions after it released its lock, so a slow log sink cannot block isPaused() on a dataflow thread.
Helpers you call¶
| Python | C++ | Notes |
|---|---|---|
self.get_data(port) |
T getData<T>(const std::string& port) |
Returns a default-constructed T{} when nothing has arrived, not a null. See Reading inputs. std::any_cast throws std::bad_any_cast when T is not the port's message type. |
self.publish(port, msg) |
void publish<T>(const std::string& port, const T& msg) |
T is the ROS 2 message type declared for the port in the schema, for example std_msgs::msg::String. |
self.register_handler(callback, port) |
void registerHandler(std::function<void(const std::any&)> callback, const std::string& port = "") |
Register once in onConfigure(); the dataflow exists only after initialize(), so a call from the constructor does nothing. An input with a handler is push-only: getData() no longer sees its messages. |
self.wait_for_message(port, timeout) |
void waitForMessage(const std::string& port, double timeout = -1.0) |
Do not use. Python raises NotImplementedError on every production transport; C++ throws DataFlowException on the MQTT and Zenoh transports. |
self.fire_trigger(port_key, trigger_context=None) |
void fireTrigger(const std::string& port_name, const std::optional<TriggerContext>& = std::nullopt) |
Same argument: the port key from the schema's outputs. Without a context, one carrying the class name as source_node is sent. |
@trigger_handler("Type") or self.register_trigger_handler("Type", callback) |
void registerTriggerHandler(const std::string& trigger_type, ITrigger::TriggerCallback callback) (protected) |
No decorator in C++. Call it from the constructor, before initialize() and configure(). The callback is std::function<bool(const std::optional<TriggerContext>&)>. Built-in type names throw NodeConfigurationError. |
trigger_context.is_triggered_by_error() |
trigger_context->isTriggeredByError() |
TriggerContext{source_node, timestamp, err_info}; ErrorInformation{err_type, err_msg, transaction_id}. Same JSON field names, so contexts serialized by one SDK deserialize on the other. |
self.is_paused() |
bool isPaused() const |
Reads the state machine. |
self.send_health_update(is_healthy, message) |
void sendHealthUpdate(bool is_healthy, const std::string& message) |
Deduplicates identical snapshots; a no-op before configure. |
self._health_check_message = "..." |
void setHealthCheckMessage(const std::string&) (protected) |
Call from onHealthCheck(). Cleared before every check. |
self.get_cached_output(port) |
std::any getCachedOutput(const std::string& port) const |
Last message published on the port, or an empty std::any. |
self.log_info / log_warning / log_error / log_debug(message) |
logInfo / logWarning / logError / logDebug(const std::string&) |
Python's log_error accepts an optional exception= argument; C++ takes the message only, so append e.what() yourself. |
self.get_node_id() / get_node_name() / get_node_class_name() |
getNodeId() / getNodeName() / getNodeClassName() |
Same meaning. |
self.get_connected_ports() / get_input_topics() / get_output_topics() |
getConnectedPorts() / getInputTopics() / getOutputTopics() |
Same meaning; C++ returns std::unordered_map. |
self.project_id, get_frames(filter), get_robots(), get_paths(robot_ids) |
getProjectId(), getFrames(filter), getRobots(), getPaths(robot_ids) |
C++ throws NodeStateError when no scene endpoint is configured. Results are the structs described in Scene data instead of dicts. |
self.set_project_id(id) |
void setProjectId(const std::string&) (protected) |
Call it from onConfigure() or another hook to point the Scene Builder helpers at another project than the graph's own. |
self.create_data / read_data / update_data / delete_data(key, ..., namespace) |
no C++ equivalent | The C++ NodeBase has no platform data client. |
node_version = "1.2.3" class attribute |
virtual std::string getNodeVersion() const (protected) |
Override to pin a per-class version; the default is the service config's service_version. |
get_config_value(key, config, dynamic_config) from neuraverse_sdk.utils.config |
std::optional<std::string> utils::getConfigValue(key, config, dynamic_config) from <neuraverse_sdk/utils/Config.hpp> |
Same resolution order: typed entry first (toggle to "true"/"false", range to its value, select lists to the first selected item), then the static string. Returns std::nullopt when both miss. A second overload takes a default_value and returns std::string. |
no public Python API (private _viz_bg_push, unsupported) |
void pushBackgroundFrame(const std::string& port, streaming::VizRgbaFrame frame) noexcept |
C++ only. Feeds the source image a segmentation output is composited over when the image never passes through getData(). A no-op with no visualization session running. See Segmentation backgrounds for the Python parity gap. |
Exceptions carry the same names in the neuraverse::sdk namespace, all derived from NodeSdkError (Python: NodeSDKError): NodeConfigurationError, NodeExecutionError, NodeStopError, NodePauseError, NodeResumeError, NodeStateError, DataFlowException, TriggerFlowException, NodeSimulationModeError, NodeHealthCheckError. Python's misspelled NodeRegisteryError is NodeRegistryError in C++. Throw from onExecute() and the SDK behaves as in Python: the Error output fires with the error details attached, the node moves to ERROR, and NodeExecutionError is raised to the engine.
A throwing onExecute() no longer terminates the C++ node process. Before 2.40.0 the exception escaped the background execute thread and killed every node hosted in the process.
Typed errors are available in C++ since SDK 2.48.0, see Typed errors. Throwing the exceptions above keeps working and the engine sees them exactly as before.
Scene data¶
Since SDK 2.51.0
Structs instead of protos, and project-v2 support.
getFrames(), getRobots() and getPaths() return plain structs from <neuraverse_sdk/models/Scene.hpp>. NodeBase::Frame and NodeBase::Path alias SceneFrame and ScenePath. Fields are public members named like the Python dict keys, so frame.id replaces frame.id().
| Type | Members |
|---|---|
SceneFrame |
id, display_name, initial_pose (Pose with position x, y, z and orientation qx, qy, qz, qw; qw is 1 without a pose), metadata, source (FrameSource) |
ScenePath |
id, display_name, frames, segments, target_robot_id, tcp_tip_link, tcp_flange_name, plus is_trajectory, disabled, closing_segment (project-v2 only) |
PathSegment |
id, motion_type (PathMotionType), speed, blend, acceleration (std::optional), plus action, action_param (project-v2 only) |
FrameSource |
Unspecified, Path, Robot, Sensor, Model, Scene (project-v2 only) |
PathMotionType |
Unspecified, MoveJ, MoveL, MoveC, MoveP (project-v2 has only MoveJ and MoveL) |
The v1 scene builder does not expose a segment's jerk, via_frame_id and tool_frame_id in these structs.
Reading from project-v2¶
C++ has no config loader. The node's main() sets the keys on NodeServiceConfig, the same way it sets scene_builder_endpoint.
| Field | Default | Effect |
|---|---|---|
project_service_v2_endpoint |
empty | Address of project-v2. When set, the three calls use it and scene_builder_endpoint is not used. |
project_service_v2_use_tls |
true |
TLS for the project-v2 channel. |
With the endpoint set, getFrames() also returns frames no path visits (FrameSource::Scene). The project id must be the project-v2 UUID. Project-v2 requires authorization: the SDK keeps the authorization header the engine sends on InitializeNode, ConfigureNode and GetNodeConfiguration, stored before the node's getConfiguration(), so frame dropdowns in onGetConfiguration() work on the first Initialize. A call without a header keeps the previous token. Addresses and the other differences are in Scene from project-v2.
Typed errors¶
Since SDK 2.48.0
The C++ SDK has the error vocabulary of the Python SDK. Earlier C++ nodes throw the NodeSdkError family above.
Include <neuraverse_sdk/utils/NodeErrors.hpp>. Pick the class by cause, build it with a factory and throw it:
throw neuraverse::sdk::NodeDataError::invalid("speed must be > 0, got " + std::to_string(speed));
| Class | Factories |
|---|---|
NodeError |
unknown, fault |
NodeDataError |
invalid, missing, unprocessable |
NodeDependencyError |
unavailable, busy, timeout, failure |
Error codes, default user messages and the gRPC status per code are the ones in the Python factory table. The builder methods are withErrorCode, withUserMessage, retryable, withRetryHintMinWaitMs and asPublic; each returns the error, so they chain on a NodeDataError or NodeDependencyError without losing the type. Public and private behave as in Python: a private error (the default) sends the caller only the user message and the retry advice, and the full message goes to the node log. NodeError derives from NodeSdkError, so catch (const NodeSdkError&) still catches it.
<neuraverse_sdk/utils/Retry.hpp> has autoRetry(fn, max_attempts = 3). It retries fn while the thrown error is retryable, waits the error's retry hint (1 s when the error has none), and rethrows the last error after max_attempts attempts in total.
| Difference from Python | C++ |
|---|---|
| Where a typed error reaches the caller | Only from onConfigure(). Other hooks wrap what you throw into NodePauseError and its siblings, and errors from onExecute() are not typed. |
SDKError family |
Not ported. |
| Generic private message | "An error occurred while processing. See the node logs." The text does not quote a transaction id. |
Health escalation¶
Since SDK 2.48.0
C++ nodes can escalate a lasting health fault, as Python nodes do.
The behaviour is the one on Health reporting: a RUNNING node that stays unhealthy for unhealthy_escalate_after_s moves to ERROR and fires its Error trigger with err_type HealthFaultEscalation. C++ has no YAML or generic environment for these fields; set them in the struct in main():
config.health_stream_check_interval_s = 1.0;
config.escalate_unhealthy_to_error = true;
config.unhealthy_escalate_after_s = 7.0;
| Field | Default | Meaning |
|---|---|---|
escalate_unhealthy_to_error |
false |
Off unless you opt in. |
unhealthy_escalate_after_s |
7.0 |
Seconds a running node must stay unhealthy. |
A healthy sample cancels a pending escalation. An onExecute() that returns after the escalation does not move the node back to CONFIGURED. Since 2.48.0 the SDK also logs a health check result only when it changes.
Probes¶
Since SDK 2.49.0
Before, a C++ node's gRPC health service answered SERVING unconditionally.
C++ nodes answer the same unauthenticated liveness and readiness probes as Python nodes, with the same checks, status codes and body: HTTP /health/live, /health and /health/ready, and a Check-only grpc.health.v1.Health ("" and hosted services for readiness, "liveness" for liveness, Watch is UNIMPLEMENTED). See Deployment: Probes. Nothing to configure; the C++ node template's HEALTHCHECK uses /health/live from 2.49.0.
Differences that change how you write code¶
Reading inputs has no None¶
Python's get_data() returns None while nothing has arrived. C++ getData<T>() returns T{} instead, so a std_msgs::msg::Float32 reads as 0.0 and a std_msgs::msg::String as "". There is no way to tell "no message yet" from "a message equal to the default" through getData<T>() alone. When your node must distinguish the two, use getDataAny(port) and test has_value() before casting:
std::any raw = getDataAny("image_in");
if (!raw.has_value())
{
logWarning("No image on image_in yet");
return;
}
auto image = std::any_cast<sensor_msgs::msg::CompressedImage>(raw);
Repeated reads without a new message return the same value in both SDKs.
Custom trigger handlers live in the constructor¶
There is no @trigger_handler decorator. Bind the handler to the trigger type name (the rosType of the input port) in the constructor:
class WorkerNode : public neuraverse::sdk::NodeBase
{
public:
WorkerNode()
{
registerTriggerHandler("SpecialStart",
[this](const std::optional<neuraverse::sdk::TriggerContext>& ctx) {
logInfo("SpecialStart received");
return true;
});
}
protected:
// ... the four required hooks
};
Native handlers run on the transport callback thread; external input handlers use a separate worker. Both run concurrently with onExecute(), as in Python: keep them fast and protect shared state. A declared custom input trigger with no bound handler fails configure in both SDKs.
Reading configuration¶
getConfigValue mirrors the Python helper, including the fallback to the static map. The template's StringPublisher shows the idiom:
void onConfigure(const NodeConfigStringMap& config,
const NodeConfigEntryMap* dynamic_config = nullptr) override
{
auto text = neuraverse::sdk::utils::getConfigValue("text", config, dynamic_config);
if (text.has_value())
{
text_ = *text;
}
}
onGetConfiguration() builds NodeConfigEntry objects with the protobuf setters (mutable_configvalue()->set_stringvalue(...), set_displaylabel(...), set_description(...), set_required(...), set_isoverridable(...)). The keys must match the schema's configuration block, as in Python.
Registration and startup¶
Python registers classes with set_node_classes([...]) and calls run(); the SDK reads config/service_config.yaml. C++ has no YAML loader for the service config. Your main() fills a NodeServiceConfig struct, usually from environment variables, and passes a vector of {class name, factory} pairs to NodeManagerService::run:
#include <neuraverse_sdk/NodeManagerService.hpp>
neuraverse::sdk::NodeServiceConfig config;
config.grpc.port = 50081;
config.http.port = 8081;
config.mqtt.broker_host = "localhost";
config.schema_dir = "/neuraverse-node/src";
config.registry_config.node_namespace = "gateway";
config.container_name = "neuraverse-my-node-cpp";
config.service_version = "1.0.0";
std::vector<std::pair<std::string, neuraverse::sdk::NodeFactory>> nodes = {
{"StringPublisher", [] { return std::make_unique<StringPublisher>(); }},
};
neuraverse::sdk::NodeManagerService::run(nodes, config);
Two environment variables override the listener bind addresses, with the Python names. The environment wins over the struct, an empty value is ignored, and both default to 0.0.0.0. The address the node registers in Consul follows grpc__address.
Since SDK 2.48.0
grpc__address and http__address are read by C++ nodes.
| Variable | Overrides |
|---|---|
grpc__address |
config.grpc.address |
http__address |
config.http.address |
Rules that follow:
| Rule | Why |
|---|---|
The string key of each pair is the class name and must equal the schema's executionContext.className. |
In Python the class name is taken from the class object. In C++ NodeFactory is std::function<std::unique_ptr<NodeBase>()>, so the SDK cannot see your type name; the key is what it registers and what it uses to find the schema. |
Set config.schema_dir to the directory that holds your *_schema.json files. |
The SDK scans it recursively once per process and indexes every file by its className. An empty schema_dir disables discovery: the node still runs but stays out of the palette. |
Set container_name, registry_config.node_namespace and service_version. |
They take the place of the container_name, registry_config.node_namespace and service_descriptor.version keys of the Python service_config.yaml. |
Register extra ROS 2 message types before run(). |
run() registers the common packages (std_msgs, geometry_msgs, sensor_msgs, audio_common_msgs, nav_msgs, instance_segmentation_ros_msgs). For any other type call neuraverse::sdk::TypeRegistry::registerType<pkg::msg::Type>("pkg/msg/Type") from <neuraverse_sdk/dataflow/TypeRegistry.hpp> first. |
The schema file rules are the Python ones, including the port-key convention. In Python the file must be named <module>_schema.json and sit next to <module>.py; in C++ any file ending in _schema.json under schema_dir works, because lookup goes by className, not by file name. The template keeps the Python layout anyway (src/<node>/<Node>.hpp next to src/<node>/<node>_schema.json).
Wire format and mixed graphs¶
C++ and Python nodes connect freely in one graph. Data edges between the two carry the same serialized ROS 2 message, and trigger edges carry the same TriggerContext JSON. Custom trigger ports use the same topic and payload contract; the fixture custom_trigger_wire.json in the C++ SDK repository is asserted by both SDKs' test suites, so a TaskInterrupt fired from C++ wakes a Python handler and the other way round.
C++ nodes get zero-code data visualization: every visualizable output streams to the UI, topics the node does not publish itself are picked up by a ROS subscription, and the last value per port is cached for late viewers. Before 2.40.0 only Python nodes were visualized.
Since SDK 2.50.1
A C++ node renamed in the frontend to a name with spaces or other special characters configures correctly. The SDK derives a valid ROS node name from the display name and the node id, the same way as in Python.
The ROS adapter also validates topics at configure (validateRosTopics in utils/RosTopicSanitizer.hpp) and throws DataFlowException for two outputs that map to one topic after sanitizing, and for an output or input source topic with an empty segment (a port name ending in / or containing //). Behaviour and messages match Python. Name ports [A-Za-z][A-Za-z0-9_]*.
Since SDK 2.50.2
The composite dataflow and the MQTT and Zenoh trigger adapters validate topics at configure (utils/TopicValidation.hpp). A port name that puts # or + (MQTT) or *, $, ? or # (Zenoh) into an output topic or an input source topic throws DataFlowException (TriggerFlowException in the trigger adapters) before any adapter is torn down. Rules and messages match Python.
Runtime dependencies¶
The C++ SDK ships Paho MQTT C 1.3.15, Paho MQTT C++ 1.6.0, Zenoh 1.10.1 and cpp-httplib 0.58.0.
| Change | Effect on your node |
|---|---|
| Paho C 1.3.14 and later | http_proxy is only honoured when PAHO_C_CLIENT_USE_HTTP_PROXY=TRUE is set. Only lowercase http_proxy and no_proxy are read. |
| Paho C++ 1.6.0 | The installed CMake target is PahoMqttCpp::paho-mqttpp3-shared, with PahoMqttCpp::paho-mqttpp3 as an alias. Linking neuraverse_node_sdk alone needs no change. |
| cpp-httplib 0.58.0 | Regex routes no longer match request paths over 256 characters, so requests with such paths return 404. |
Testing C++ nodes¶
The Mock Runner loads Python modules only (*.py files under the mounted src/), so it cannot run a C++ node. For C++:
- Unit test the class directly with your C++ test framework: construct it, call
onConfigure,onExecute, and assert on what it publishes throughgetCachedOutput(port), which is filled even without a dataflow. A node that has not been initialized has no dataflow, sopublish<T>sends nothing andgetData<T>returnsT{}. - Run the built container against a real MQTT broker and engine as described in the C++ SDK README, then check the node appears in the palette and its HTTP port answers on
/(the template's container health check requests that path).
Where to go¶
| You need | Go to |
|---|---|
A C++ project skeleton: CMakeLists.txt, Dockerfile, main.cpp, two example nodes with schemas |
node-template-cpp |
The C++ API in detail: prerequisites, base image, find_package(neuraverse_node_sdk), full publisher and consumer examples, project structure |
C++ SDK README |
| The concepts behind every row above | Node anatomy, Lifecycle and states, Triggers, Dataflow, Configuration |
| Building and deploying the image | Project layout and build, Deploying on an engine |
Both the Python and the C++ node containers start from the same SDK base image (registry.gitlab.neura-robotics.com/neuraverse/neuraverse-node-sdk:vX.Y.Z), which installs the C++ SDK to /usr/local with a CMake package config. A C++ node links it with find_package(neuraverse_node_sdk REQUIRED CONFIG) and target_link_libraries(my_node PRIVATE neuraverse_node_sdk).
External Start input¶
C++ nodes accept platform Start events on configured declared inputs, with Python parity.
Events reach onExecute through the normal execution queue, including disconnected
inputs and distinct Start keys. Context and error information are preserved.
Inactive, idle or errored nodes and invalid ports/types are rejected. Start never
re-arms the run; pause remains cooperative through isPaused(). See
triggers for acknowledgement and
retry semantics.
External Stop uses onStop on the target only. Other built-ins use their wired
execution path, and custom inputs call the handler registered for their type.
Separate keys sharing a custom type remain addressable without connections.
A stopped target rejects later input with node_run_inactive.
Scalar JSON inputs¶
C++ nodes accept the same scalar JSON input contract as Python nodes.
Existing input reads and handlers receive committed values without an implicit
onExecute() call. ROS, MQTT and Zenoh retain their native receive
representations, including composite routes and disconnected declared inputs.
Install and register any custom message type, and resolve generic input types
before configuration. See typed JSON input
and the scalar rules.
C++ accepts nested message objects and scalar/message arrays with the same defaults, bounds, binary and numeric conventions as Python. Custom messages use the existing installed type registration mechanism. Validation finishes before input delivery, so a rejected nested field cannot partially update a value or invoke its handler.
See compound JSON rules.