Skip to content

Tutorials

Six tutorials take you from the Quickstart node to a node that talks to a device, a node that talks to a cloud service, and nodes that wake each other with custom triggers. Each tutorial supplies tested example code you can copy into your node project and read beside the explanation. Tutorials 1 through 4 run in the Mock Runner; tutorial 5 uses a real transport, and tutorial 6 uses a supporting platform endpoint. After this page you know which tutorial teaches what, what you need to run it, and how to load any of them into the Mock Runner in one command.

The six tutorials

# Tutorial Level Node and ports What you learn
1 Math node Beginner MathAddNode: a, b (Float32) in, sum (Float32) out; static offset Data ports and ROS 2 messages, get_data and publish, the schema file, a static configuration value, the pytest that CI runs
2 Image node Intermediate GrayscaleNode: image_in to image_out (sensor_msgs/msg/CompressedImage); typed scale range Binary payloads with OpenCV and NumPy, why CompressedImage, a typed range setting, visualization without extra code
3 Device node (smart home) Intermediate SmartLightNode: command_in (String) to status_out (String); typed light_ip text and simulate toggle Typed configuration with get_config_value, a device handle owned by the node, health reporting, simulation mode, cooperative pause, cleanup
4 Cloud upload node Advanced CloudUploadNode: data_to_upload (String) to upload_status (String); typed endpoint, read-only api_key, dry_run toggle HTTP calls with a timeout and bounded retries, raising NodeExecutionError so the error trigger fires, a downstream ErrorHandlerNode, secrets that never reach the UI, a service-level hook
5 Custom triggers Advanced WatchdogNode fires task_interrupt (TaskInterrupt); WorkerNode handles special_start (SpecialStart) fire_trigger and @trigger_handler, port key versus trigger type, running two nodes end to end against a local MQTT broker
6 External inputs Advanced VelocityEchoNode passes through a Twist; HeartbeatNode runs independently Acknowledged JSON input before Start, ordinary downstream output, and an explicit target-only Stop; requires a supporting platform endpoint

Read them in order if you are new to the platform. Tutorials 1 and 2 only use the four required hooks. Tutorial 3 adds the optional hooks, tutorial 4 adds error handling and a service hook, tutorial 5 leaves the Mock Runner for a real transport, and tutorial 6 requires a supporting platform endpoint and rebuilt SDK 2.45.0 node images.

Tutorial 3 polls self.is_paused() inside on_execute, because pausing a node suspends nothing on its own. The example falls back to a flag set in on_pause when it runs on an SDK older than 2.39.0, which has no is_paused().

The tutorials raise the older exceptions

Every tutorial node raises NodeExecutionError and NodeConfigurationError, the family that also works on SDKs older than 2.42.0 and is not being removed. New node code should raise the typed errors instead, which give the caller an accurate gRPC status, a message that never leaks node internals and retry advice. The mapping from one to the other is a table in Errors, and examples/errors/gripper_node/ is a node written the new way.

Custom service example

The standalone CRUD example in examples/custom_services/ hosts a generated gRPC API with an in-memory database substitute and no graph nodes. Python and C++ share its proto and client-visible behavior. Its README gives generation, startup, authentication, and client commands.

Run this application in the SDK runtime, rather than mounting it as a node in the Mock Runner. See Custom gRPC services for registration, reflection, and lifetime rules.

Prerequisites

The Quickstart environment is all you need: Docker with Compose v2, access to the NEURA container registry, and a running Mock Runner. No Python, ROS 2 or Poetry on the host.

You need an engine only to see triggers wired for real: the error output of tutorial 4 starting ErrorHandlerNode, or a graph-wide pause reaching tutorial 3. The Mock Runner does not evaluate triggers; you click Execute on each node yourself. Tutorial 5 shows the alternative: one MQTT broker container plus a demo script run the two nodes end to end without an engine.

Where the code lives

All tutorial code is in the examples/tutorials folder of the SDK repository (neuraverse-node-sdk-python), one folder per tutorial, laid out like a node project's src/:

examples/tutorials/
  math_node/     math_node.py        math_node_schema.json        test_math_node.py
  image_node/    image_node.py       image_node_schema.json       test_image_node.py
  smart_home/    smart_home_node.py  smart_home_node_schema.json  test_smart_home_node.py
  cloud_node/    cloud_node.py       cloud_node_schema.json       test_cloud_node.py
                 error_handler_node.py  error_handler_node_schema.json  service.py
examples/custom_triggers/
                 watchdog_node.py    watchdog_node_schema.json
                 worker_node.py      worker_node_schema.json      run_local_demo.py

The tutorial pages show this code through snippets, never a retyped copy, so the page and the file cannot drift apart. The SDK test suite runs every example node through configure, an in-memory data flow and on_execute with one message per data input, and checks every schema against its class. When a tutorial page says "publishes sum", a test has asserted it.

The Python packages the tutorials import beyond the SDK (numpy, opencv-python-headless, requests, tenacity) are dependencies of the SDK itself, so they are present in the Mock Runner image and in the node base image. Your own extra packages go into pyproject.toml, see Project layout and build.

Run a tutorial in the Mock Runner

The Mock Runner backend imports every module it finds under one mounted directory. Give it the tutorials in either of two ways.

From a checkout of the mock-nodegraph repository, point SRC_DIRPATH at the tutorials folder of the SDK repository. Use an absolute path.

cd mock-nodegraph
SRC_DIRPATH=/absolute/path/to/neuraverse-node-sdk-python/examples/tutorials docker compose up -d

All four tutorial nodes plus ErrorHandlerNode appear in the palette after Reload Code. Use examples/custom_triggers as the path for tutorial 5.

Copy one tutorial folder next to your own nodes and start the Mock Runner services from the template as in the Quickstart. The template mounts its src/ directory into the backend.

cp -r /path/to/neuraverse-node-sdk-python/examples/tutorials/math_node node-template/node-template/src/
cd node-template/node-template
docker compose up -d mock-backend mock-frontend docs

Click Reload Code if the Mock Runner was already running. This is also the way to make a tutorial the starting point of your own node: rename the folder, the two files and the class, and update executionContext.className.

The backend skips test_*.py files and any folder whose name starts with an underscore, so the test files can stay where they are. Everything else under the mounted directory must import cleanly; one failing import aborts the whole reload and the palette keeps its previous list (docker compose logs mock-backend shows the error).

Then, in the browser, the same sequence as in the Quickstart: Reload Code, drag the node onto the canvas, Init, Configure, Override the inputs, Execute. What to enter per tutorial:

Tutorial Configuration on the card Inputs to override Expected output
1 Math no card widgets; offset is the static value in the schema's configuration block (0.0) a = 1.5, b = 2.0 sum = 3.5
2 Image scale slider image_in cannot be typed in by hand; wire FloatPublisherNode from the node template upstream and Execute it first, so run this one from a src/ that holds both nodes (the copy tab) a JPEG on image_out, previewed in the Outputs tab
3 Device switch simulate on, keep the default light_ip command_in = ON or OFF status_out = the command and a [simulation] line in the node logs; any other text is ignored with a warning
4 Cloud keep dry_run on (the default) data_to_upload = any text upload_status = DRY_RUN; nothing leaves the machine
4 Cloud, ErrorHandlerNode none none an info line saying it was started normally; the error branch runs only when an error trigger starts it, which needs an engine
5 Custom triggers anomalies_to_report on the watchdog none the Mock Runner rejects a bad @trigger_handler at Init, but does not deliver the trigger; use the broker demo on the tutorial page

Overrides exist only after Configure, and Configure resets every port. Init reuses the code imported at the last Reload Code; after editing a file reload first, then Init again.

Conventions every tutorial follows

Each tutorial applies the same rules, stated once in the concept pages and repeated here so you can spot them in the code:

Rule Where it is explained
Port keys are lowercase snake_case; trigger inputs start, stop; trigger outputs start, error; no stop output, because the SDK fires every declared Stop output after each successful on_execute Schema file reference
on_configure(self, config, dynamic_config=None) always receives two positional arguments; config is the static string map from the schema, dynamic_config the typed UI values or None Configuration
on_get_configuration returns typed NodeConfigEntry values; read them back with get_config_value(key, config, dynamic_config) Configuration
self.get_data(port) returns the last ROS 2 message or None; read the payload through msg.data and guard the None case Dataflow
self.publish(port, msg) needs a ROS 2 message object; a bare str or float is dropped Dataflow
The body of on_execute is wrapped in try/except and raises NodeExecutionError, which fires the error trigger Triggers
Setup lives in on_configure, release in on_cleanup; __init__ holds plain defaults only Lifecycle and states
Log with self.log_info, self.log_warning, self.log_error, never print() Node anatomy
executionContext.className in the schema equals the Python class name; the schema file is named <module>_schema.json next to <module>.py Schema file reference

The optional hooks used in tutorials 3 and 4 have their own pages: Health reporting, Simulation mode and Service-level hooks. How to unit test any of these nodes without ROS 2 on your machine is in Testing.