ros_d2
Exports ROS2 nodes (publishers, subcribers and services) into a D2 file so they can be visualised and serialised for later use.
Features
- Export runtime ROS2 system architecture (nodes, services, topics, clients) 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
- Action servers / clients?
- Topic Types (
--verboseflag) - Advanced theming
- Pytest helpers that ensure your ROS2 System architecture matches that of your .d2 diagram
- Better testing on this repo!
-
ros_d2 export-launch-filescommand that will export a .d2 file for each of your launch files -
ros_d2 rendercommand that will render all .d2 files in the current directory
Examples
Simple
More complex applications
Installation
pip install ros-d2
ros_d2 export --help # prints help
# If you get an error about "No module named 'ros2cli'" - ros has not been sourced!
Requirements
- ROS2 + Colcon
- D2
Usage
Exporting a diagram
- Launch your ROS2 system
- Source ROS
- Use
ros_d2to export your runtime ros system to a .d2 file
ros_d2 export ros-diagram.d2
- Render your diagram using
d2.
ros_d2 render # to render ALL .d2 files in the current directory
# or...
d2 --layout dagre ros-diagram.d2 # to use d2 directly
Exporting diagrams for all launch files
If you want to create a .d2 and .svg alongside each of your ros2 .launch.py files. You can use the following script:
# Source ros: eg) `source /opt/ros/humble/setup.bash`
# Build your ros2 workspace: eg) `colcon build`
# Source your ros2 workspace: eg) `source install/setup.bash`
ros_d2 export-launch-files
ros_d2 render
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:
- Build this project using colcon
source /opt/ros/galactic/setup.bash
colcon build
ros_d2 --help # prints help
- Let's bring up the example nodes:
source install/setup.sh
ros2 launch ./src/ros_example_adder_node/launch/example_adder_node.launch.py
- Now that ROS is running, lets use
ros_d2to generate a diagram of all the nodes in the system:
ros_d2 export example_output/ros-diagram.d2
- 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:
Elk:
- We can also export with more info using
ros_d2 export example_output/ros-diagram.d2
Metadata
Release files for ros-d2 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ros-d2-1.0.5.tar.gz | 6.6 kB | Without provenance | Details for ros-d2-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ros_d2-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for ros_d2-1.0.5-py3-none-any.whl |
Total release size: 14.1 kB
Release files / ros-d2-1.0.5.tar.gz
| Download URL | ros-d2-1.0.5.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f6348a74ff2909579ec30d36732ef52ce47b0257f5e2cf91949678297c6bbdf
|
|
BLAKE2b-256 checksum How to use checksums |
0752d53b6c8eb1448b0b23682f971cc2ef771312c4e59568afd9f466de23f1e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / ros_d2-1.0.5-py3-none-any.whl
| Download URL | ros_d2-1.0.5-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf6e8b42f8c4cd16fafe5e4ffdf2c6d2fc41cd19996b03e8a6dcb5b041fa0e5b
|
|
BLAKE2b-256 checksum How to use checksums |
f6f3d654ca6c2da106591eb8cc48be9728f94ecd626430694dee50aa7e52c7c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for ros-d2 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.