Skip to content

Commit b02f2c9

Browse files
committed
fix sleipnir api break
1 parent e811894 commit b02f2c9

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"python.testing.unittestEnabled": false,
33
"python.testing.pytestEnabled": true,
4-
"python.testing.cwd": "photon-lib/py"
4+
"python.testing.cwd": "photon-lib/py",
5+
"files.associations": {
6+
"bitset": "cpp"
7+
}
58
}

photon-targeting/src/main/native/cpp/photon/constrained_solvepnp/wrap/casadi_wrapper.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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>
161160
constrained_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
}

photon-targeting/src/main/native/cpp/photon/estimation/VisionEstimation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ std::optional<photon::PnpResult> EstimateRobotPoseConstrainedSolvePNP(
191191
guess2.X().value(), guess2.Y().value(),
192192
guess2.Rotation().Radians().value()};
193193

194-
wpi::expected<constrained_solvepnp::RobotStateMat,
195-
sleipnir::SolverExitCondition>
194+
wpi::expected<constrained_solvepnp::RobotStateMat, slp::ExitStatus>
196195
result = constrained_solvepnp::do_optimization(
197196
headingFree, knownTags.size(), cameraCal, robotToCamera, guessMat,
198197
field2points, pointObservations, gyroTheta.Radians().value(),

photon-targeting/src/main/native/include/photon/constrained_solvepnp/wrap/casadi_wrapper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#pragma once
1919

2020
#include <Eigen/Core>
21-
#include <sleipnir/optimization/SolverExitCondition.hpp>
21+
#include <sleipnir/optimization/solver/exit_status.hpp>
2222
#include <wpi/expected>
2323

2424
namespace constrained_solvepnp {
@@ -40,7 +40,7 @@ using RobotStateMat = Eigen::Matrix<casadi_real, 3, 1>;
4040
* to this. The number of columns in field2points and point_observations just be
4141
* exactly 4x nTags.
4242
*/
43-
wpi::expected<RobotStateMat, sleipnir::SolverExitCondition> do_optimization(
43+
wpi::expected<RobotStateMat, slp::ExitStatus> do_optimization(
4444
bool heading_free, int nTags, CameraCalibration cameraCal,
4545
// Note that casadi is column major, apparently
4646
Eigen::Matrix<casadi_real, 4, 4, Eigen::ColMajor> robot2camera,

photon-targeting/src/main/native/jni/ConstrainedSolvepnpJNI.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ Java_org_photonvision_jni_ConstrainedSolvepnpJni_do_1optimization
8484
std::cout << "observations:\n" << pointObservationsMat << std::endl;
8585
#endif
8686

87-
wpi::expected<constrained_solvepnp::RobotStateMat,
88-
sleipnir::SolverExitCondition>
87+
wpi::expected<constrained_solvepnp::RobotStateMat, slp::ExitStatus>
8988
result = constrained_solvepnp::do_optimization(
9089
headingFree, nTags, cameraCal_, robot2cameraMat, xGuessMat,
9190
field2pointsMat, pointObservationsMat, gyro_θ, gyro_error_scale_fac);

0 commit comments

Comments
 (0)