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
22 changes: 5 additions & 17 deletions hydra_ros/include/hydra_ros/visualizer/feature_color_adaptors.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <hydra/openset/embedding_distances.h>
#include <hydra_visualizer/adapters/graph_color.h>
#include <hydra_visualizer/adapters/node_color.h>
#include <hydra_visualizer/adapters/text.h>

#include <rclcpp/subscription.hpp>
Expand All @@ -10,7 +10,7 @@

namespace hydra {

class FeatureScoreColor : public GraphColorAdapter {
class FeatureScoreColor : public NodeColorAdapter {
public:
struct Config {
std::string ns = "~";
Expand All @@ -23,7 +23,7 @@ class FeatureScoreColor : public GraphColorAdapter {
explicit FeatureScoreColor(const Config& config);
~FeatureScoreColor();
void setGraph(const spark_dsg::DynamicSceneGraph& graph,
spark_dsg::LayerId layer) override;
spark_dsg::LayerKey layer) override;
spark_dsg::Color getColor(const spark_dsg::DynamicSceneGraph& graph,
const spark_dsg::SceneGraphNode& node) const override;

Expand All @@ -46,15 +46,11 @@ class FeatureScoreColor : public GraphColorAdapter {
Eigen::VectorXf feature_;
std::unordered_map<spark_dsg::NodeId, float> values_;
std::unique_ptr<EmbeddingDistance> metric_;

inline static const auto registration_ =
config::RegistrationWithConfig<GraphColorAdapter, FeatureScoreColor, Config>(
"FeatureScoreColor");
};

void declare_config(FeatureScoreColor::Config& config);

class NearestFeatureColor : public GraphColorAdapter {
class NearestFeatureColor : public NodeColorAdapter {
public:
struct Config {
config::VirtualConfig<EmbeddingDistance> metric{CosineDistance::Config()};
Expand All @@ -70,15 +66,11 @@ class NearestFeatureColor : public GraphColorAdapter {
std::unique_ptr<EmbeddingDistance> metric_;
std::unique_ptr<EmbeddingGroup> features_;
const visualizer::DiscreteColormap colormap_;

inline static const auto registration_ =
config::RegistrationWithConfig<GraphColorAdapter, NearestFeatureColor, Config>(
"NearestFeatureColor");
};

void declare_config(NearestFeatureColor::Config& config);

class NearestFeatureLabel : public visualizer::GraphTextAdapter {
class NearestFeatureLabel : public visualizer::NodeTextAdapter {
public:
struct Config {
config::VirtualConfig<EmbeddingDistance> metric{CosineDistance::Config()};
Expand All @@ -94,10 +86,6 @@ class NearestFeatureLabel : public visualizer::GraphTextAdapter {
private:
std::unique_ptr<EmbeddingDistance> metric_;
std::unique_ptr<EmbeddingGroup> features_;

inline static const auto registration_ =
config::RegistrationWithConfig<GraphTextAdapter, NearestFeatureLabel, Config>(
"NearestFeatureLabel");
};

} // namespace hydra
22 changes: 20 additions & 2 deletions hydra_ros/src/visualizer/feature_color_adaptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@
#include <spark_dsg/node_symbol.h>

namespace hydra {
namespace {

static const auto score_registration =
config::RegistrationWithConfig<NodeColorAdapter,
FeatureScoreColor,
FeatureScoreColor::Config>("FeatureScoreColor");

static const auto nearest_registration =
config::RegistrationWithConfig<NodeColorAdapter,
NearestFeatureColor,
NearestFeatureColor::Config>("NearestFeatureColor");

static const auto text_registration =
config::RegistrationWithConfig<visualizer::NodeTextAdapter,
NearestFeatureLabel,
NearestFeatureLabel::Config>("NearestFeatureLabel");

} // namespace

using namespace spark_dsg;
using semantic_inference_msgs::msg::FeatureVectorStamped;
Expand Down Expand Up @@ -103,13 +121,13 @@ FeatureScoreColor::FeatureScoreColor(const Config& config)

FeatureScoreColor::~FeatureScoreColor() = default;

void FeatureScoreColor::setGraph(const DynamicSceneGraph& graph, LayerId layer_id) {
void FeatureScoreColor::setGraph(const DynamicSceneGraph& graph, LayerKey layer_key) {
values_.clear();
if (!has_feature_ || !metric_) {
return;
}

const auto& layer = graph.getLayer(layer_id);
const auto& layer = graph.getLayer(layer_key.layer, layer_key.partition);
range_.min = 1.0f;
range_.max = 0.0f;
for (const auto& [node_id, node] : layer.nodes()) {
Expand Down
11 changes: 8 additions & 3 deletions hydra_visualizer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.22.1)
project(hydra_visualizer)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -31,8 +31,8 @@ add_library(
${PROJECT_NAME}
src/plugins/traversability_plugin.cpp
src/adapters/edge_color.cpp
src/adapters/graph_color.cpp
src/adapters/mesh_color.cpp
src/adapters/node_color.cpp
src/adapters/text.cpp
src/color/colormap_utilities.cpp
src/drawing.cpp
Expand All @@ -50,6 +50,7 @@ add_library(
src/plugins/pose_plugin.cpp
src/scene_graph_renderer.cpp
src/utils/ear_clipping.cpp
src/utils/layer_key_selector.cpp
src/utils/marker_group_pub.cpp
src/utils/marker_tracker.cpp
src/utils/polygon_utilities.cpp
Expand Down Expand Up @@ -89,7 +90,11 @@ target_link_libraries(

if(BUILD_TESTING)
find_package(ament_cmake_gtest)
ament_add_gtest(test_${PROJECT_NAME} tests/main.cpp tests/test_ear_clipping.cpp)
ament_add_gtest(test_${PROJECT_NAME}
tests/main.cpp
tests/test_ear_clipping.cpp
tests/test_layer_key_selector.cpp
)
target_link_libraries(
test_${PROJECT_NAME}
${PROJECT_NAME}
Expand Down
2 changes: 0 additions & 2 deletions hydra_visualizer/app/hydra_visualizer_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
#include <glog/logging.h>
#include <ianvs/node_init.h>

#include <filesystem>

#include <rclcpp/rclcpp.hpp>

#include "hydra_visualizer/visualizer_node.h"
Expand Down
45 changes: 16 additions & 29 deletions hydra_visualizer/config/visualizer_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,37 @@ renderer:
nodes: {scale: 0.40, color: {type: LabelColorAdapter}, alpha: 0.8, use_sphere: false}
text: {draw: true, collapse: true, adapter: {type: LabelTextAdapter}, height: 0.5, scale: 0.45}
bounding_boxes: {draw: true, collapse: true, scale: 0.05, edge_scale: 0.05, alpha: 0.9, edge_break_ratio: 0.5}
edges: {interlayer_use_source: true, interlayer_scale: 0.08, interlayer_alpha: 0.5}
3:
z_offset_scale: 3.0
visualize: true
nodes: {scale: 0.2, color: {type: ParentColorAdapter, colormap: {palette: colorbrewer}}, alpha: 0.9, use_sphere: true}
edges:
scale: 0.01
alpha: 0.5
color: {type: UniformEdgeColorAdapter}
interlayer_use_source: false
interlayer_scale: 0.08
interlayer_alpha: 0.4
interlayer_insertion_skip: 0
edges: {scale: 0.01, alpha: 0.5, color: {type: UniformEdgeColorAdapter}}
4:
z_offset_scale: 4.2
visualize: true
nodes: {scale: 0.6, color: {type: IdColorAdapter, colormap: {palette: colorbrewer}}, alpha: 0.8, use_sphere: false}
text: {draw: true, height: 1.25, scale: 1.0}
edges:
scale: 0.1
alpha: 0.2
color: {type: UniformEdgeColorAdapter}
interlayer_use_source: true
interlayer_scale: 0.08
interlayer_alpha: 0.4
interlayer_insertion_skip: 0
partitions:
2:
edges: {scale: 0.1, alpha: 0.2, color: {type: UniformEdgeColorAdapter}}
2p*:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

z_offset_scale: 0.0
visualize: true
nodes: {scale: 0.15, alpha: 0.9, use_sphere: false, color: {type: PartitionColorAdapter}}
edges: {scale: 0.05, alpha: 0.9, draw_interlayer: false}
text: {draw_layer: true, height: 0.9, scale: 0.8}
3:
3p1:
z_offset_scale: 3.0
visualize: true
nodes: {scale: 0.2, color: {type: LabelColorAdapter}, alpha: 0.9, use_sphere: true}
boundaries: {draw: true, collapse: false, wireframe_scale: 0.1, use_node_color: true, alpha: 1.0}
edges: {scale: 0.01, alpha: 0.5, color: {type: UniformEdgeColorAdapter}}
3p2:
z_offset_scale: 3.0
visualize: true
nodes: {scale: 0.2, color: {type: LabelColorAdapter}, alpha: 0.9, use_sphere: true}
boundaries: {draw: true, collapse: false, wireframe_scale: 0.1, use_node_color: true, alpha: 1.0}
text: {draw: true, collapse: true, adapter: {type: IdTextAdapter}, height: 0.5, scale: 0.45}
edges:
scale: 0.1
alpha: 0.8
color: {type: TraversabilityEdgeColorAdapter}
interlayer_use_source: false
interlayer_scale: 0.08
interlayer_alpha: 0.4
interlayer_insertion_skip: 0
text: {draw: false, collapse: true, adapter: {type: IdTextAdapter}, height: 0.5, scale: 0.45}
edges: {scale: 0.1, alpha: 0.8, color: {type: TraversabilityEdgeColorAdapter}}
interlayer_edges:
- {from: 3*, to: 2p*, draw: false}
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Minor: Would it make sense to imply * if no partitions are mentioned? i.e. from: 3 would apply to all partitions of 3, that would seem intuitive.

  • Minor minor: Would *p1 work to link up specific partitions only? Not sure if needed 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.

I think that would make more sense in the final version (that gets put in spark-dsg), but I think that would lead to confusing behavior for configs that hadn't been updated yet at the moment (e.g., 2 being interperted as all partitions would mean that the agent layers pick up the object layer config as the default config)

- {from: 3*, to: 2, use_child_color: true, scale: 0.08, alpha: 0.5}
- {from: 4, to: 3*, scale: 0.08, alpha: 0.4}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct EdgeColorAdapter {
* any edge colors when drawing the scene graph
*/
virtual void setGraph(const spark_dsg::DynamicSceneGraph& /* graph */,
spark_dsg::LayerId /* layer */) {}
spark_dsg::LayerKey /* layer */) {}
};

struct UniformEdgeColorAdapter : EdgeColorAdapter {
Expand Down Expand Up @@ -112,7 +112,7 @@ struct ValueEdgeColorAdapter : EdgeColorAdapter {

explicit ValueEdgeColorAdapter(const Config& config);
void setGraph(const spark_dsg::DynamicSceneGraph& graph,
spark_dsg::LayerId layer) override;
spark_dsg::LayerKey layer) override;
EdgeColor getColor(const spark_dsg::DynamicSceneGraph& graph,
const spark_dsg::SceneGraphEdge& edge) const override;

Expand All @@ -137,7 +137,7 @@ struct TraversabilityEdgeColorAdapter : EdgeColorAdapter {

explicit TraversabilityEdgeColorAdapter(const Config& config);
void setGraph(const spark_dsg::DynamicSceneGraph& graph,
spark_dsg::LayerId layer) override;
spark_dsg::LayerKey layer) override;
EdgeColor getColor(const spark_dsg::DynamicSceneGraph& graph,
const spark_dsg::SceneGraphEdge& edge) const override;

Expand Down
Loading