Skip to content

Commit 2c527f2

Browse files
authored
Merge pull request #368 from Simple-Robotics/remove-deprecated-stageconstraint-class
(Finally) remove deprecated `StageConstraint` template class
2 parents 72882a4 + 1f26cbf commit 2c527f2

File tree

14 files changed

+21
-114
lines changed

14 files changed

+21
-114
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
### Removed
3333

3434
- modelling/multibody : remove txx files, remove `context.hpp`
35-
- core : remove `callback-base.txx`
35+
- core : remove `callback-base.txx`, remove `constraint.txx`
36+
- core : remove deprecated class template `StageConstraintTpl`, and its Python bindings
3637

3738
## [0.16.0] - 2025-10-15
3839

bindings/python/src/expose-constraint.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@
99
namespace aligator::python {
1010
using context::ConstraintSet;
1111
using context::ConstraintStack;
12-
using context::StageConstraint;
1312
using context::StageFunction;
1413
using PolyFunc = xyz::polymorphic<StageFunction>;
1514
using PolySet = xyz::polymorphic<ConstraintSet>;
1615

17-
context::StageConstraint *make_constraint_wrap(const PolyFunc &f,
18-
const PolySet &c) {
19-
return new context::StageConstraint{f, c};
20-
}
21-
2216
void exposeConstraintSets();
2317

2418
void exposeConstraint() {
@@ -27,27 +21,6 @@ void exposeConstraint() {
2721
exposeConstraintSets();
2822
}
2923

30-
bp::class_<StageConstraint>(
31-
"StageConstraint",
32-
"A stage-wise constraint, of the form :math:`c(x,u) \\leq 0 c(x,u)`.\n"
33-
":param f: underlying function\n"
34-
":param cs: constraint set",
35-
bp::no_init)
36-
.def("__init__",
37-
bp::make_constructor(
38-
make_constraint_wrap,
39-
eigenpy::deprecation_warning_policy<>(
40-
"This class has been deprecated and will be removed in a "
41-
"future version of aligator."),
42-
("func"_a, "cstr_set")),
43-
"Contruct a StageConstraint from a StageFunction and a constraint "
44-
"set.")
45-
.def_readwrite("func", &StageConstraint::func)
46-
.def_readwrite("set", &StageConstraint::set)
47-
.add_property(
48-
"nr", +[](StageConstraint const &el) { return el.func->nr; },
49-
"Get constraint dimension.");
50-
5124
bp::class_<ConstraintStack>("ConstraintStack", "The stack of constraint.",
5225
bp::no_init)
5326
.add_property("size", &ConstraintStack::size,

bindings/python/src/expose-problem.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ void exposeProblem() {
5858
&TrajOptProblem::setInitState, "Initial state.")
5959
.add_property("init_constraint", &TrajOptProblem::init_constraint_,
6060
"Get initial state constraint.")
61-
.def<void (TrajOptProblem::*)(const context::StageConstraint &)>(
62-
"addTerminalConstraint", &TrajOptProblem::addTerminalConstraint,
63-
eigenpy::deprecated_member<>("This method is deprecated (because "
64-
"StageConstraint has been deprecated)."),
65-
("self"_a, "constraint"), "Add a terminal constraint.")
6661
.def<void (TrajOptProblem::*)(const PolyFunction &, const PolySet &)>(
6762
"addTerminalConstraint", &TrajOptProblem::addTerminalConstraint,
6863
("self"_a, "func", "set"), "Add a terminal constraint.")

bindings/python/src/expose-stage.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ void exposeStage() {
5555
bp::no_init)
5656
.def(bp::init<const PolyCost &, const PolyDynamics &>(
5757
("self"_a, "cost", "dynamics")))
58-
.def<void (StageModel::*)(const context::StageConstraint &)>(
59-
"addConstraint", &StageModel::addConstraint,
60-
eigenpy::deprecated_member<>("This method has been deprecated since "
61-
"StageConstraint is deprecated."),
62-
("self"_a, "constraint"), "Add an existing constraint to the stage.")
6358
.def<void (StageModel::*)(const PolyFunction &, const PolyCstrSet &)>(
6459
"addConstraint", &StageModel::addConstraint,
6560
("self"_a, "func", "cstr_set"),

examples/clqr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include "aligator/modelling/state-error.hpp"
55
#include "aligator/solvers/proxddp/solver-proxddp.hpp"
66

7-
#include "aligator/modelling/constraints.hpp"
7+
#include "aligator/modelling/constraints/box-constraint.hpp"
8+
#include "aligator/modelling/constraints/equality-constraint.hpp"
89
#include <aligator/fmt-eigen.hpp>
910
#include <iostream>
1011
#include "../tests/test_util.hpp"

include/aligator/context.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ using VectorSpace = VectorSpaceTpl<Scalar, Eigen::Dynamic>;
1717
using StageFunction = StageFunctionTpl<Scalar>;
1818
using UnaryFunction = UnaryFunctionTpl<Scalar>;
1919
using StageFunctionData = StageFunctionDataTpl<Scalar>;
20-
using StageConstraint ALIGATOR_DEPRECATED = StageConstraintTpl<Scalar>;
2120

2221
using ConstraintSet = ConstraintSetTpl<Scalar>;
2322

include/aligator/core/constraint.hpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010

1111
namespace aligator {
1212

13-
/// @brief Simple struct holding together a function and set, to describe a
14-
/// constraint.
15-
template <typename Scalar> struct ALIGATOR_DEPRECATED StageConstraintTpl {
16-
xyz::polymorphic<StageFunctionTpl<Scalar>> func;
17-
xyz::polymorphic<ConstraintSetTpl<Scalar>> set;
18-
};
19-
2013
/// @brief Convenience class to manage a stack of constraints.
2114
template <typename Scalar> struct ConstraintStackTpl {
2215
ALIGATOR_DYNAMIC_TYPEDEFS(Scalar);
@@ -95,8 +88,7 @@ template <typename Scalar> void ConstraintStackTpl<Scalar>::clear() {
9588
total_dim_ = 0;
9689
}
9790

98-
} // namespace aligator
99-
10091
#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
101-
#include "aligator/core/constraint.txx"
92+
extern template struct ConstraintStackTpl<context::Scalar>;
10293
#endif
94+
} // namespace aligator

include/aligator/core/constraint.txx

Lines changed: 0 additions & 14 deletions
This file was deleted.

include/aligator/core/stage-model.hpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ template <typename _Scalar> struct StageModelTpl {
3232
using PolyConstraintSet = polymorphic<ConstraintSetTpl<Scalar>>;
3333
using Cost = CostAbstractTpl<Scalar>;
3434
using PolyCost = polymorphic<Cost>;
35-
#pragma GCC diagnostic push
36-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
37-
using StageConstraint = StageConstraintTpl<Scalar>;
38-
#pragma GCC diagnostic pop
3935
using Data = StageDataTpl<Scalar>;
4036

4137
/// State space for the current state \f$x_k\f$.
@@ -105,12 +101,6 @@ template <typename _Scalar> struct StageModelTpl {
105101
int numDual() const { return ndx2() + nc(); }
106102

107103
/// @brief Add a constraint to the stage.
108-
template <typename Cstr, typename = std::enable_if_t<std::is_same_v<
109-
std::decay_t<Cstr>, StageConstraint>>>
110-
ALIGATOR_DEPRECATED void addConstraint(Cstr &&cstr);
111-
112-
/// @copybrief addConstraint().
113-
/// @details Adds a constraint by allocating a new StageConstraintTpl.
114104
void addConstraint(const PolyFunction &func,
115105
const PolyConstraintSet &cstr_set);
116106

@@ -135,18 +125,6 @@ template <typename _Scalar> struct StageModelTpl {
135125
virtual shared_ptr<Data> createData() const;
136126
};
137127

138-
template <typename Scalar>
139-
template <typename Cstr, typename>
140-
void StageModelTpl<Scalar>::addConstraint(Cstr &&cstr) {
141-
const int c_nu = cstr.func->nu;
142-
if (c_nu != this->nu()) {
143-
ALIGATOR_RUNTIME_ERROR(
144-
"Function has the wrong dimension for u: got {:d}, expected {:d}", c_nu,
145-
this->nu());
146-
}
147-
constraints_.pushBack(std::forward<Cstr>(cstr));
148-
}
149-
150128
#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
151129
extern template struct StageModelTpl<context::Scalar>;
152130
#endif

include/aligator/core/traj-opt-problem.hpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ namespace aligator {
5151
* # Stage models
5252
* A stage model (StageModelTpl) describes a node in the discrete-time optimal
5353
* control problem: it consists in a running cost function, and a vector of
54-
* constraints (StageConstraintTpl), the first of which @b must describe
55-
* system dynamics (through a DynamicsModelTpl).
54+
* constraints, the first of which @b must describe system dynamics (through a
55+
* ExplicitDynamicsModelTpl).
5656
*
5757
* # Example
5858
*
@@ -113,10 +113,6 @@ template <typename _Scalar> struct TrajOptProblemTpl {
113113
using CostAbstract = CostAbstractTpl<Scalar>;
114114
using ConstraintSet = ConstraintSetTpl<Scalar>;
115115
using StateErrorResidual = StateErrorResidualTpl<Scalar>;
116-
#pragma GCC diagnostic push
117-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
118-
using StageConstraint = StageConstraintTpl<Scalar>;
119-
#pragma GCC diagnostic pop
120116
using InitializationStrategy =
121117
std::function<void(const Self &, std::vector<VectorXs> &)>;
122118

@@ -185,12 +181,11 @@ template <typename _Scalar> struct TrajOptProblemTpl {
185181
}
186182

187183
/// @brief Add a terminal constraint for the model.
188-
ALIGATOR_DEPRECATED void addTerminalConstraint(const StageConstraint &cstr);
189-
/// @copybrief addTerminalConstraint()
190184
void addTerminalConstraint(const xyz::polymorphic<StageFunction> &func,
191185
const xyz::polymorphic<ConstraintSet> &set) {
192186
this->term_cstrs_.pushBack(func, set);
193187
}
188+
194189
/// @brief Remove all terminal constraints.
195190
void removeTerminalConstraints() { term_cstrs_.clear(); }
196191

0 commit comments

Comments
 (0)