30 #ifndef EXOTICA_CORE_DYNAMIC_TIME_INDEXED_SHOOTING_PROBLEM_H_ 31 #define EXOTICA_CORE_DYNAMIC_TIME_INDEXED_SHOOTING_PROBLEM_H_ 37 #include <exotica_core/dynamic_time_indexed_shooting_problem_initializer.h> 56 void Instantiate(
const DynamicTimeIndexedShootingProblemInitializer& init)
override;
64 const int&
get_T()
const;
65 void set_T(
const int& T_in);
69 const Eigen::MatrixXd&
get_X()
const;
70 Eigen::VectorXd
get_X(
int t)
const;
73 const Eigen::MatrixXd&
get_U()
const;
74 Eigen::VectorXd
get_U(
int t)
const;
80 const Eigen::MatrixXd&
get_Q(
int t)
const;
83 const Eigen::MatrixXd&
get_Qf()
const;
86 const Eigen::MatrixXd&
get_R()
const;
87 Eigen::MatrixXd
get_F(
int t)
const;
96 std::vector<TaskSpaceVector>
Phi;
121 return Eigen::MatrixXd::Zero(
scene_->get_num_controls(),
scene_->get_num_state_derivative());
130 const double momentum = 0.9;
132 Eigen::VectorXd new_smooth_l1_mean_ = Eigen::VectorXd::Zero(
scene_->get_num_controls());
133 Eigen::VectorXd new_smooth_l1_std_ = Eigen::VectorXd::Zero(
scene_->get_num_controls());
135 for (
int t = 0; t <
T_; ++t)
137 for (
int ui = 0; ui <
scene_->get_num_controls(); ++ui)
139 new_smooth_l1_mean_[ui] += std::abs(
U_.col(t)[ui]);
143 new_smooth_l1_mean_ /=
T_;
145 for (
int t = 0; t <
T_; ++t)
147 for (
int ui = 0; ui <
scene_->get_num_controls(); ++ui)
149 new_smooth_l1_std_[ui] += (std::abs(
U_.col(t)[ui]) - new_smooth_l1_mean_[ui]) * (std::abs(
U_.col(t)[ui]) - new_smooth_l1_mean_[ui]);
153 new_smooth_l1_std_ /=
T_;
156 smooth_l1_std_ = smooth_l1_std_ * momentum + new_smooth_l1_std_ * (1 - momentum);
158 for (
int ui = 0; ui <
scene_->get_num_controls(); ++ui)
174 if (t_in >=
T_ || t_in < -1)
176 ThrowPretty(
"Requested t=" << t_in <<
" out of range, needs to be 0 =< t < " <<
T_);
198 std::vector<Eigen::MatrixXd>
Q_;
201 std::vector<Eigen::MatrixXd>
Ci_;
234 #endif // EXOTICA_CORE_DYNAMIC_TIME_INDEXED_SHOOTING_PROBLEM_H_ void Update(Eigen::VectorXdRefConst u, int t)
Eigen::VectorXd huber_rate_
void Instantiate(const DynamicTimeIndexedShootingProblemInitializer &init) override
virtual ~DynamicTimeIndexedShootingProblem()
void PreUpdate() override
std::normal_distribution< double > standard_normal_noise_
int T_
Number of time steps.
Eigen::VectorXd smooth_l1_std_
const double & get_tau() const
Returns the discretization timestep tau.
void set_X(Eigen::MatrixXdRefConst X_in)
Sets the state trajectory X (can be used as the initial guess)
Eigen::MatrixXd Qf_
Final state cost.
void set_control_cost_weight(const double control_cost_weight_in)
Eigen::VectorXd bimodal_huber_mode2_
Eigen::MatrixXd X_star_
Goal state trajectory (i.e., positions, velocities). Size: num-states x T.
void set_loss_type(const ControlCostLossTermType &loss_type_in)
void EnableStochasticUpdates()
const int & get_T() const
Returns the number of timesteps in the state trajectory.
void set_Qf(Eigen::MatrixXdRefConst Q_in)
Sets the cost weight matrix for time N.
Eigen::MatrixXd GetStateControlCostHessian()
int num_tasks
Number of TaskMaps.
Eigen::MatrixXd GetStateCostHessian(int t)
lxx
void OnSolverIterationEnd()
lxu == lux
std::vector< Hessian > ddPhi_ddu
Stacked TaskMap Hessian w.r.t. control.
std::vector< Eigen::MatrixXd > control_cost_hessian_
std::vector< Eigen::MatrixXd > general_cost_hessian_
std::vector< Eigen::MatrixXd > state_cost_hessian_
std::vector< Eigen::VectorXd > control_cost_jacobian_
void set_Q(Eigen::MatrixXdRefConst Q_in, int t)
Sets the precision matrix for time step t.
std::vector< Hessian > ddPhi_ddx
Stacked TaskMap Hessian w.r.t. state.
int length_Phi
Length of TaskSpaceVector (Phi => stacked task-maps)
const Eigen::MatrixXd & get_Qf() const
Returns the cost weight matrix at time N.
Eigen::MatrixXd X_diff_
Difference between X_ and X_star_. Size: ndx x T.
const Eigen::MatrixXd & get_R() const
Returns the control weight matrix.
Eigen::VectorXd GetStateCostJacobian(int t)
lx
void set_U(Eigen::MatrixXdRefConst U_in)
Sets the control trajectory U (can be used as the initial guess)
std::vector< Eigen::MatrixXd > dPhi_dx
Stacked TaskMap Jacobian w.r.t. state.
const Eigen::Ref< const Eigen::MatrixXd > & MatrixXdRefConst
std::vector< Eigen::MatrixXd > Q_
State space penalty matrix (precision matrix), per time index.
double tau_
Time step duration.
Eigen::MatrixXd R_
Control space penalty matrix.
void set_X_star(Eigen::MatrixXdRefConst X_star_in)
Sets the target state trajectory X.
Eigen::MatrixXd GetControlCostHessian(int t)
luu
std::vector< Eigen::VectorXd > state_cost_jacobian_
void InstantiateCostTerms(const DynamicTimeIndexedShootingProblemInitializer &init)
double get_control_cost_weight() const
void UpdateTaskMaps(Eigen::VectorXdRefConst x, Eigen::VectorXdRefConst u, int t)
const Eigen::MatrixXd & get_Q(int t) const
Returns the precision matrix at time step t.
void UpdateTerminalState(Eigen::VectorXdRefConst x)
std::vector< std::shared_ptr< KinematicResponse > > kinematic_solutions_
Eigen::VectorXd bimodal_huber_mode1_
Eigen::MatrixXd X_
State trajectory (i.e., positions, velocities). Size: num-states x T.
std::vector< Eigen::MatrixXd > dPhi_du
Stacked TaskMap Jacobian w.r.t. control.
Eigen::MatrixXd U_
Control trajectory. Size: num-controls x (T-1)
void DisableStochasticUpdates()
void ReinitializeVariables()
DynamicTimeIndexedShootingProblemInitializer parameters_
const Eigen::MatrixXd & GetControlNoiseJacobian(int column_idx) const
F[i]_u.
Eigen::MatrixXd get_F(int t) const
Returns the noise weight matrix at time t.
const Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
const ControlCostLossTermType & get_loss_type() const
std::vector< Hessian > ddPhi_dxdu
Stacked TaskMap Hessian w.r.t. state and control.
ControlCostLossTermType loss_type_
void set_T(const int &T_in)
Sets the number of timesteps in the state trajectory.
std::vector< Eigen::MatrixXd > dxdiff_
Eigen::MatrixXd CW_
White noise covariance.
Eigen::VectorXd GetControlCostJacobian(int t)
lu
double GetStateCost(int t) const
std::vector< Eigen::MatrixXd > Ci_
Noise weight terms.
const Eigen::MatrixXd & get_X_star() const
Returns the target state trajectory X.
bool stochastic_updates_enabled_
bool stochastic_matrices_specified_
DynamicTimeIndexedShootingProblem()
std::shared_ptr< exotica::DynamicTimeIndexedShootingProblem > DynamicTimeIndexedShootingProblemPtr
void ValidateTimeIndex(int &t_in) const
Checks the desired time index for bounds and supports -1 indexing.
std::vector< TaskSpaceVector > Phi
Stacked TaskMap vector.
const Eigen::MatrixXd & get_X() const
Returns the state trajectory X.
TimeIndexedTask cost
Cost task.
double control_cost_weight_
double GetControlCost(int t) const
Eigen::VectorXd smooth_l1_mean_
const Eigen::MatrixXd & get_U() const
Returns the control trajectory U.
Eigen::VectorXd ApplyStartState(bool update_traj=true) override
std::vector< Eigen::VectorXd > general_cost_jacobian_
int length_jacobian
Length of tangent vector to Phi.