11#define ALIGATOR_CHECK_DERIVED_CLASS(Base, Derived) \
12 static_assert((std::is_base_of_v<Base, Derived>), \
13 "Failed check for derived class.")
53 return dynamic_cast<U *
>(&*
cost_);
57 template <
typename U>
const U *
getCost()
const {
59 return dynamic_cast<const U *
>(&*
cost_);
71 return dynamic_cast<const U *
>(&*
dynamics_);
111 virtual void evaluate(
const ConstVectorRef &x,
const ConstVectorRef &u,
116 const ConstVectorRef &u,
121 const ConstVectorRef &u,
128#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
134template <
typename Scalar>
135struct fmt::formatter<aligator::StageModelTpl<Scalar>> {
136 constexpr auto parse(format_parse_context &ctx)
const
137 ->
decltype(ctx.begin()) {
142 format_context &ctx)
const ->
decltype(ctx.out()) {
143 if (stage.ndx1() == stage.ndx2()) {
144 return fmt::format_to(ctx.out(),
148 "\n nc: {:d}, [{:d} constraints]"
150 stage.ndx1(), stage.nu(), stage.nc(),
151 stage.numConstraints());
153 return fmt::format_to(ctx.out(),
157 "\n nc: {:d}, [{:d} constraints]"
160 stage.ndx1(), stage.nu(), stage.nc(),
161 stage.numConstraints(), stage.ndx2());
167template <
typename Scalar>
169 return oss << fmt::format(
"{}", sm);
Defines the constraint object and constraint stack manager for this library.
Base definitions for ternary functions.
Namespace for modelling system dynamics.
std::ostream & operator<<(std::ostream &oss, const StageFunctionDataTpl< T > &self)
#define ALIGATOR_CHECK_DERIVED_CLASS(Base, Derived)
Convenience class to manage a stack of constraints.
Stage costs for control problems.
Explicit forward dynamics model .
Base class for manifolds, to use in cost funcs, solvers...
Data struct for stage models StageModelTpl.
A stage in the control problem.
virtual ~StageModelTpl()=default
PolyManifold xspace_next_
const U * getCost() const
CostAbstractTpl< Scalar > Cost
virtual void computeFirstOrderDerivatives(const ConstVectorRef &x, const ConstVectorRef &u, Data &data) const
Compute the first-order derivatives of the StageModelTpl.
U * getDynamics()
Get a pointer to an expected concrete type for the dynamics class.
virtual bool hasDynModel() const
virtual void computeSecondOrderDerivatives(const ConstVectorRef &x, const ConstVectorRef &u, Data &data) const
Compute the second-order derivatives of the StageModelTpl.
const Manifold & xspace_next() const
polymorphic< Manifold > PolyManifold
ManifoldAbstractTpl< Scalar > Manifold
ALIGATOR_DYNAMIC_TYPEDEFS(Scalar)
ConstraintStackTpl< Scalar > constraints_
virtual void evaluate(const ConstVectorRef &x, const ConstVectorRef &u, Data &data) const
Evaluate all the functions (cost, dynamics, constraints) at this node.
polymorphic< ConstraintSetTpl< Scalar > > PolyConstraintSet
const Cost & cost() const
ExplicitDynamicsModelTpl< Scalar > Dynamics
StageModelTpl(const PolyCost &cost, const PolyDynamics &dynamics)
virtual shared_ptr< Data > createData() const
Create a StageData object.
const Manifold & uspace() const
StageDataTpl< Scalar > Data
int numDual() const
Number of dual variables, i.e. Lagrange multipliers.
polymorphic< Cost > PolyCost
void addConstraint(const PolyFunction &func, const PolyConstraintSet &cstr_set)
Add a constraint to the stage.
const U * getDynamics() const
U * getCost()
Get a pointer to an expected concrete type for the cost function.
polymorphic< Dynamics > PolyDynamics
std::size_t numConstraints() const
Number of constraint objects.
const Manifold & xspace() const
polymorphic< StageFunctionTpl< Scalar > > PolyFunction
int nc() const
Total number of constraints.