diff --git a/include/sleipnir/control/OCPSolver.hpp b/include/sleipnir/control/OCPSolver.hpp index adfca449..663e81d9 100644 --- a/include/sleipnir/control/OCPSolver.hpp +++ b/include/sleipnir/control/OCPSolver.hpp @@ -308,21 +308,21 @@ class SLEIPNIR_DLLEXPORT OCPSolver : public OptimizationProblem { } /** - * Convenience function to set an upper bound on the timestep. + * Convenience function to set a lower bound on the timestep. * - * @param maxTimestep The maximum timestep. + * @param minTimestep The minimum timestep. */ - void SetMaxTimestep(std::chrono::duration maxTimestep) { - SubjectTo(DT() <= maxTimestep.count()); + void SetMinTimestep(std::chrono::duration minTimestep) { + SubjectTo(DT() >= minTimestep.count()); } /** - * Convenience function to set a lower bound on the timestep. + * Convenience function to set an upper bound on the timestep. * - * @param minTimestep The minimum timestep. + * @param maxTimestep The maximum timestep. */ - void SetMinTimestep(std::chrono::duration minTimestep) { - SubjectTo(DT() >= minTimestep.count()); + void SetMaxTimestep(std::chrono::duration maxTimestep) { + SubjectTo(DT() <= maxTimestep.count()); } /** diff --git a/jormungandr/cpp/control/BindOCPSolver.cpp b/jormungandr/cpp/control/BindOCPSolver.cpp index 3c9c907a..9dcf8c86 100644 --- a/jormungandr/cpp/control/BindOCPSolver.cpp +++ b/jormungandr/cpp/control/BindOCPSolver.cpp @@ -125,10 +125,10 @@ void BindOCPSolver(nb::enum_& transcription_method, &OCPSolver::SetUpperInputBound, "upper_bound"_a, DOC(sleipnir, OCPSolver, SetUpperInputBound)); - cls.def("set_max_timestep", &OCPSolver::SetMaxTimestep, "max_timestep"_a, - DOC(sleipnir, OCPSolver, SetMaxTimestep)); cls.def("set_min_timestep", &OCPSolver::SetMinTimestep, "min_timestep"_a, DOC(sleipnir, OCPSolver, SetMinTimestep)); + cls.def("set_max_timestep", &OCPSolver::SetMaxTimestep, "max_timestep"_a, + DOC(sleipnir, OCPSolver, SetMaxTimestep)); cls.def("X", &OCPSolver::X, DOC(sleipnir, OCPSolver, X)); cls.def("U", &OCPSolver::U, DOC(sleipnir, OCPSolver, U)); diff --git a/jormungandr/test/control/ocp_solver_differential_drive_test.py b/jormungandr/test/control/ocp_solver_differential_drive_test.py index 0ef7d1e2..a40b1a44 100644 --- a/jormungandr/test/control/ocp_solver_differential_drive_test.py +++ b/jormungandr/test/control/ocp_solver_differential_drive_test.py @@ -42,8 +42,6 @@ def test_ocp_solver_differential_drive(): problem.set_lower_input_bound(u_min) problem.set_upper_input_bound(u_max) - # TODO: Solver is unhappy when more than one minimum timestep is constrained. - # Detect this in either OptimizationProblem or OCPSolver. problem.set_min_timestep(min_timestep) problem.set_max_timestep(3.0) diff --git a/test/src/control/OCPSolverTest_DifferentialDrive.cpp b/test/src/control/OCPSolverTest_DifferentialDrive.cpp index d7412ff4..1737fbe1 100644 --- a/test/src/control/OCPSolverTest_DifferentialDrive.cpp +++ b/test/src/control/OCPSolverTest_DifferentialDrive.cpp @@ -46,8 +46,6 @@ TEST_CASE("OCPSolver - Differential drive", "[OCPSolver]") { problem.SetLowerInputBound(u_min); problem.SetUpperInputBound(u_max); - // TODO: Solver is unhappy when more than one minimum timestep is constrained. - // Detect this in either OptimizationProblem or OCPSolver. problem.SetMinTimestep(minTimestep); problem.SetMaxTimestep(3s);