From browser to a real robot
The browser taught the graph and control loop. A real ROS 2 installation adds packages, dependencies, build tools and middleware. These commands belong on a real machine, not in the learning terminal.
A Python workspace
ros2_ws/
└── src/
└── camera_detector/
├── package.xml
├── setup.py
├── setup.cfg
├── resource/
│ └── camera_detector
└── camera_detector/
├── __init__.py
└── detector.pyUse ament_python for a Python package. package.xml declares dependencies and metadata. setup.py packages the module and registers a console_scripts entry point such as detector = camera_detector.detector:main. setup.cfg installs scripts where ros2 run expects them. Put node creation and spinning inside main().
cd ~/ros2_ws colcon build source install/setup.bash ros2 run camera_detector detector
First source your installed ROS distribution’s setup.bash and install the declared dependencies. colcon builds packages; sourcing install/setup.bash makes the built workspace discoverable. Python-only exercises do not require writing CMake.
Custom interfaces and CMake
ros2learn_interfaces/
├── CMakeLists.txt
├── package.xml
├── msg/
│ └── TargetInfo.msg
└── action/
└── DriveDistance.actionReal custom-interface packages use ament_cmake and rosidl_generate_interfaces to generate language bindings during the build. The browser provides the small Python classes directly; it does not run an interface generator. CMakeLists.txt also belongs in future C++/ament_cmake packages, not in the core Python exercises.
What changes on a real robot?
Install real rclpy and message packages through your ROS distribution. Replace educational helpers with logging or your own tests. Provide real camera/LiDAR drivers, correct QoS, a real TF broadcaster and an action server matching your interface. TF timestamps, middleware discovery, executors and hardware safety now matter. Begin with a simulator or a stationary robot before enabling motion.
The browser’s 2-second velocity timeout, bounded callbacks, latest-only planar TF and limited action server are teaching choices. They are not guarantees from ROS 2.
Official ROS 2 package tutorial · Official custom-interface tutorial