robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
sto_cost_function_component_base.hpp
Go to the documentation of this file.
1#ifndef ROBOTOC_STO_COST_FUNCTION_COMPONENT_BASE_HPP_
2#define ROBOTOC_STO_COST_FUNCTION_COMPONENT_BASE_HPP_
3
4#include <memory>
5#include <stdexcept>
6
7#include "Eigen/Core"
8
10
11
12namespace robotoc {
13
19class STOCostFunctionComponentBase : public std::enable_shared_from_this<STOCostFunctionComponentBase> {
20public:
25
30
35
40 const STOCostFunctionComponentBase&) = default;
41
46 STOCostFunctionComponentBase&&) noexcept = default;
47
52 STOCostFunctionComponentBase&&) noexcept = default;
53
60 virtual double evalCost(const TimeDiscretization& time_discretization) const = 0;
61
69 virtual void evalCostDerivatives(const TimeDiscretization& time_discretization,
70 Eigen::VectorXd& lt) const = 0;
71
80 virtual void evalCostHessian(const TimeDiscretization& time_discretization,
81 Eigen::MatrixXd& Qtt) const = 0;
82
89 template <typename Derived>
90 std::shared_ptr<Derived> as_shared_ptr() {
91 auto ptr = shared_from_this();
92 auto derived_ptr = std::dynamic_pointer_cast<Derived>(ptr);
93 if (derived_ptr == nullptr) {
94 throw std::runtime_error("[STOCostFunctionComponentBase] runtime error: failed in down-casting!");
95 }
96 return derived_ptr;
97 }
98
99};
100
101} // namespace robotoc
102
103#endif // ROBOTOC_STO_COST_FUNCTION_COMPONENT_BASE_HPP_
Base class of components of the cost function of the switching time optimization (STO) problem.
Definition: sto_cost_function_component_base.hpp:19
STOCostFunctionComponentBase()
Default constructor.
Definition: sto_cost_function_component_base.hpp:24
STOCostFunctionComponentBase & operator=(const STOCostFunctionComponentBase &)=default
Default copy operator.
virtual ~STOCostFunctionComponentBase()
Destructor.
Definition: sto_cost_function_component_base.hpp:29
STOCostFunctionComponentBase(const STOCostFunctionComponentBase &)=default
Default copy constructor.
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: sto_cost_function_component_base.hpp:90
virtual void evalCostHessian(const TimeDiscretization &time_discretization, Eigen::MatrixXd &Qtt) const =0
Computes the twice-time derivative (Hessian) of the cost on the switching times.
virtual void evalCostDerivatives(const TimeDiscretization &time_discretization, Eigen::VectorXd &lt) const =0
Computes the derivative of the cost on the switching times.
virtual double evalCost(const TimeDiscretization &time_discretization) const =0
Computes the cost on the switching times.
STOCostFunctionComponentBase(STOCostFunctionComponentBase &&) noexcept=default
Default move constructor.
Time discretization of the optimal control problem.
Definition: time_discretization.hpp:20
Definition: constraint_component_base.hpp:17