Create subscriber_member_function.py in the same directory. class MinimalSubscriber(Node) calls super().__init__('minimal_subscriber') and self.subscription = self.create_subscription(String, 'topic', self.listener_callback, 10); listener_callback(self, msg) logs 'I heard: %s' % msg.data. Same main() pattern.
Edit ros2_ws/src/py_pubsub/package.xml: fill description/maintainer/license, then add <exec_depend>rclpy</exec_depend> and <exec_depend>std_msgs</exec_depend>.
Edit setup.py entry_points: console_scripts must list both 'talker = py_pubsub.publisher_member_function:main' and 'listener = py_pubsub.subscriber_member_function:main'.
From the workspace root check dependencies (Linux): `rosdep install -i --from-path src --rosdistro lyrical -y`.
New terminal: `cd ~/ros2_ws && source install/setup.bash && ros2 run py_pubsub talker` - expect a line every 0.5 s.
Another new terminal, source again, then `ros2 run py_pubsub listener` - expect `I heard: Hello World: N`. Ctrl+C both to stop.
Official doc: https://docs.ros.org/en/lyrical/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.html
Known gotchas
Topic name ('topic') and message type (String) must match exactly on both sides or the nodes silently never connect.
Both entry points must appear under console_scripts in setup.py, otherwise `ros2 run py_pubsub talker` reports no executable found.
Missing <exec_depend>rclpy</exec_depend> / <exec_depend>std_msgs</exec_depend> leaves runtime deps undeclared even though the code imports them - rosdep and downstream installs then break.
You must open a NEW terminal and re-source install/setup.bash after building; the build terminal environment is stale.
The tutorial wraps init/spin in try/except (KeyboardInterrupt, ExternalShutdownException) - omitting it makes Ctrl+C raise an unhandled exception at shutdown.
On Windows: `colcon build --merge-install --packages-select py_pubsub` and `call install/setup.bat`.
Give your agent this knowledge — and 16,000+ more routes
One MCP install gives any agent live access to the full route map across 5,800+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?