Skip to content

Commit 3059536

Browse files
author
Gibbon OPC
committed
fix dict populating
1 parent 94e1cc7 commit 3059536

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

elevation_mapping_cupy/elevation_mapping_cupy/plugins/plugin_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def init(self, plugin_params: List[PluginParams], extra_params: List[Dict]):
132132
self.plugin_names = self.get_plugin_names()
133133

134134
def load_plugin_settings(self, file_path: str):
135-
print("Start loading plugins...")
135+
print("Start loading plugins...", flush=True)
136136
cfg = YAML().load(open(file_path, "r"))
137137
plugin_params = []
138138
extra_params = []
@@ -148,7 +148,7 @@ def load_plugin_settings(self, file_path: str):
148148
)
149149
extra_params.append(v["extra_params"])
150150
self.init(plugin_params, extra_params)
151-
print("Loaded plugins are ", *self.plugin_names)
151+
print("Loaded plugins are ", *self.plugin_names, flush=True)
152152

153153
def get_layer_names(self):
154154
names = []

elevation_mapping_cupy/elevation_mapping_cupy/semantic_map.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ def get_fusion(
156156
if "default" in channel_fusions:
157157
default_fusion = channel_fusions["default"]
158158
print(
159-
f"[WARNING] Layer {channel} not found in layer_specs. Using {default_fusion} algorithm as default."
159+
f"[WARNING] Layer {channel} not found in layer_specs. Using {default_fusion} algorithm as default.", flush=True
160160
)
161161
layer_specs[channel] = default_fusion
162162
self.update_fusion_setting()
163163
# If there's no default fusion algorithm, we skip this channel
164164
else:
165165
print(
166-
f"[WARNING] Layer {channel} not found in layer_specs ({layer_specs}) and no default fusion is configured. Skipping."
166+
f"[WARNING] Layer {channel} not found in layer_specs ({layer_specs}) and no default fusion is configured. Skipping.", flush=True
167167
)
168168
continue
169169
else:
@@ -192,7 +192,7 @@ def get_layer_indices(self, fusion_alg, layer_specs):
192192
"""
193193
layer_indices = cp.array([], dtype=cp.int32)
194194
for it, (key, val) in enumerate(layer_specs.items()):
195-
if key in val == fusion_alg:
195+
if val == fusion_alg:
196196
layer_indices = cp.append(layer_indices, it).astype(cp.int32)
197197
return layer_indices
198198

@@ -236,7 +236,7 @@ def update_layers_pointcloud(self, points_all, channels, R, t, elevation_map):
236236
# If channels has a new layer that is not in the semantic map, add it
237237
for channel in process_channels:
238238
if channel not in self.layer_names:
239-
print(f"Layer {channel} not found, adding it to the semantic map")
239+
print(f"Layer {channel} not found, adding it to the semantic map", flush=True)
240240
self.add_layer(channel)
241241

242242
# Resetting new_map for the layers that are to be deleted
@@ -286,7 +286,7 @@ def update_layers_image(
286286
self.new_map[self.delete_new_layers] = 0.0
287287
for j, (fusion, channel) in enumerate(zip(fusion_methods, process_channels)):
288288
if channel not in self.layer_names:
289-
print(f"Layer {channel} not found, adding it to the semantic map")
289+
print(f"Layer {channel} not found, adding it to the semantic map", flush=True)
290290
self.add_layer(channel)
291291
sem_map_idx = self.get_index(channel)
292292

elevation_mapping_cupy/src/elevation_mapping_ros.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ ElevationMappingNode::ElevationMappingNode(const rclcpp::NodeOptions& options)
109109
}
110110
}
111111
subscriber_keys.assign(keys_set.begin(), keys_set.end());
112+
if (subscriber_keys.empty()) {
113+
RCLCPP_FATAL(this->get_logger(), "There aren't any subscribers to be configured, the elevation mapping cannot be configured. Exit");
114+
throw std::runtime_error("No subscribers configured");
115+
}
112116

113117
for (const auto& key : subscriber_keys) {
114118
std::string prefix = "subscribers." + key;
@@ -217,6 +221,10 @@ ElevationMappingNode::ElevationMappingNode(const rclcpp::NodeOptions& options)
217221
}
218222
}
219223
}
224+
if (publisher_keys.empty()) {
225+
RCLCPP_FATAL(this->get_logger(), "There aren't any publishers to be configured, the elevation mapping cannot be configured. Exit");
226+
throw std::runtime_error("No publishers configured");
227+
}
220228

221229
for (const auto& key : publisher_keys) {
222230
std::string prefix = "publishers." + key;

elevation_mapping_cupy/src/elevation_mapping_wrapper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ void ElevationMappingWrapper::setParameters(rclcpp::Node* node) {
123123
if (name.find("pointcloud_channel_fusions.") == 0) {
124124
std::string key = name.substr(27); // length of prefix
125125
std::string val = node->get_parameter(name).as_string();
126+
pointcloud_channel_fusion_dict[key.c_str()] = val;
126127
}
127128
}
129+
RCLCPP_INFO_STREAM(node->get_logger(), "pointcloud_channel_fusions_dict: " << py::str(pointcloud_channel_fusion_dict));
128130
param_.attr("pointcloud_channel_fusions") = pointcloud_channel_fusion_dict;
129131

130132
// Image channel fusion
@@ -137,6 +139,7 @@ void ElevationMappingWrapper::setParameters(rclcpp::Node* node) {
137139
image_channel_fusion_dict[key.c_str()] = val;
138140
}
139141
}
142+
RCLCPP_INFO_STREAM(node->get_logger(), "image_channel_fusions_dict: " << py::str(image_channel_fusion_dict));
140143
param_.attr("image_channel_fusions") = image_channel_fusion_dict;
141144

142145

0 commit comments

Comments
 (0)