Skip to content

Commit

Permalink
Fix crash when no features are available to calculate a layer transfo…
Browse files Browse the repository at this point in the history
…rm (#460)

Signed-off-by: Luca Della Vedova <[email protected]>
  • Loading branch information
luca-della-vedova authored Nov 12, 2024
1 parent 71e419c commit d4649d9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rmf_traffic_editor/gui/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,7 @@ void Level::optimize_layer_transforms()
layers[i].transform.translation().x(),
layers[i].transform.translation().y()
};
int num_constraints_found = 0;

for (const Constraint& constraint : constraints)
{
Expand Down Expand Up @@ -1865,8 +1866,15 @@ void Level::optimize_layer_transforms()
&scale,
&translation[0]);

++num_constraints_found;
}

// Make sure there were features for this layer, otherwise ceres will fail
if (num_constraints_found == 0)
{
printf("No constraints found for layer, skipping optimization\n");
continue;
}
problem.SetParameterLowerBound(&scale, 0, 0.01);

ceres::Solver::Options options;
Expand Down

0 comments on commit d4649d9

Please sign in to comment.