Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.22)
project(spark_dsg VERSION 1.1.3)
project(spark_dsg VERSION 1.1.4)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
87 changes: 34 additions & 53 deletions include/spark_dsg/node_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,20 @@ using NodeAttributeRegistration =
serialization::AttributeRegistration<NodeAttributes, T>;

#define REGISTER_NODE_ATTRIBUTES(attr_type) \
inline static const auto registration_ = \
inline static const auto attr_type##registration_ = \
NodeAttributeRegistration<attr_type>(#attr_type); \
const serialization::RegistrationInfo& registrationImpl() const override { \
return registration_.info; \
return attr_type##registration_.info; \
} \
static_assert(true, "")

// TODO(nathan) handle this better
/**
* @brief Typedef representing the semantic class of an object or other node
* @brief Type alias representing the semantic class of an object or other node
*/
using SemanticLabel = uint32_t;

/**
* @brief Information related to place to mesh coorespondence
* @brief Information related to place to mesh correspondence
*/
struct NearestVertexInfo {
int32_t block[3];
Expand Down Expand Up @@ -110,11 +109,11 @@ struct NodeAttributes {

//! Position of the node
Eigen::Vector3d position;
//! last time the place was updated (while active)
//! Last time the place was updated (while active)
uint64_t last_update_time_ns;
//! whether or not the node is in the active window
//! Whether or not the node is in the active window
bool is_active;
//! whether the node was observed by Hydra, or added as a prediction
//! Whether the node was observed by Hydra, or added as a prediction
bool is_predicted;
//! Arbitrary node metadata
Metadata metadata;
Expand All @@ -139,19 +138,16 @@ struct NodeAttributes {
virtual size_t memoryUsage() const;

protected:
//! actually output information to the std::ostream
virtual std::ostream& fill_ostream(std::ostream& out) const;
//! dispatch function for serialization
virtual void serialization_info();
//! dispatch function for serialization
void serialization_info() const;
//! compute equality
virtual bool is_equal(const NodeAttributes& other) const;

private:
inline static const auto registration_ =
NodeAttributeRegistration<NodeAttributes>("NodeAttributes");

//! get registration
protected:
virtual const serialization::RegistrationInfo& registrationImpl() const {
return registration_.info;
}
Expand All @@ -163,12 +159,12 @@ struct NodeAttributes {
struct SemanticNodeAttributes : public NodeAttributes {
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
//! pointer type for node
//! Pointer type for node
using Ptr = std::unique_ptr<SemanticNodeAttributes>;

//! alias for semantic label
//! Alias for semantic label
using Label = SemanticLabel;
// !flag for whether or not semantic label should be considered valid
//! Flag for whether or not semantic label should be considered valid
inline static constexpr Label NO_SEMANTIC_LABEL = std::numeric_limits<Label>::max();

SemanticNodeAttributes();
Expand Down Expand Up @@ -217,11 +213,11 @@ struct ObjectNodeAttributes : public SemanticNodeAttributes {
NodeAttributes::Ptr clone() const override;
void transform(const Eigen::Isometry3d& transform) override;

//! Mesh vertice connections
//! Mesh vertex connections
std::list<size_t> mesh_connections;
//! Whether or not the object is known (and registered)
bool registered;
//! rotation of object w.r.t. world (only valid when registerd)
//! Rotation of object with respect to world (only valid when registered)
Eigen::Quaterniond world_R_object;

protected:
Expand Down Expand Up @@ -260,9 +256,8 @@ struct RoomNodeAttributes : public SemanticNodeAttributes {

/**
* @brief Additional node attributes for a place
* In addition to the normal semantic properties, a room has the minimum
* distance to an obstacle and the number of basis points for that vertex in the
* GVD
* In addition to the normal semantic properties, a place has the minimum
* distance to an obstacle and the number of basis points for that vertex
*/
struct PlaceNodeAttributes : public SemanticNodeAttributes {
public:
Expand All @@ -274,7 +269,7 @@ struct PlaceNodeAttributes : public SemanticNodeAttributes {

/**
* @brief make places node attributes
* @param distance distance to nearest obstalce
* @param distance distance to nearest obstacle
* @param num_basis_points number of basis points of the places node
*/
PlaceNodeAttributes(double distance, unsigned int num_basis_points);
Expand All @@ -285,13 +280,13 @@ struct PlaceNodeAttributes : public SemanticNodeAttributes {
double distance;
//! number of equidistant obstacles
unsigned int num_basis_points;
//! voxblox mesh vertices that are closest to this place
//! Mesh vertices that are closest to this place
std::vector<NearestVertexInfo> voxblox_mesh_connections;
//! pcl mesh vertices that are closest to this place
//! Mesh vertices that are closest to this place
std::vector<size_t> pcl_mesh_connections;
//! semantic labels of parents
std::vector<uint8_t> mesh_vertex_labels;
//! deformation vertices that are closest to this place
//! Deformation vertices that are closest to this place
std::vector<size_t> deformation_connections;

bool real_place = true;
Expand Down Expand Up @@ -322,42 +317,28 @@ struct Place2dNodeAttributes : public SemanticNodeAttributes {
using Ptr = std::unique_ptr<Place2dNodeAttributes>;

Place2dNodeAttributes();

/**
* @brief make places node attributes
* @param boundary Boundary points surrounding place
*/
Place2dNodeAttributes(std::vector<Eigen::Vector3d> boundary);
virtual ~Place2dNodeAttributes() = default;
NodeAttributes::Ptr clone() const override;

//! points on boundary of place region
//! Mesh vertices that are closest to this place
std::list<size_t> mesh_connections;
//! Mesh vertices corresponding to boundary points
std::vector<size_t> boundary_connections;
//! Points on boundary of place region
std::vector<Eigen::Vector3d> boundary;
//! center of intersection checking ellipsoid
//! Center of intersection checking ellipsoid
Eigen::Vector3d ellipse_centroid;
//! shape matrix for intersection checking ellipsoid
//! Shape matrix for intersection checking ellipsoid
Eigen::Matrix<double, 2, 2> ellipse_matrix_compress;
//! shape matrix for plotting ellipsoid
//! Shape matrix for plotting ellipsoid
Eigen::Matrix<double, 2, 2> ellipse_matrix_expand;
//! pcl mesh vertices corresponding to boundary points
std::vector<size_t> pcl_boundary_connections;
//! voxblox mesh vertices that are closest to this place
std::vector<NearestVertexInfo> voxblox_mesh_connections;
//! pcl mesh vertices that are closest to this place
std::vector<size_t> pcl_mesh_connections;
//! min vertex index of associated mesh vertices
size_t pcl_min_index;
//! max vertex index of associated mesh vertices
size_t pcl_max_index;
//! semantic labels of parents
std::vector<uint8_t> mesh_vertex_labels;
//! deformation vertices that are closest to this place
std::vector<size_t> deformation_connections;
//! tracks whether the node still needs to be cleaned up during merging
//! Minimum vertex index of associated mesh vertices
size_t min_mesh_index;
//! Max vertex index of associated mesh vertices
size_t max_mesh_index;
//! Tracks whether the node still needs to be cleaned up during merging
bool need_finish_merge;
//! whether this node has been merged to while in current active window
bool need_cleanup_splitting;
//! whether this node has mesh vertices in active window
//! Whether this node has mesh vertices in active window
bool has_active_mesh_indices;

protected:
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="2">
<name>spark_dsg</name>
<version>1.1.3</version>
<version>1.1.4</version>
<description>3D Scene Graph (3DSG) type definitions and core library code</description>

<author email="na26933@mit.edu">Nathan Hughes</author>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build"

[project]
name = "spark_dsg"
version = "1.1.3"
version = "1.1.4"
description = "Library for representing 3D scene graphs"
readme = "README.md"
license = "BSD-3-Clause"
Expand Down
16 changes: 7 additions & 9 deletions python/bindings/src/attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
#include <spark_dsg/mesh.h>
#include <spark_dsg/node_attributes.h>

#include <filesystem>

#include "spark_dsg/python/mesh.h"
#include "spark_dsg/python/python_types.h"

namespace spark_dsg::python {
Expand Down Expand Up @@ -171,15 +168,16 @@ void init_attributes(py::module_& m) {

py::class_<Place2dNodeAttributes, SemanticNodeAttributes>(m, "Place2dNodeAttributes")
.def(py::init<>())
.def_readwrite("mesh_connections", &Place2dNodeAttributes::mesh_connections)
.def_readwrite("boundary_connections", &Place2dNodeAttributes::boundary_connections)
.def_readwrite("boundary", &Place2dNodeAttributes::boundary)
.def_readwrite("ellipse_centroid", &Place2dNodeAttributes::ellipse_centroid)
.def_readwrite("ellipse_matrix_compress", &Place2dNodeAttributes::ellipse_matrix_compress)
.def_readwrite("ellipse_matrix_expand", &Place2dNodeAttributes::ellipse_matrix_expand)
.def_readwrite("ellipse_centroid", &Place2dNodeAttributes::ellipse_centroid)
.def_readwrite("pcl_boundary_connections", &Place2dNodeAttributes::pcl_boundary_connections)
.def_readwrite("voxblox_mesh_connections", &Place2dNodeAttributes::voxblox_mesh_connections)
.def_readwrite("pcl_mesh_connections", &Place2dNodeAttributes::pcl_mesh_connections)
.def_readwrite("mesh_vertex_labels", &Place2dNodeAttributes::mesh_vertex_labels)
.def_readwrite("deformation_connections", &Place2dNodeAttributes::deformation_connections);
.def_readwrite("min_mesh_index", &Place2dNodeAttributes::min_mesh_index)
.def_readwrite("max_mesh_index", &Place2dNodeAttributes::max_mesh_index)
.def_readwrite("need_finish_merge", &Place2dNodeAttributes::need_finish_merge)
.def_readwrite("has_active_mesh_indices", &Place2dNodeAttributes::has_active_mesh_indices);

py::class_<BoundaryInfo>(m, "BoundaryInfo")
.def(py::init<>())
Expand Down
71 changes: 46 additions & 25 deletions src/node_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,10 @@ bool PlaceNodeAttributes::is_equal(const NodeAttributes& other) const {
}

Place2dNodeAttributes::Place2dNodeAttributes()
: Place2dNodeAttributes(std::vector<Eigen::Vector3d>()) {}

Place2dNodeAttributes::Place2dNodeAttributes(std::vector<Eigen::Vector3d> boundary)
: SemanticNodeAttributes(),
boundary(boundary),
pcl_min_index(0),
pcl_max_index(0),
min_mesh_index(0),
max_mesh_index(0),
need_finish_merge(false),
need_cleanup_splitting(false),
has_active_mesh_indices(false) {}

NodeAttributes::Ptr Place2dNodeAttributes::clone() const {
Expand All @@ -413,17 +408,44 @@ std::ostream& Place2dNodeAttributes::fill_ostream(std::ostream& out) const {

void Place2dNodeAttributes::serialization_info() {
SemanticNodeAttributes::serialization_info();
serialization::field("boundary", boundary);
serialization::field("ellipse_centroid", ellipse_centroid);
serialization::field("ellipse_matrix_compress", ellipse_matrix_compress);
serialization::field("ellipse_matrix_expand", ellipse_matrix_expand);
serialization::field("pcl_boundary_connections", pcl_boundary_connections);
serialization::field("voxblox_mesh_connections", voxblox_mesh_connections);
serialization::field("pcl_mesh_connections", pcl_mesh_connections);
serialization::field("mesh_vertex_labels", mesh_vertex_labels);
serialization::field("deformation_connections", deformation_connections);
serialization::field("need_cleanup_splitting", need_cleanup_splitting);
serialization::field("has_active_mesh_indices", has_active_mesh_indices);
const auto& header = io::GlobalInfo::loadedHeader();
if (header.version < io::Version(1, 1, 4)) {
io::warnOutdatedHeader(header);
serialization::field("boundary", boundary);
serialization::field("ellipse_centroid", ellipse_centroid);
serialization::field("ellipse_matrix_compress", ellipse_matrix_compress);
serialization::field("ellipse_matrix_expand", ellipse_matrix_expand);
serialization::field("pcl_boundary_connections", boundary_connections);
{ // temp
std::vector<NearestVertexInfo> temp;
serialization::field("voxblox_mesh_connections", temp);
}
serialization::field("pcl_mesh_connections", mesh_connections);
{ // temp scope
std::vector<uint8_t> temp;
serialization::field("mesh_vertex_labels", temp);
}
{ // temp scope
std::vector<size_t> temp;
serialization::field("deformation_connections", temp);
}
{ // temp scope
bool temp;
serialization::field("need_cleanup_splitting", temp);
}
serialization::field("has_active_mesh_indices", has_active_mesh_indices);
} else {
serialization::field("mesh_connections", mesh_connections);
serialization::field("boundary_connections", boundary_connections);
serialization::field("boundary", boundary);
serialization::field("ellipse_centroid", ellipse_centroid);
serialization::field("ellipse_matrix_compress", ellipse_matrix_compress);
serialization::field("ellipse_matrix_expand", ellipse_matrix_expand);
serialization::field("min_mesh_index", min_mesh_index);
serialization::field("max_mesh_index", max_mesh_index);
serialization::field("need_finish_merge", need_finish_merge);
serialization::field("has_active_mesh_indices", has_active_mesh_indices);
}
}

bool Place2dNodeAttributes::is_equal(const NodeAttributes& other) const {
Expand All @@ -436,16 +458,15 @@ bool Place2dNodeAttributes::is_equal(const NodeAttributes& other) const {
return false;
}

return boundary == derived->boundary &&
return mesh_connections == derived->mesh_connections &&
boundary_connections == derived->boundary_connections &&
boundary == derived->boundary &&
ellipse_centroid == derived->ellipse_centroid &&
ellipse_matrix_compress == derived->ellipse_matrix_compress &&
ellipse_matrix_expand == derived->ellipse_matrix_expand &&
pcl_boundary_connections == derived->pcl_boundary_connections &&
voxblox_mesh_connections == derived->voxblox_mesh_connections &&
pcl_mesh_connections == derived->pcl_mesh_connections &&
mesh_vertex_labels == derived->mesh_vertex_labels &&
deformation_connections == derived->deformation_connections &&
need_cleanup_splitting == derived->need_cleanup_splitting &&
min_mesh_index == derived->min_mesh_index &&
max_mesh_index == derived->max_mesh_index &&
need_finish_merge == derived->need_finish_merge &&
has_active_mesh_indices == derived->has_active_mesh_indices;
}

Expand Down