Skip to content

Commit c979c45

Browse files
let layer name be configurable (#61)
1 parent e8274f2 commit c979c45

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

hydra_visualizer/include/hydra_visualizer/plugins/traversability_plugin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ namespace hydra {
4949
class TraversabilityPlugin : public VisualizerPlugin {
5050
public:
5151
struct Config {
52+
//! Layer to visualize
53+
std::string layer = spark_dsg::DsgLayers::TRAVERSABILITY;
54+
5255
//! Colors representing each traversability state.
5356
std::vector<spark_dsg::Color> colors{spark_dsg::Color::gray(), // Unknown
5457
spark_dsg::Color::blue(), // Traversable

hydra_visualizer/src/plugins/traversability_plugin.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ static const auto registration_ =
5757

5858
}
5959

60-
using spark_dsg::Color;
6160
using spark_dsg::DynamicSceneGraph;
6261
using spark_dsg::SceneGraphLayer;
63-
using spark_dsg::SceneGraphNode;
6462
using spark_dsg::TraversabilityNodeAttributes;
6563
using spark_dsg::TraversabilityState;
6664
using spark_dsg::TravNodeAttributes;
@@ -70,6 +68,7 @@ using visualization_msgs::msg::MarkerArray;
7068
void declare_config(TraversabilityPlugin::Config& config) {
7169
using namespace config;
7270
name("TraversabilityPlugin::Config");
71+
field(config.layer, "layer");
7372
field(config.colors, "colors");
7473
field(config.slice_height, "slice_height", "m");
7574
field(config.line_width, "line_width", "m");
@@ -110,11 +109,13 @@ void TraversabilityPlugin::reset(const std_msgs::msg::Header& header) {
110109
void TraversabilityPlugin::fillMarkers(const std_msgs::msg::Header& header,
111110
const DynamicSceneGraph& graph,
112111
MarkerArray& msg) const {
113-
auto layer = graph.findLayer(spark_dsg::DsgLayers::TRAVERSABILITY);
112+
const auto config = config_.get();
113+
auto layer = graph.findLayer(config.layer);
114114
if (!layer) {
115115
return;
116116
}
117-
drawBoundaries(config_.get(), header, *layer, msg);
117+
118+
drawBoundaries(config, header, *layer, msg);
118119
}
119120

120121
void TraversabilityPlugin::drawBoundaries(const Config& config,
@@ -151,10 +152,9 @@ void TraversabilityPlugin::drawBoundaries(const Config& config,
151152
}
152153
}
153154

154-
void TraversabilityPlugin::drawBlockBoundary(
155-
const Config& config,
156-
const spark_dsg::TraversabilityNodeAttributes& attrs,
157-
visualization_msgs::msg::Marker& marker) const {
155+
void TraversabilityPlugin::drawBlockBoundary(const Config& config,
156+
const TraversabilityNodeAttributes& attrs,
157+
Marker& marker) const {
158158
// Get the world frame positions of the boundary points, adjusted for the line width
159159
// for non-overlapping rendering. bot-right, bot-left, top-left, top-right
160160
std::vector<Eigen::Vector3d> pts;
@@ -205,10 +205,9 @@ void TraversabilityPlugin::drawBlockBoundary(
205205
}
206206
}
207207

208-
void TraversabilityPlugin::drawRegionBoundary(
209-
const Config& config,
210-
const TravNodeAttributes& attrs,
211-
visualization_msgs::msg::Marker& marker) const {
208+
void TraversabilityPlugin::drawRegionBoundary(const Config& config,
209+
const TravNodeAttributes& attrs,
210+
Marker& marker) const {
212211
marker.type = Marker::LINE_STRIP;
213212
for (size_t i = 0; i < attrs.radii.size(); ++i) {
214213
tf2::convert(attrs.getBoundaryPoint(i), marker.points.emplace_back());

0 commit comments

Comments
 (0)