Skip to content

Commit

Permalink
Fix adding edge with broken parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerKuemmerle committed Dec 14, 2024
1 parent 0fd6a29 commit 9042c9e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions g2o/core/optimizable_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,17 @@ bool OptimizableGraph::Edge::resolveParameters() {
for (size_t i = 0; i < _parameters.size(); i++) {
int index = _parameterIds[i];
*_parameters[i] = graph()->parameter(index);
if (!*_parameters[i]) {
G2O_CRITICAL(
"parameter {} is NULL. Check setParameterId() calls for the edge.",
i);
return false;
}
auto& aux = **_parameters[i];
if (typeid(aux).name() != _parameterTypes[i]) {
G2O_CRITICAL("parameter type mismatch - encountered {}; should be {}",
typeid(aux).name(), _parameterTypes[i]);
}
if (!*_parameters[i]) {
G2O_CRITICAL("*_parameters[i] == 0");
return false;
}
}
return true;
}
Expand Down Expand Up @@ -228,12 +230,12 @@ bool OptimizableGraph::addEdge(OptimizableGraph::Edge* e) {
e->_internalId = _nextEdgeId++;
if (e->numUndefinedVertices()) return true;
if (!e->resolveParameters()) {
G2O_ERROR("{}: FATAL, cannot resolve parameters for edge {}",
G2O_ERROR("FATAL, cannot resolve parameters for edge {}",
static_cast<void*>(e));
return false;
}
if (!e->resolveCaches()) {
G2O_ERROR("{}: FATAL, cannot resolve caches for edge {}",
G2O_ERROR("FATAL, cannot resolve caches for edge {}",
static_cast<void*>(e));
return false;
}
Expand Down Expand Up @@ -263,12 +265,12 @@ bool OptimizableGraph::setEdgeVertex(HyperGraph::Edge* e, int pos,
OptimizableGraph::Edge* ee = static_cast<OptimizableGraph::Edge*>(e);
#endif
if (!ee->resolveParameters()) {
G2O_ERROR("{}: FATAL, cannot resolve parameters for edge {}",
G2O_ERROR("FATAL, cannot resolve parameters for edge {}",
static_cast<void*>(e));
return false;
}
if (!ee->resolveCaches()) {
G2O_ERROR("{}: FATAL, cannot resolve caches for edge {}",
G2O_ERROR("FATAL, cannot resolve caches for edge {}",
static_cast<void*>(e));
return false;
}
Expand Down

0 comments on commit 9042c9e

Please sign in to comment.