ROS2 Examples
These examples demonstrate how to integrate ROS2 applications with Roboticks. All code is available in the roboticks-examples repository.Hello World Example
A simple ROS2 node that publishes messages, managed by Roboticks. This is the perfect starting point for understanding the integration.What It Does
- Publishes “Hello from Roboticks!” messages at a configurable rate
- Accepts input to dynamically update the message
- Records all messages to a rosbag for later analysis
- Demonstrates automatic restart on crash
Project Structure
The ROS2 Node
A standard ROS2 node - nothing Roboticks-specific:Module Configuration
The Roboticks module configuration tells the system how to manage your node:ROS2 Interface
| Topic | Type | Description |
|---|---|---|
/roboticks/hello_world/output | std_msgs/String | Published messages |
/roboticks/hello_world/input | std_msgs/String | Update the message dynamically |
/roboticks/hello_world/status | std_msgs/String | Node status (JSON) |
| Service | Type | Description |
|---|---|---|
/roboticks/hello_world/enable | std_srvs/SetBool | Enable/disable publishing |
Running the Example
Build the ROS2 package:Interacting with the Running Node
While the session is running, you can interact with the node via ROS2:Composition Example
The composition bundles multiple modules together:What Gets Recorded
During a session, Roboticks automatically captures:| Data | Location | Access |
|---|---|---|
| Module logs | Cloud | Dashboard → Sessions → Logs |
| ROS2 node logs | Cloud | Dashboard → Sessions → Logs |
| Rosbag files | Cloud | Dashboard → Sessions → Artifacts |
| Node status | Cloud | Real-time in dashboard |
Best Practices
Namespace your topics
Namespace your topics
Use a consistent namespace for all your topics:This makes rosbag recording and debugging easier.
Use parameters for configuration
Use parameters for configuration
Make your nodes configurable via ROS2 parameters:Roboticks can then set these parameters at launch time.
Publish status periodically
Publish status periodically
Add a status topic that publishes node health:This helps with monitoring in the dashboard.
Handle graceful shutdown
Handle graceful shutdown
Your node should clean up properly on SIGTERM:
More Examples
Check the roboticks-examples repository for more examples:- Ros2BridgeModule - Bidirectional bridge between ROS2 and Roboticks
- HelloWorldModule - Non-ROS2 example showing basic module concepts
- Custom compositions - Examples of multi-module setups