aligator  0.6.1
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
quad-state-cost.hpp
Go to the documentation of this file.
1
4#pragma once
5
8
9namespace aligator {
10
12template <typename Scalar>
15 using Base = QuadraticResidualCostTpl<Scalar>;
16 using StateError = StateErrorResidualTpl<Scalar>;
17 using Manifold = ManifoldAbstractTpl<Scalar>;
18
19 // StateError's space variable holds a pointer to the state manifold
20 QuadraticStateCostTpl(shared_ptr<StateError> resdl, const MatrixXs &weights)
21 : Base(resdl->space_, resdl, weights) {}
22
23 QuadraticStateCostTpl(shared_ptr<Manifold> space, const int nu,
24 const ConstVectorRef &target, const MatrixXs &weights)
25 : QuadraticStateCostTpl(std::make_shared<StateError>(space, nu, target),
26 weights) {}
27
28 void setTarget(const ConstVectorRef target) { residual().target_ = target; }
29 ConstVectorRef getTarget() const { return residual().target_; }
30
31protected:
32 StateError &residual() { return static_cast<StateError &>(*this->residual_); }
33 const StateError &residual() const {
34 return static_cast<const StateError &>(*this->residual_);
35 }
36};
37
38template <typename Scalar>
41 using Base = QuadraticResidualCostTpl<Scalar>;
42 using Manifold = ManifoldAbstractTpl<Scalar>;
43 using Error = ControlErrorResidualTpl<Scalar>;
44
45 QuadraticControlCostTpl(shared_ptr<Manifold> space, shared_ptr<Error> resdl,
46 const MatrixXs &weights)
47 : Base(space, resdl, weights) {}
48
49 QuadraticControlCostTpl(shared_ptr<Manifold> space, int nu,
50 const ConstMatrixRef &weights)
52 space, std::make_shared<Error>(space->ndx(), nu), weights) {}
53
54 QuadraticControlCostTpl(shared_ptr<Manifold> space,
55 const ConstVectorRef &target,
56 const ConstMatrixRef &weights)
58 space, std::make_shared<Error>(space->ndx(), target), weights) {}
59
60 void setTarget(const ConstVectorRef &target) { residual().target_ = target; }
61 ConstVectorRef getTarget() const { return residual().target_; }
62
63protected:
64 Error &residual() { return static_cast<Error &>(*this->residual_); }
65 const Error &residual() const {
66 return static_cast<const Error &>(*this->residual_);
67 }
68};
69
70} // namespace aligator
71
72#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
73#include "./quad-state-cost.txx"
74#endif
Main package namespace.
int nu
Control dimension.
shared_ptr< Manifold > space
State dimension.
void setTarget(const ConstVectorRef &target)
QuadraticControlCostTpl(shared_ptr< Manifold > space, int nu, const ConstMatrixRef &weights)
ControlErrorResidualTpl< Scalar > Error
QuadraticControlCostTpl(shared_ptr< Manifold > space, const ConstVectorRef &target, const ConstMatrixRef &weights)
ManifoldAbstractTpl< Scalar > Manifold
QuadraticControlCostTpl(shared_ptr< Manifold > space, shared_ptr< Error > resdl, const MatrixXs &weights)
Quadratic composite of an underlying function.
Quadratic distance cost over the state manifold.
QuadraticStateCostTpl(shared_ptr< StateError > resdl, const MatrixXs &weights)
ManifoldAbstractTpl< Scalar > Manifold
ConstVectorRef getTarget() const
const StateError & residual() const
StateErrorResidualTpl< Scalar > StateError
QuadraticStateCostTpl(shared_ptr< Manifold > space, const int nu, const ConstVectorRef &target, const MatrixXs &weights)
void setTarget(const ConstVectorRef target)