ROS2 Graph Introspection - Node/Topic Snapshot

Medium ROS2 Core 0% pass rate

Practice the ROS2 Graph Introspection - Node/Topic Snapshot coding problem in ROS2 Core. Browser-based execution with automated grading — no local ROS install required. 0% of engineers pass this challenge.

Problem Statement

Implement a graph inspector node that periodically queries the ROS2 graph and logs a structured snapshot.

Requirements

Your node must:

  • Use create_timer(3.0, ...) to take a graph snapshot every 3 seconds
  • In each snapshot, call:
    • self.get_node_names() — returns list of node names
    • self.get_topic_names_and_types() — returns list of (topic_name, [type_strings])
    • self.get_service_names_and_types() — returns list of (service_name, [type_strings])
  • Log the counts: f"Graph: {n_nodes} nodes, {n_topics} topics, {n_services} services"
  • Publish the snapshot as a JSON std_msgs/String on /graph_snapshot containing:
    { "nodes": [...], "topics": [...], "services": [...] }
    
  • Log "Graph Inspector Ready" on startup

Input / Output

Output: std_msgs/String on /graph_snapshot every 3 seconds

🤖 Why This Matters in Real Robots

Health monitoring systems use graph introspection to detect when critical nodes crash and need to be restarted. Integration tests use it to assert that all expected topics are present before running a scenario. ROS2's component container and lifecycle manager use it to coordinate node startup order.

⚠️ Common Pitfalls

  • get_node_names() vs get_node_names_and_namespaces(): get_node_names() returns just names. get_node_names_and_namespaces() returns tuples — don't confuse them.
  • The node sees itself: Your own node name will appear in the graph. This is normal.

Frequently asked questions

What is the ROS2 Graph Introspection - Node/Topic Snapshot practice problem?

It is a hands-on ROS2 Core challenge on SimuCode where you implement and run ROS2 code in the browser with runtime-verified tests.

How do I practice ROS2 Graph Introspection - Node/Topic Snapshot online?

Open this page, sign in, and solve the problem in the built-in IDE. Your solution is graded against real ROS2 execution checks.

What skills does ROS2 Graph Introspection - Node/Topic Snapshot test?

This Medium problem focuses on ROS2 Core skills used in robotics interviews and production systems.