robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
cost_function_component_base.hpp
Go to the documentation of this file.
1#ifndef ROBOTOC_COST_FUNCTION_COMPONENT_BASE_HPP_
2#define ROBOTOC_COST_FUNCTION_COMPONENT_BASE_HPP_
3
4#include <memory>
5#include <stdexcept>
6
7#include "Eigen/Core"
8
17
18
19namespace robotoc {
20
25class CostFunctionComponentBase : public std::enable_shared_from_this<CostFunctionComponentBase> {
26public:
31
36
41
46 = default;
47
52
57 = default;
58
68 virtual double evalStageCost(Robot& robot, const ContactStatus& contact_status,
69 CostFunctionData& data, const GridInfo& grid_info,
70 const SplitSolution& s) const = 0;
71
83 virtual void evalStageCostDerivatives(Robot& robot,
84 const ContactStatus& contact_status,
85 CostFunctionData& data,
86 const GridInfo& grid_info,
87 const SplitSolution& s,
88 SplitKKTResidual& kkt_residual) const = 0;
89
102 virtual void evalStageCostHessian(Robot& robot,
103 const ContactStatus& contact_status,
104 CostFunctionData& data,
105 const GridInfo& grid_info,
106 const SplitSolution& s,
107 SplitKKTMatrix& kkt_matrix) const = 0;
108
117 virtual double evalTerminalCost(Robot& robot, CostFunctionData& data,
118 const GridInfo& grid_info,
119 const SplitSolution& s) const = 0;
120
131 virtual void evalTerminalCostDerivatives(Robot& robot,
132 CostFunctionData& data,
133 const GridInfo& grid_info,
134 const SplitSolution& s,
135 SplitKKTResidual& kkt_residual) const = 0;
136
148 virtual void evalTerminalCostHessian(Robot& robot,
149 CostFunctionData& data,
150 const GridInfo& grid_info,
151 const SplitSolution& s,
152 SplitKKTMatrix& kkt_matrix) const = 0;
153
163 virtual double evalImpactCost(Robot& robot,
164 const ImpactStatus& impact_status,
165 CostFunctionData& data,
166 const GridInfo& grid_info,
167 const SplitSolution& s) const = 0;
168
180 virtual void evalImpactCostDerivatives(Robot& robot,
181 const ImpactStatus& impact_status,
182 CostFunctionData& data,
183 const GridInfo& grid_info,
184 const SplitSolution& s,
185 SplitKKTResidual& kkt_residual) const = 0;
186
199 virtual void evalImpactCostHessian(Robot& robot,
200 const ImpactStatus& impact_status,
201 CostFunctionData& data,
202 const GridInfo& grid_info,
203 const SplitSolution& s,
204 SplitKKTMatrix& kkt_matrix) const = 0;
205
212 template <typename Derived>
213 std::shared_ptr<Derived> as_shared_ptr() {
214 auto ptr = shared_from_this();
215 auto derived_ptr = std::dynamic_pointer_cast<Derived>(ptr);
216 if (derived_ptr == nullptr) {
217 throw std::runtime_error("[CostFunctionComponentBase] runtime error: failed in down-casting!");
218 }
219 return derived_ptr;
220 }
221
222};
223
224} // namespace robotoc
225
226#endif // ROBOTOC_COST_FUNCTION_COMPONENT_BASE_HPP_
Contact status of robot model.
Definition: contact_status.hpp:32
Base class of components of cost function.
Definition: cost_function_component_base.hpp:25
virtual double evalStageCost(Robot &robot, const ContactStatus &contact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s) const =0
Computes the stage cost.
CostFunctionComponentBase(const CostFunctionComponentBase &)=default
Default copy constructor.
virtual void evalTerminalCostHessian(Robot &robot, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTMatrix &kkt_matrix) const =0
Computes the Hessian, i.e., the second-order partial derivatives of the teminal cost....
virtual void evalTerminalCostDerivatives(Robot &robot, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTResidual &kkt_residual) const =0
Computes the first-order partial derivatives of the terminal cost. This function is always called jus...
virtual double evalTerminalCost(Robot &robot, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s) const =0
Computes the terminal cost.
std::shared_ptr< Derived > as_shared_ptr()
Gets the shared ptr of this object as the specified type. If this fails in dynamic casting,...
Definition: cost_function_component_base.hpp:213
virtual void evalImpactCostHessian(Robot &robot, const ImpactStatus &impact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTMatrix &kkt_matrix) const =0
Computes the Hessian, i.e., the second-order partial derivatives of the impact cost....
virtual double evalImpactCost(Robot &robot, const ImpactStatus &impact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s) const =0
Computes the impact cost.
virtual void evalStageCostHessian(Robot &robot, const ContactStatus &contact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTMatrix &kkt_matrix) const =0
Computes the Hessian, i.e., the second-order partial derivatives of the stage cost....
CostFunctionComponentBase & operator=(const CostFunctionComponentBase &)=default
Default copy operator.
virtual void evalStageCostDerivatives(Robot &robot, const ContactStatus &contact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTResidual &kkt_residual) const =0
Computes the first-order partial derivatives of the stage cost. This function is always called just a...
CostFunctionComponentBase(CostFunctionComponentBase &&) noexcept=default
Default move constructor.
virtual void evalImpactCostDerivatives(Robot &robot, const ImpactStatus &impact_status, CostFunctionData &data, const GridInfo &grid_info, const SplitSolution &s, SplitKKTResidual &kkt_residual) const =0
Computes the first-order partial derivatives of the impact cost. This function is always called just ...
virtual ~CostFunctionComponentBase()
Destructor.
Definition: cost_function_component_base.hpp:35
CostFunctionComponentBase()
Default constructor.
Definition: cost_function_component_base.hpp:30
Impact status of robot model. Wrapper of ContactStatus to treat impacts.
Definition: impact_status.hpp:21
Dynamics and kinematics model of robots. Wraps pinocchio::Model and pinocchio::Data....
Definition: robot.hpp:32
The KKT matrix split into a time stage.
Definition: split_kkt_matrix.hpp:18
KKT residual split into each time stage.
Definition: split_kkt_residual.hpp:18
Solution to the optimal control problem split into a time stage.
Definition: split_solution.hpp:20
Definition: constraint_component_base.hpp:17
Composed of data used to compute the cost function and its derivatives.
Definition: cost_function_data.hpp:17
Grid information.
Definition: grid_info.hpp:24