Visualize Nodes in a intutive Directed Acyclic Graph format - Get realtime updates
Try Demo
Demo: Real-time visualization of ROS 2 control system
Table of Contents
This project is a ROS 2-based Directed Acyclic Graph (DAG) visualizer that subscribes to a custom topic, processes incoming messages, and updates a graph dynamically. The graph is interactive, displays metadata, and distinguishes edges based on the message attributes.
- ROS 2 Subscription & Service Call: A ROS 2 node subscribes to a topic and sends a service request.
- Custom Message Definition: Implements a custom message format for defining directed edges.
- TypeScript-based Graph Visualization: The DAG is displayed using TypeScript, earning extra points for interactivity and metadata display.
- Dynamic Graph Updates: Graph updates in real-time based on received ROS messages.
- Metadata Display: Each node contains metadata information for better visualization.
- Edge Coloring Rules:
- Command interface (
command_interface = true): Edge is shown in a specific color. - State interface (
state_interface = true): Another distinct color. - Hardware-based (
is_hardware = true): Highlighted accordingly.
- Command interface (
This project defines a custom ROS 2 message type:
string start
string end
bool command_interface
bool state_interface
bool is_hardware
string metadata-
For ROS package
- Install ROS2 - Jazzy (Documentation)
- Clone and Setup ROS2 Workspace - ros2-control-viz
-
For Web Interface
- Node.js (LTS recommended)
npm or yarn- Clone and Setup Web Interface - ros2_control_web
- TurtleSim package (for the TurtleSim example)
-
Clone the repository
git clone https://github.com/Malay-dev/ros2_control_web.git cd ros2_control_web -
Install dependencies
npm install
-
Start the development server
npm run dev
-
Access the web interface
- Open your browser and navigate to http://localhost:3000
- The interface will show "Disconnected" status initially
-
Set up the ROS2 backend
- Make sure you have installed and configured ros2_control_viz
- Follow the instructions in the ROS2 Package Setup section to start the backend
-
Verify connection
- When the ROS2 backend is properly running, the web interface will automatically connect
- Connection status will change to "Connected"
- Control values will begin populating in real-time
First, ensure you have all necessary dependencies:
# Install ROS 2 dependencies
sudo apt update
sudo apt install -y ros-jazzy-turtlesim
# Install Python dependencies
pip3 install websockets asyncio- Create a new ROS 2 workspace or use an existing one:
# Create a new workspace (if needed)
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
# Clone the repository
git clone https://github.com/Malay-dev/ros2_control_viz.git- Build the workspace:
cd ~/ros2_ws
colcon build --symlink-install- Source the workspace:
source ~/ros2_ws/install/setup.bashTip: Add this line to your ~/.bashrc file to automatically source the workspace in every new terminal:
echo "source ~/ros2_ws/install/setup.bash" >> ~/.bashrcThis example demonstrates the core functionality of publishing and subscribing to graph updates:
- In one terminal, run the graph subscriber:
ros2 run ros2_control_viz graph_subscriber- In another terminal, run the graph publisher:
ros2 run ros2_control_viz graph_publisherYou should see output in the subscriber terminal showing the connections being published:
[INFO] [graph_subscriber]: Received: A -> B | Metadata: {"type": "controller", "priority": 1, "rate": "100Hz"}
[INFO] [graph_subscriber]: Received: B -> C | Metadata: {"type": "state_handler", "priority": 2, "status": "active"}
...
This setup connects the graph publisher to a web interface for visual representation:
- Start the WebSocket bridge server:
ros2 run ros2_control_viz web_socket_graph- In another terminal, run the graph publisher:
ros2 run ros2_control_viz graph_publisher- In a web browser, navigate to the web interface:
- If using the hosted demo: https://ros-control-viz.vercel.app/
- If running locally: http://localhost:3000
You should see a live visualization of the graph with color-coded edges indicating command interfaces, state interfaces, and hardware components.
Visualization Legend:
-
Controller -
Hardware/Actuator -
Joint -
Other -
Command Interface -
State Interface -
Other Connection Solid Linefor edgeDashed Linefor edge update
This example visualizes the data flow between TurtleSim and teleop controls:
- Start the WebSocket bridge server:
ros2 run ros2_control_viz web_socket_graph- In another terminal, start the TurtleSim node:
ros2 run turtlesim turtlesim_node- In another terminal, start the TurtleSim teleop:
ros2 run turtlesim turtle_teleop_key- In a fourth terminal, start the turtle graph publisher:
ros2 run ros2_control_viz turtle_graph_publisher-
Open the web interface at http://localhost:3000 (or the hosted demo)
-
Use the arrow keys in the teleop terminal to control the turtle
The visualization will update in real-time, showing:
- Commands flowing from the teleop to the turtle
- State information flowing from the turtle
- Metadata including position and velocity
-
"Package 'ros2_control_viz' not found":
- Make sure you've built the workspace:
cd ~/ros2_ws && colcon build - Ensure you've sourced the workspace:
source ~/ros2_ws/install/setup.bash
- Make sure you've built the workspace:
-
WebSocket connection issues:
- Check that the WebSocket server is running
- Verify that port 8765 is not blocked by a firewall
- Check the server logs for any connection errors
-
No visualization in the web interface:
- Ensure the WebSocket server shows a "connected" status in the web interface
- Verify that graph updates are being published (check the publisher terminal)
- Try refreshing the web interface
You can publish your own graph updates from the command line:
ros2 topic pub /graph_update ros2_control_viz_interfaces/msg/GraphUpdate '{start: "Custom1", end: "Custom2", command_interface: true, state_interface: false, is_hardware: true, metadata: "{\"description\": \"My custom connection\"}"}'Note: Checkout turtle_connector.py for more info on how to translate your custom package msgs to GraphUpdate.msg
- Add Readme
- Stricter Type Checks
- User Interface/User Experience
- Dynamic Layout lags
- Research for better graph simulations
- Add More Example Connectors
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star⭐! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt for more information.
Malay Kumar - Twitter (X) @void_MalayK | LinkedIn @malayk





