Skip to main content

Exports ROS2 nodes into the .d2 diagram format

Project description

ros_d2

Banner

Exports ROS2 nodes (publishers, subcribers and nodes) into a D2 file so they can be visualised and serialised for later use.

Features

  • Export runtime ROS2 system architecture to .d2 (using ros2cli)
  • Powerful visualisation and theming provided by D2
  • Simple serialisable diagram format
  • Ros node descriptions pulled from the package.xml
  • Topic QOS descriptions
  • Topic Types
  • Advanced theming
  • Pytest helpers that ensure your ROS2 System architecture matches that of your .d2 diagram

Examples

Simple

Simple example

More complex applications

Example

Installation

pip install ros-d2
ros-d2 --help # prints help

Requirements

  • ROS2 + Colcon
  • D2

Usage

  1. Launch your ROS2 system
  2. Source ROS
  3. Use ros_d2 to export your runtime ros system to a .d2 file
ros_d2 export ros-diagram.d2
  1. Render your diagram using d2 or on the playground using https://play.d2lang.com/
d2 --layout dagre ros-diagram.d2

Development

Prerequisite

Installation

following the steps below to setup the project:

```bash
# Clone the repository
git clone git@github.com:Greenroom-Robotics/ros-d2.git && cd ros-d2

# Install all dependencies
pip install -e ./src/ros_d2

Example usage

From the root of this repo:

  1. Build this project using colcon
source /opt/ros/galactic/setup.bash
colcon build

ros_d2 --help # prints help
  1. Let's bring up the example nodes:
source install/setup.sh
ros2 launch ./src/ros_example_adder_node/launch/launch.py
  1. Now that ROS is running, lets use ros_d2 to generate a diagram of all the nodes in the system:
ros_d2 export example_output/ros-diagram.d2
  1. We will now have the example_output/ros-diagram.d2 file. We can render this using d2:
d2 --layout dagre example_output/ros-diagram.d2 example_output/ros-diagram-dagre.svg
# or
d2 --layout elk example_output/ros-diagram.d2 example_output/ros-diagram-dagre.svg
# Note - d2 provides other layouts and themes. See `d2 --help` for more info

This will produce the following diagram:

Dagre: dagre

Elk: elk

  1. We can also export with more info using ros_d2 export example_output/ros-diagram.d2

dagre

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ros-d2-1.0.2.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

ros_d2-1.0.2-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page