Phase 02 · Week 5 · 105 minutes

Day 34: Lifecycle nodes, composition, namespaces, launch, and introspection

ROS 2 graph, runtime, and communication · Treat ROS as a concurrent distributed production system.

Chapter 05 · Build and debug a real ROS 2 system

Today in the field story

One problem, then the next

The Aisle Seven Watchdog must now start twice for two robot namespaces without publishing commands before dependencies are ready. Use parameters, relative names, lifecycle states, and one launch description; choose process or composition boundaries from latency and fault containment. Inspect effective configuration and transition order rather than accepting a successful launch command as proof of readiness.

Why now

Reusable deployment needs explicit identity, configuration, lifecycle, and observability before fault policy is enabled.

Ignore today

Ignore composing every component for speed; shared-process failure is part of the decision.

Unlocks next

A repeatable multi-instance bring-up path for robot models and simulation.

Understand

Build the physical picture first

A production ROS system needs more than a pile of start commands. Namespaces give each robot an address, launch is the checked opening routine, lifecycle states prevent a component from working before it is ready, composition chooses which workers share a room, and introspection is the roll call.

Managed lifecycle nodes expose defined primary states such as unconfigured, inactive, active, and finalized, plus transitions including configure, activate, deactivate, cleanup, and shutdown. Configuration can allocate resources and validate parameters; activation can begin publishers or task work only after dependencies are ready. A transition can fail and must report why. Not every ordinary ROS node implements the lifecycle interface, so inspect capability rather than assuming a lifecycle command applies.

Composition loads multiple component nodes into one process. It can reduce process and communication overhead and support efficient intra-process transfer, but it also changes failure isolation: a crash or resource problem can affect every component in the container. Separate processes cost more but provide clearer operating-system isolation and independent restart. Choose the boundary from latency, copying, resource use, fault containment, security, and deployment needs; do not compose everything merely because the tool exists.

Namespaces and remapping let reusable node code run more than once without name collisions. A fleet might use /robot_01/telemetry and /robot_02/telemetry, while each node internally publishes relative name telemetry. Avoid hard-coded global names that escape the namespace. Parameters configure a node instance; they need types, units, ranges, defaults, ownership, source, and startup validation. A parameter file plus launch arguments should make the effective configuration inspectable and versioned.

A launch description starts processes or components with explicit names, namespaces, remappings, parameter files, environment, conditions, and shutdown behavior. Launch order alone does not prove readiness: use lifecycle transitions, service/action availability, health state, or explicit events for dependencies. A reproducible bring-up captures the exact command, configuration revision, expected graph, and acceptance checks rather than relying on terminal history.

ROS CLI and rqt tools expose the live system: list and inspect nodes, topics, services, actions, parameters, lifecycle states, components, interfaces, logs, rates, bandwidth, and environment diagnostics. Use them as a structured investigation: identity and namespace, graph endpoints and types, QoS, timestamps/rates, parameters, lifecycle/readiness, logs, and process/network facts. The CLI often uses a discovery cache/daemon, so if evidence conflicts with process reality, verify both and refresh deliberately rather than trusting one stale view.

Words you need

Name each idea precisely

Lifecycle node

A managed node exposing standardized states and externally requested transitions.

Physical example:

A camera node can configure its device while inactive and publish only after activation.

Composition

Loading multiple component nodes into one operating-system process.

Physical example:

An image decoder and rectifier can share a component container to reduce copies.

Namespace

A hierarchical prefix that scopes ROS names so reusable instances do not collide.

Physical example:

The same telemetry node runs as /robot_01/telemetry_node and /robot_02/telemetry_node.

Remapping

Changing a ROS name at runtime without changing the node's source code.

Physical example:

A generic scan subscription is remapped to /front_lidar/scan for one robot.

Launch description

A versioned declaration that starts and configures a multi-process or composed ROS system.

Physical example:

One launch file starts simulation telemetry, watchdog, UI bridge, parameters, and namespaces.

Introspection

Inspecting the live graph, interfaces, configuration, state, and timing through ROS tools.

Physical example:

ros2 node info reveals that a node subscribes to a differently named topic than expected.

Math, one line at a time

Work through today’s relationship

Prerequisite rescue · optionalMessage rates, queues, and latency

ROS nodes form a distributed timing system; rates and queue depth decide freshness.

λ
messages arriving each secondUnit: messages/s
μ
messages processed each secondUnit: messages/s
latency
receive time minus source timestampUnit: milliseconds (ms)
  1. A camera publishes λ = 30 messages/s while a node processes μ = 20 messages/s.

  2. The backlog grows by λ − μ = 10 messages each second.

  3. A depth-5 queue fills in about 0.5 s; choose a QoS policy based on whether freshness or completeness matters.

Programmer analogy

ROS pub/sub resembles backend messaging, but an old robot message can command the wrong physical state.

Input is 50 Hz and processing is 40 Hz. How fast does backlog grow?

10 messages per second.

Two serialization steps add

ttransport=2(0.4)=0.8 ms.t_{\text{transport}}=2(0.4)=0.8\ \mathrm{ms}.

Relative to a 20 ms20\ \mathrm{ms} sensor period,

O=0.820×100%=4%.O=\frac{0.8}{20}\times100\%=4\%.

Design a two-robot launch and readiness sequence

Robot 01 and Robot 02 each need telemetry and watchdog nodes. Telemetry must validate a 10 Hz rate before the watchdog becomes active. Both robots run on the same development computer.

  1. Use relative node/interface names inside reusable packages and launch each pair under /robot_01 and /robot_02.

  2. Load separate parameter files containing publish_rate_hz: 10, freshness limits, robot identifier, and units.

  3. Launch telemetry nodes into unconfigured state, request configure, and reject startup if the rate or identifier is invalid.

  4. After telemetry reaches inactive/ready, configure the corresponding watchdog and inspect its subscriptions.

  5. Activate telemetry, observe approximately T = 1/10 = 100 ms samples, then activate the watchdog only after fresh data exists.

  6. Use node, topic, parameter, and lifecycle introspection to compare the live graph/state with the launch design for both namespaces.

  7. Stop Robot 02 telemetry and verify Robot 01's graph and state remain distinct and unaffected.

Result

Two namespaced node pairs start from one reusable launch pattern, validate instance-specific configuration, transition in dependency order, and can be inspected independently.

What this proves

Launch starts entities; lifecycle and health evidence decide readiness. Namespaces make reuse safe only when source code avoids accidental global names.

Physical examples

Where this appears in real life

Two identical AMRs

Two robots run the same telemetry, command, and watchdog software on one development network.

Look for:

Relative names under /robot_01 and /robot_02 prevent collisions; a hard-coded /cmd_vel can accidentally merge the systems.

Camera bring-up sequence

A camera driver must open the device, load calibration, and pass a self-test before consumers use images.

Look for:

Configure performs preparation, inactive exposes readiness without live data, activate begins publication, and a failed configure transition blocks activation with a reason.

Hands-on exercise

Make the idea observable

Extend the chapter's simulated telemetry and watchdog packages. Use a Python launch file and parameters; no hardware is connected.

  1. Move rates, freshness limits, robot ID, and log level into a typed YAML parameter file with stated units and valid ranges.

  2. Create a launch description that starts telemetry and watchdog under a launch argument robot_namespace and passes the parameter file.

  3. Run two instances under /robot_01 and /robot_02; inspect node names, topics, types, endpoints, and parameters for collision.

  4. If using lifecycle-capable versions, prove configure, activate, deactivate, cleanup, and one rejected transition; otherwise document exactly which ordinary nodes lack lifecycle support.

  5. Run one node separately and then as a component if your implementation supports composition; compare process count and state the changed fault boundary.

  6. Write a bring-up checklist whose acceptance evidence includes expected graph, effective configuration, readiness state, message rate/age, and clean shutdown.

Observe

The same source can produce distinct robot instances through namespaces and parameters. Starting every process successfully is weaker evidence than checking graph, readiness, and fresh data.

Done when

One command launches two collision-free namespaced systems, effective parameters are inspectable, readiness is explicit, a stopped instance does not change the other's names, and the bring-up checklist can be followed in a clean shell.

Build today

Build a Python/C++ telemetry, command, and watchdog system; then reproduce QoS, discovery, executor, lifecycle, and cancellation failures.

Evidence to save

DONE when a 60–120 second uncut “Lifecycle nodes, composition, namespaces, launch, and introspection” demo links to its command, logs or plots, result count, and honest failure note.

Common mistakes

Catch the wrong mental model

Wrong

Using process start order as proof that a dependency is ready.

Better

Gate on lifecycle/readiness or explicit interface/health evidence with timeout and failure reporting.

Wrong

Hard-coding absolute global topic names in reusable nodes.

Better

Use relative names, namespaces, and explicit remapping so instances remain isolated.

Wrong

Composing all nodes to reduce process count without considering faults.

Better

Balance copy/latency benefits against shared crash, resource, security, and restart boundaries.

Wrong

Reporting a successful launch command as system acceptance.

Better

Inspect graph, interface types/QoS, effective parameters, lifecycle state, fresh data, logs, and shutdown.

Job connection

How this becomes employable evidence

A deployment engineer turns a hand-started prototype into a repeatable robot bring-up: versioned launch and parameter files, namespaced fleet instances, ordered readiness, defined restart boundaries, and an introspection checklist for site technicians.

Relevant target roles

  • Robot Fleet Backend / Platform Engineer
  • Robotics Deployment, Integration & Validation Engineer
  • Robotics Application / ROS 2 Integration Engineer
  • Robotics Software Engineer — ROS 2 / AMR

Chapter 05 interview drill

Interview questions: Lifecycle nodes, composition, namespaces, launch, and introspection

Practise a 60–90 second answer: define the idea, connect it to a physical robot, state assumptions, frames, and units when relevant, then finish with the failure signal or evidence you would inspect.

Primary interview scenario

How would you launch the same navigation-facing node for ten robots without name collisions, and how would you prove each instance is configured and ready rather than merely running?

Answer shape: clarify the situation → trace the physical and software path → test the most likely boundaries → name the evidence that would confirm the result.

Technical follow-up questions

Q1What is the difference between inactive and active for a well-designed lifecycle publisher?
Model interview answer

Inactive means configured resources are ready but task publication is not enabled; active permits the node's intended runtime work.

Q2What major tradeoff changes when nodes are composed into one process?
Model interview answer

Communication/copy and resource overhead may improve, while crash, restart, and resource isolation become shared.

Q3Why does `/robot_01/telemetry` not guarantee isolation by itself?
Model interview answer

Other hard-coded global names, parameters, process resources, domains, or bridges can still cross boundaries; inspect the complete graph and configuration.