Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph archetype #6898

Open
vmayoral opened this issue Jul 15, 2024 · 5 comments
Open

Graph archetype #6898

vmayoral opened this issue Jul 15, 2024 · 5 comments
Labels
enhancement New feature or request 🍏 primitives Relating to Rerun primitives 📺 re_viewer affects re_viewer itself

Comments

@vmayoral
Copy link
Contributor

Most of the computations in robotics are expressed in the form of computational graphs. Whether you use ROS, ROS 2 or alternative frameworks, this seems to be the general consensus.

imagen

(an arbitrary ROS graph)

Besides their use for dev-purposes, these graphs are a fundamental tool when visualizing a robot's architecture. Most ROS-related graph representations are lacking. There's an interesting opportunity to get this right within rerun. That would make it much more useful for roboticists.

@vmayoral vmayoral added enhancement New feature or request 👀 needs triage This issue needs to be triaged by the Rerun team labels Jul 15, 2024
@nikolausWest
Copy link
Member

Thanks @vmayoral!

There's an interesting opportunity to get this right within rerun.

could you expand on this? Sounds very interesting!

@vmayoral
Copy link
Contributor Author

Hey @nikolausWest,

I'll try to expand on both the motivation and on the technical approach, sure:

  • Motivation-wise: (As I believe you folks know already) Robots are networks of networks, with sensors capturing data, passing to compute technologies, and then on to actuators and back again in a deterministic manner. These networks can be understood as the nervous system of the robot, passing across compute Nodes, that represent neurons. Like the human nervous systems, real-time information across all these computational Nodes is fundamental for the robot to behave coherently. "Robot brains" are built with this same philosophy. Behaviors take the form of computational graphs, with data flowing between Nodes, across physical networks (communication buses) and while mapping to underlying sensors, compute technologies and actuators. Frameworks like ROS enables you to build these computational graphs and create robot behaviors by providing libraries, a communication infrastructure, drivers and tools to put it all together. Alternatives to ROS also bet into this graph-like concepts. In a way, robot behaviors derive from the dataflow across these graphs, thereby getting a good representation of such (computational) graphs is fundamental for robot visualization.
  • Technically (getting this right1): Let me start by telling you what works with limitations and what doesn't, and then throw a few suggestions.
    • Most of us still rely on rqt_graph for (robot) graph visualization. This tool hasn't evolved alongside modern software concepts in robotics (aspects such as ROS Components as opposed to Nodes (or Nodelets) aren't depicted). There're plenty of limitations on this regard. You still can't easily properly represent other-than-pub/sub relationships into these graphs, for example client-server interactions such as ROS services.
    • Web-based alternatives to rqt_graph that I know are very lacking. For example Foxglove's Topic Graph is useless, probably resulting from a lack of understanding of the criticality of these graphs for demonstrating/showcasing/building/repairing/improving/debuging robots. There're other web-based robot graph visualizations that have been prototyped, but they simply lack the simplicity, (programming) usability, easy of customization and responsiveness that you folks at rerun seem to be taking at your core.
    • Suggestions:
      • Graphs should be simple to visualize, responsive and easy to custom programatically.
      • It should be possible to represent basic pub/sub interactions between nodes in the graph as well as other communication paradigms, capturing abstractions like ROS services or actions.
      • Ease of graph customization is key for succeeding in my opinion. Modern/custom aspects such as depicting subgroups within the graph to capture Components vs Nodes, or inter-network vs intra-network communications within a robotic system come to mind as relevantly unmet.
      • There's a huge opportunity in rerun to make use of theSelectionPanel to further augment information by selecting a node in the graph. This information could/should bet set programatically within each graph node, and could be extracted/relied from data-frameworks like ROS. Things like frequency of interactions, bandwidth, latencies (max/mean/min), etc would be tremendously useful if used together with your already existing ploting capabilities (e.g. TimeSeriesView).

Footnotes

  1. I can only throw a few initial ideas on the getting right topic, as "getting it right" would likely require iterations and feedback for its achievement

@nikolausWest
Copy link
Member

@vmayoral: we're considering giving this a go soon. Would you be willing to feedback on some early designs / requirements to help us make sure we actually get it right?

@grtlr
Copy link
Contributor

grtlr commented Sep 17, 2024

I've written down a proposal for extending the data model to handle graphs here: #7431. This could be a first step to implement the use cases that @vmayoral describes here.

@Wumpf Wumpf added 📺 re_viewer affects re_viewer itself 🍏 primitives Relating to Rerun primitives and removed 👀 needs triage This issue needs to be triaged by the Rerun team labels Oct 11, 2024
grtlr added a commit that referenced this issue Nov 25, 2024
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

Tracking issue: #7897 

This implements basic graph primitives in the Rerun data model. This is
a first step towards visualizing node-link diagrams in Rerun (related
issue: #6898).

In addition to the changes to the data model, this PR adds two example
crates, `node_link_graph` and `graph_view` to the Rust examples that
show how these primitives can be used.

## Design Decisions

- Nodes and edges are stored as `components` and can be batched. To have
a single node per entity we can use Rerun’s [[clamping
mechanism](https://rerun.io/docs/concepts/batches#component-clamping)](https://rerun.io/docs/concepts/batches#component-clamping).
- `GraphNodeId` is modeled as ~`u32` to improve performance when using
`petgraph`~ strings for better user experience.
- A node is unique identified by combining its `GraphNodeId` and its
`EntityPath`.
- Labels of the nodes can be set via the `labels` component and toggled
via `show_labels`
- ~Hierarchical graphs can be modeled through entity paths. For edges
that cross entity boundaries we can insert dummy nodes to properly
render subparts of the hierarchy.~
- ~Nodes and edges need to be logged to the same entity, otherwise the
selections will collide. We provider helper functions / conversions to
link nodes that are stored in different entities.~

> [!WARNING]
> This PR has changed considerably from its initial version:
> * No linking of nodes between entities (an therefore hierarchy) yet.
> * For now, Graphs are local only and therefore have to be logged to
the same entity.

## Logging example

```rs
rec.log(
        "simple",
        &rerun::GraphNodes::new(["a", "b", "c"])
            .with_positions([(0.0, 100.0), (-100.0, 0.0), (100.0, 0.0)])
            .with_labels(["A", "B", "C"]),
    )?;
    // Note: We log to the same entity here.
    rec.log(
        "simple",
        &rerun::GraphEdges::new([("a", "b"), ("b", "c"), ("c", "a")]).with_directed_edges(),
    )?;
```

## TODOs

- [x] ~Get rid of the `Default` derive for `GraphNodeId` and `GraphEdge`
in the flatbuffer definitions.~
- [x]  Improve ergonomics for generating graph edges during logging.
- [x]  Ensure that logging works from Python and C++ too.
- [x]  Fix remaining lints.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7500?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7500?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7500)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.

---------

Co-authored-by: Antoine Beyeler <antoine@rerun.io>
Co-authored-by: Andreas Reich <r_andreas2@web.de>
emilk pushed a commit that referenced this issue Nov 25, 2024
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

Tracking issue: #7897 

This implements basic graph primitives in the Rerun data model. This is
a first step towards visualizing node-link diagrams in Rerun (related
issue: #6898).

In addition to the changes to the data model, this PR adds two example
crates, `node_link_graph` and `graph_view` to the Rust examples that
show how these primitives can be used.

## Design Decisions

- Nodes and edges are stored as `components` and can be batched. To have
a single node per entity we can use Rerun’s [[clamping
mechanism](https://rerun.io/docs/concepts/batches#component-clamping)](https://rerun.io/docs/concepts/batches#component-clamping).
- `GraphNodeId` is modeled as ~`u32` to improve performance when using
`petgraph`~ strings for better user experience.
- A node is unique identified by combining its `GraphNodeId` and its
`EntityPath`.
- Labels of the nodes can be set via the `labels` component and toggled
via `show_labels`
- ~Hierarchical graphs can be modeled through entity paths. For edges
that cross entity boundaries we can insert dummy nodes to properly
render subparts of the hierarchy.~
- ~Nodes and edges need to be logged to the same entity, otherwise the
selections will collide. We provider helper functions / conversions to
link nodes that are stored in different entities.~

> [!WARNING]
> This PR has changed considerably from its initial version:
> * No linking of nodes between entities (an therefore hierarchy) yet.
> * For now, Graphs are local only and therefore have to be logged to
the same entity.

## Logging example

```rs
rec.log(
        "simple",
        &rerun::GraphNodes::new(["a", "b", "c"])
            .with_positions([(0.0, 100.0), (-100.0, 0.0), (100.0, 0.0)])
            .with_labels(["A", "B", "C"]),
    )?;
    // Note: We log to the same entity here.
    rec.log(
        "simple",
        &rerun::GraphEdges::new([("a", "b"), ("b", "c"), ("c", "a")]).with_directed_edges(),
    )?;
```

## TODOs

- [x] ~Get rid of the `Default` derive for `GraphNodeId` and `GraphEdge`
in the flatbuffer definitions.~
- [x]  Improve ergonomics for generating graph edges during logging.
- [x]  Ensure that logging works from Python and C++ too.
- [x]  Fix remaining lints.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7500?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7500?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7500)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.

---------

Co-authored-by: Antoine Beyeler <antoine@rerun.io>
Co-authored-by: Andreas Reich <r_andreas2@web.de>
@grtlr
Copy link
Contributor

grtlr commented Nov 26, 2024

Quick Update: With #7500 the graph primitives have landed in Rerun. The next steps are working laying out these graphs, so that they can also be used to visualize ROS node/topic graphs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🍏 primitives Relating to Rerun primitives 📺 re_viewer affects re_viewer itself
Projects
None yet
Development

No branches or pull requests

4 participants