12 #include <Eigen/Dense> 22 StateBase(
int xdim) { state_ = Eigen::VectorXd(xdim).setZero(); }
25 StateBase& operator= (
const StateBase& rhs) { state_ = rhs.stateVector();
return *
this; }
26 StateBase operator* (
double scalar)
const {
StateBase new_state; new_state.stateVector() = scalar*state_;
return new_state; }
27 StateBase& operator*=(
double scalar) { state_ *= scalar;
return *
this; }
28 StateBase operator+ (
const StateBase& rhs)
const {
StateBase new_state; new_state.stateVector() = state_+rhs.stateVector();
return new_state; }
29 StateBase& operator+=(
const StateBase& rhs) { state_ += rhs.stateVector();
return *
this; }
30 StateBase operator/ (
double scalar)
const {
StateBase new_state; new_state.stateVector() = state_/scalar;
return new_state; }
31 StateBase& operator/=(
double scalar) { state_ /= scalar;
return *
this; }
33 Eigen::VectorXd& stateVector() {
return state_; }
34 const Eigen::VectorXd& stateVector()
const {
return state_; }
35 void resize(
int xdim) { state_ = Eigen::VectorXd(xdim).setZero(); }
38 Eigen::VectorXd state_;
48 StateSequence(
int tdim,
int xdim) { this->resize(tdim, xdim); }
51 void resize(
int tdim,
int xdim);
52 void setRandom(
double scaling = 1.0);
53 const int size()
const {
return stateseq_.size(); }
54 StateBase& state(
int id) {
return stateseq_[id]; }
55 const StateBase& state(
int id)
const {
return stateseq_[id]; }
58 std::vector<StateBase> stateseq_;
75 void setZero() { feedforward_.setZero(); }
76 Eigen::MatrixXd& feedback() {
return feedback_; }
77 Eigen::VectorXd& feedforward() {
return feedforward_; }
78 const Eigen::MatrixXd& feedback()
const {
return feedback_; }
79 const Eigen::VectorXd& feedforward()
const {
return feedforward_; }
80 void setRandom(
double scaling = 1.0) { feedforward_.setRandom(); feedforward_ *= scaling; }
83 Eigen::MatrixXd feedback_;
84 Eigen::VectorXd feedforward_;
92 ControlSequence(
int tdim,
int xdim,
int udim) { this->resize(tdim, xdim, udim); }
95 void setRandom(
double scaling = 1.0);
96 void resize(
int tdim,
int xdim,
int udim);
97 const int size()
const {
return controlseq_.size(); }
98 ControlBase& control(
int id) {
return controlseq_[id]; }
99 const ControlBase& control(
int id)
const {
return controlseq_[id]; }
110 std::vector<ControlBase> controlseq_;
122 const double& dt()
const {
return this->getLqrSetting().get(SolverLqrDoubleParam_TimeStep); }
123 const int& tdim()
const {
return this->getLqrSetting().get(SolverLqrIntParam_TimeDimension); }
124 const int& xdim()
const {
return this->getLqrSetting().get(SolverLqrIntParam_StateDimension); }
125 const int& udim()
const {
return this->getLqrSetting().get(SolverLqrIntParam_ControlDimension); }
133 virtual void configure(
const YAML::Node& user_parameters) = 0;
134 virtual Eigen::MatrixXd processNoiseFilter(
int time_id)
const;
135 virtual Eigen::MatrixXd measurementNoiseFilter(
int time_id)
const;
138 virtual double objective(
const StateBase& state,
const ControlBase& control,
int time_id,
bool is_final_timestep) = 0;
141 friend class Estimator;
Class to define Control of OCP.
Definition: OcpDescription.hpp:62
Definition: BackwardPass.hpp:17
Definition: FiniteDifferences.hpp:17
Definition: BackwardPass.hpp:15
Definition: OcpDescription.hpp:44
Optimal Control Problem Description Class.
Definition: OcpDescription.hpp:115
Definition: OcpDescription.hpp:88
Definition: ForwardPass.hpp:16
Definition: SolverLqrSetting.hpp:18
Class to define State of OCP.
Definition: OcpDescription.hpp:18