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

Feature/flexible layer #22

Open
wants to merge 56 commits into
base: develop
Choose a base branch
from
Open

Conversation

nathanhhughes
Copy link
Collaborator

This includes several major changes that I want to put in front of everyone sooner rather than later:

  • Replaces DynamicSceneGraphLayer with SceneGraphLayer and changes terminology: "dynamic" layers are now "partitions" of a layer (where the normal layers are partition 0)
  • Layers are no longer fixed at graph creation. You can add and remove layers as needed
  • Layers can be accessed by name; names are configurable. Layers can have multiple names.
  • I removed several scene graph methods that didn't make sense any more or were near duplicated of other functionality (e.g., setNodeAttributes was removed in favor of addOrUpdateNode)
  • SceneGraphNode no longer has a timestamp. Dynamics are being pushed to the attributes
  • Node emplacement has now changed to take an optional partition at the end of the list of arguments
  • Partitions are now just indexed by a plain integer (instead of the LayerPrefix class that could be constructed via a char). Most of the python functionality will still accept a char in place of an integer partition ID, but it'll map to the ascii value
  • The nodes and edges iterators over the scene graph iterate over ALL nodes (previously it used to only be static nodes)

I haven't updated Hydra, etc. yet so some of the API is still subject to change (I'm trying to use the python unit tests here and Hydra to make sure the API is sane / things don't change too much)

@nathanhhughes
Copy link
Collaborator Author

Last change that I forgot: There is no more IsolatedSceneGraphLayer: you can modify nodes and edges in the normal SceneGraphLayer (I previously disallowed this in case someone messed with the scene graph book-keeping by modifying a layer directly instead of modifying the scene graph, but I realized you would have to use const_cast to do this, which is a strong enough check against someone doing something silly)

Copy link
Contributor

@Schmluk Schmluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I think will make quite a few things nicer and easier to use!

* @param node_id node to get
* @returns a potentially valid node constant reference
*/
const SceneGraphNode* findNode(NodeId node_id) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: While we're at it, wanted to throw out the point of mutable/const access with pointer members. How much do we care about the scene graph actually not being modified (including node attributes etc) when it is constant? I know this requires more duplicate interfaces for const access but might make some designs (multi-threading, read-only) easier.

/**
* @brief Get a particular node in the layer
* @param node_id node to get
* @returns a potentially valid node constant reference
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can const refs be invalid?

*/
const SceneGraphNode* findNode(NodeId node_id) const override;
const SceneGraphEdge* findEdge(NodeId source, NodeId target) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: It would also be useful to have a findEdges(src) function that gives all connectivity of a node. Maybe that is already implemented somewhere else though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a connections() method that will get you the IDs of all the neighbors (but it is annoying to have to grab the edge attributes once you have those)

* @brief Get node id of deleted nodes
*/
void getRemovedNodes(std::vector<NodeId>& removed_nodes, bool clear_removed) override;
void getNewNodes(std::vector<NodeId>& new_nodes, bool clear_new) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for getting the result by reference? I usually like std::vector<NodeId> newNodes(bool clear_new=false) better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but these get used in the scene graph class to populate all the new nodes, etc. for every layer (so it feels slightly cleaner to fill an existing vector instead of returning a new one and inserting)

@@ -70,29 +69,13 @@ class SceneGraphNode {
* @param id the id of the node to create
* @param layer the layer that the node will belong to
* @param attrs attributes for the node
* @param timestamp Optional node timestamp in nanoseconds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still accurate?

}

return total_nodes;
}

size_t DynamicSceneGraph::numDynamicNodes() const {
size_t DynamicSceneGraph::numUnpartitionedNodes() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does unpartitioned nodes mean? This looks like just num nodes in DSG to me?

@@ -108,7 +120,7 @@ void parseEdge(const AttributeFactory<EdgeAttributes>& factory,

void writeLayer(const SceneGraphLayer& graph, std::vector<uint8_t>& buffer) {
BinarySerializer serializer(&buffer);
serializer.write(graph.id);
serializer.write(graph.id.layer); // we don't save partition IDs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to save these? Just thinking of confusion potential if partitions get re-shuffeled/indexed during I/O.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This serialization is distinct from the graph serialization. Layers can't be constructed standalone with a partition ID. I guess this would be a problem if you wanted to serialized a bunch of partitions from a graph independent of saving the graph (I think I punted on this because I didn't want to branch on file version)

nathanhhughes and others added 11 commits December 12, 2024 21:23
* forward declare DynamicSceneGraph where possible

* rework NodeSymbol and hide eigen in new file

* forward declare node attributes and some bounding boxes

* forward declare mesh for bounding box

* forward declare edge attributes and remove graph utilities from layer

* split bindings into separate files

* push edges towards derived layers

* (wip) move traits and status

* split layer prefix from types

* minor cleanup of node

* simplify eraseVertices

* drop getPosition and eigen dep

* drop node symbol include

* remove typedef from

* add missing bindings and fix compilation

* add binary serialization for python layers

* fix pytorch tests

* remove commented code

---------

Co-authored-by: Nathan Hughes <[email protected]>
* try adding python workflow

* add test deps

* install torch cpu only

* fix url typo

* add python badge

---------

Co-authored-by: Nathan Hughes <[email protected]>
* switch feature vector to single precision

* bump version
* add room colormap and cleanup ironbow

* add conversion to hsv and hls

* move colormaps to be functions

* move colormaps to new file

* add 150 class map and divergent map

* clean up discrete colormaps

* better sort colormaps

* improve divergent docstring

---------

Co-authored-by: Nathan Hughes <[email protected]>
* add khronos object bindings

* make complex types readonly for safety for now
* correctly parse flat meshes from old versions

* Update src/node_attributes.cpp

Co-authored-by: Lukas Schmid <[email protected]>

---------

Co-authored-by: Nathan Hughes <[email protected]>
Co-authored-by: Lukas Schmid <[email protected]>
* add mesh append function

* expand mesh python bindings

* add default args for transform
* recombine bindings and use system pybind11

* fix binding ordering for default args

* revert back to fetch content and reformat cmake

* revert changes for avoiding newer pybind features

* conditionally enable zmq implementation

* clean up dependencies and other changes

* switch to submodule

* enable verbose build

* add more status

* revert debugging and use recursive clone

* install git before checking out code
* add graph metadata object

* skip networkx tests if not available

* add python metadata interface

* add node and edge metadata

* use nodesymbol as primary arg type and add implicit conversion

* add node and edge metadata bindings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants