@@ -156,8 +156,7 @@ struct ProblemState {
156156#undef MAKE_ARGV
157157};
158158
159- wpi::expected<constrained_solvepnp::RobotStateMat,
160- sleipnir::SolverExitCondition>
159+ wpi::expected<constrained_solvepnp::RobotStateMat, slp::ExitStatus>
161160constrained_solvepnp::do_optimization (
162161 bool heading_free, int nTags,
163162 constrained_solvepnp::CameraCalibration cameraCal,
@@ -173,7 +172,7 @@ constrained_solvepnp::do_optimization(
173172 if constexpr (VERBOSE) fmt::println (" Got unexpected num cols!" );
174173 // TODO find a new error code
175174 return wpi::unexpected{
176- sleipnir::SolverExitCondition:: kNonfiniteInitialCostOrConstraints };
175+ slp::ExitStatus::NONFINITE_INITIAL_COST_OR_CONSTRAINTS };
177176 }
178177
179178 // rescale observations to homogenous pixel coordinates
@@ -203,7 +202,7 @@ constrained_solvepnp::do_optimization(
203202 auto problemOpt = createProblem (nTags, heading_free);
204203 if (!problemOpt) {
205204 return wpi::unexpected{
206- sleipnir::SolverExitCondition:: kNonfiniteInitialCostOrConstraints };
205+ slp::ExitStatus::NONFINITE_INITIAL_COST_OR_CONSTRAINTS };
207206 }
208207
209208 ProblemState<3 > pState{robot2camera, field2points, point_observations,
@@ -233,7 +232,7 @@ constrained_solvepnp::do_optimization(
233232
234233 // Check for diverging iterates
235234 if (x.template lpNorm <Eigen::Infinity>() > 1e20 || !x.allFinite ()) {
236- return wpi::unexpected{sleipnir::SolverExitCondition:: kDivergingIterates };
235+ return wpi::unexpected{slp::ExitStatus::DIVERGING_ITERATES };
237236 }
238237
239238 GradMat g = pState.calculateGradJ (x);
@@ -254,7 +253,7 @@ constrained_solvepnp::do_optimization(
254253 auto H_ldlt = H.ldlt ();
255254 if (H_ldlt.info () != Eigen::Success) {
256255 std::cerr << " LDLT decomp failed! H=" << std::endl << H << std::endl;
257- return wpi::unexpected{sleipnir::SolverExitCondition:: kLocallyInfeasible };
256+ return wpi::unexpected{slp::ExitStatus::LOCALLY_INFEASIBLE };
258257 }
259258
260259 // Make sure H is positive definite (all eigenvalues are > 0)
@@ -278,8 +277,7 @@ constrained_solvepnp::do_optimization(
278277
279278 if (H_ldlt.info () != Eigen::Success) {
280279 std::cerr << " LDLT decomp failed! H=" << std::endl << H << std::endl;
281- return wpi::unexpected{
282- sleipnir::SolverExitCondition::kLocallyInfeasible };
280+ return wpi::unexpected{slp::ExitStatus::LOCALLY_INFEASIBLE};
283281 }
284282
285283 // If our eigenvalues aren't positive definite, pick a new δ for next
@@ -289,8 +287,7 @@ constrained_solvepnp::do_optimization(
289287
290288 // If the Hessian perturbation is too high, report failure
291289 if (δ > 1e20 ) {
292- return wpi::unexpected{
293- sleipnir::SolverExitCondition::kLocallyInfeasible };
290+ return wpi::unexpected{slp::ExitStatus::LOCALLY_INFEASIBLE};
294291 }
295292 } else {
296293 // Done!
@@ -301,8 +298,7 @@ constrained_solvepnp::do_optimization(
301298 }
302299
303300 if (i_reg == MAX_REG_STEPS) {
304- return wpi::unexpected{
305- sleipnir::SolverExitCondition::kLocallyInfeasible };
301+ return wpi::unexpected{slp::ExitStatus::LOCALLY_INFEASIBLE};
306302 }
307303 } else {
308304 // std::printf("Already regularized\n");
@@ -345,8 +341,7 @@ constrained_solvepnp::do_optimization(
345341
346342 // If our step size shrank too much, report local infesibility
347343 if (alpha < α_min_frac * γConstraint) {
348- return wpi::unexpected{
349- sleipnir::SolverExitCondition::kLocallyInfeasible };
344+ return wpi::unexpected{slp::ExitStatus::LOCALLY_INFEASIBLE};
350345 }
351346 }
352347 }
0 commit comments