Go to the documentation of this file.
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_;
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 ApplyStartState(bool update_traj=true) override
std::mt19937 generator_
Definition: dynamic_time_indexed_shooting_problem.h:215
Eigen::VectorXd l1_rate_
Definition: dynamic_time_indexed_shooting_problem.h:225
DynamicTimeIndexedShootingProblemInitializer parameters_
Definition: property.h:139
const double & get_tau() const
Returns the discretization timestep tau.
Eigen::VectorXd smooth_l1_std_
Definition: dynamic_time_indexed_shooting_problem.h:229
std::vector< Eigen::VectorXd > control_cost_jacobian_
Definition: dynamic_time_indexed_shooting_problem.h:210
virtual ~DynamicTimeIndexedShootingProblem()
void set_X(Eigen::MatrixXdRefConst X_in)
Sets the state trajectory X (can be used as the initial guess)
double control_cost_weight_
Definition: dynamic_time_indexed_shooting_problem.h:220
double get_control_cost_weight() const
Definition: dynamic_time_indexed_shooting_problem.h:167
Eigen::MatrixXd GetStateCostHessian(int t)
lxx
int length_jacobian
Length of tangent vector to Phi.
Definition: dynamic_time_indexed_shooting_problem.h:105
std::vector< Eigen::MatrixXd > general_cost_hessian_
Definition: dynamic_time_indexed_shooting_problem.h:209
std::normal_distribution< double > standard_normal_noise_
Definition: dynamic_time_indexed_shooting_problem.h:216
const int & get_T() const
Returns the number of timesteps in the state trajectory.
void ValidateTimeIndex(int &t_in) const
Checks the desired time index for bounds and supports -1 indexing.
Definition: dynamic_time_indexed_shooting_problem.h:172
std::vector< Eigen::VectorXd > general_cost_jacobian_
Definition: dynamic_time_indexed_shooting_problem.h:208
@ SmoothL1
Definition: dynamic_time_indexed_shooting_problem.h:45
void Instantiate(const DynamicTimeIndexedShootingProblemInitializer &init) override
const Eigen::MatrixXd & get_X() const
Returns the state trajectory X.
@ Undefined
Definition: dynamic_time_indexed_shooting_problem.h:43
void set_Q(Eigen::MatrixXdRefConst Q_in, int t)
Sets the precision matrix for time step t.
ControlCostLossTermType loss_type_
Definition: dynamic_time_indexed_shooting_problem.h:221
void EnableStochasticUpdates()
std::vector< Eigen::MatrixXd > dxdiff_
Definition: dynamic_time_indexed_shooting_problem.h:205
Definition: property.h:110
void set_X_star(Eigen::MatrixXdRefConst X_star_in)
Sets the target state trajectory X.
Definition: cartpole_dynamics_solver.h:38
Eigen::MatrixXd X_star_
Goal state trajectory (i.e., positions, velocities). Size: num-states x T.
Definition: dynamic_time_indexed_shooting_problem.h:194
ControlCostLossTermType
Definition: dynamic_time_indexed_shooting_problem.h:41
DynamicTimeIndexedShootingProblem()
const Eigen::MatrixXd & GetControlNoiseJacobian(int column_idx) const
F[i]_u.
const Eigen::MatrixXd & get_Qf() const
Returns the cost weight matrix at time N.
Eigen::VectorXd bimodal_huber_mode1_
Definition: dynamic_time_indexed_shooting_problem.h:227
std::vector< Hessian > ddPhi_ddu
Stacked TaskMap Hessian w.r.t. control.
Definition: dynamic_time_indexed_shooting_problem.h:100
const Eigen::MatrixXd & get_Q(int t) const
Returns the precision matrix at time step t.
std::vector< Eigen::MatrixXd > dPhi_du
Stacked TaskMap Jacobian w.r.t. control.
Definition: dynamic_time_indexed_shooting_problem.h:98
Eigen::MatrixXd Qf_
Final state cost.
Definition: dynamic_time_indexed_shooting_problem.h:197
const Eigen::MatrixXd & get_U() const
Returns the control trajectory U.
std::vector< Eigen::MatrixXd > state_cost_hessian_
Definition: dynamic_time_indexed_shooting_problem.h:207
ScenePtr scene_
Definition: planning_problem.h:106
Eigen::MatrixXd CW_
White noise covariance.
Definition: dynamic_time_indexed_shooting_problem.h:202
bool stochastic_matrices_specified_
Definition: dynamic_time_indexed_shooting_problem.h:189
std::vector< Eigen::MatrixXd > control_cost_hessian_
Definition: dynamic_time_indexed_shooting_problem.h:211
double GetControlCost(int t) const
const typedef Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
Definition: conversions.h:52
@ Huber
Definition: dynamic_time_indexed_shooting_problem.h:46
std::vector< TaskSpaceVector > Phi
Stacked TaskMap vector.
Definition: dynamic_time_indexed_shooting_problem.h:96
std::vector< std::shared_ptr< KinematicResponse > > kinematic_solutions_
Definition: dynamic_time_indexed_shooting_problem.h:213
std::vector< Hessian > ddPhi_dxdu
Stacked TaskMap Hessian w.r.t. state and control.
Definition: dynamic_time_indexed_shooting_problem.h:101
void set_Qf(Eigen::MatrixXdRefConst Q_in)
Sets the cost weight matrix for time N.
Definition: task_space_vector.h:50
void OnSolverIterationEnd()
lxu == lux
Definition: dynamic_time_indexed_shooting_problem.h:124
const typedef Eigen::Ref< const Eigen::MatrixXd > & MatrixXdRefConst
Definition: conversions.h:53
@ L2
Definition: dynamic_time_indexed_shooting_problem.h:44
void set_U(Eigen::MatrixXdRefConst U_in)
Sets the control trajectory U (can be used as the initial guess)
std::shared_ptr< exotica::DynamicTimeIndexedShootingProblem > DynamicTimeIndexedShootingProblemPtr
Definition: dynamic_time_indexed_shooting_problem.h:231
TimeIndexedTask cost
Cost task.
Definition: dynamic_time_indexed_shooting_problem.h:95
void DisableStochasticUpdates()
void set_loss_type(const ControlCostLossTermType &loss_type_in)
Definition: dynamic_time_indexed_shooting_problem.h:166
Eigen::VectorXd GetControlCostJacobian(int t)
lu
Definition: dynamic_time_indexed_shooting_problem.h:50
Eigen::VectorXd GetStateCostJacobian(int t)
lx
std::vector< Eigen::MatrixXd > dPhi_dx
Stacked TaskMap Jacobian w.r.t. state.
Definition: dynamic_time_indexed_shooting_problem.h:97
int length_Phi
Length of TaskSpaceVector (Phi => stacked task-maps)
Definition: dynamic_time_indexed_shooting_problem.h:104
Eigen::MatrixXd U_
Control trajectory. Size: num-controls x (T-1)
Definition: dynamic_time_indexed_shooting_problem.h:193
void UpdateTerminalState(Eigen::VectorXdRefConst x)
@ PseudoHuber
Definition: dynamic_time_indexed_shooting_problem.h:47
const ControlCostLossTermType & get_loss_type() const
Definition: dynamic_time_indexed_shooting_problem.h:165
void ReinitializeVariables()
#define ThrowPretty(m)
Definition: exception.h:36
void PreUpdate() override
Definition: planning_problem.h:64
double tau_
Time step duration.
Definition: dynamic_time_indexed_shooting_problem.h:188
Eigen::MatrixXd GetControlCostHessian(int t)
luu
Eigen::VectorXd smooth_l1_mean_
Definition: dynamic_time_indexed_shooting_problem.h:229
Eigen::MatrixXd X_
State trajectory (i.e., positions, velocities). Size: num-states x T.
Definition: dynamic_time_indexed_shooting_problem.h:192
int T_
Number of time steps.
Definition: dynamic_time_indexed_shooting_problem.h:187
const Eigen::MatrixXd & get_R() const
Returns the control weight matrix.
void InstantiateCostTerms(const DynamicTimeIndexedShootingProblemInitializer &init)
std::vector< Eigen::MatrixXd > Q_
State space penalty matrix (precision matrix), per time index.
Definition: dynamic_time_indexed_shooting_problem.h:198
Eigen::MatrixXd GetStateControlCostHessian()
Definition: dynamic_time_indexed_shooting_problem.h:115
void set_T(const int &T_in)
Sets the number of timesteps in the state trajectory.
int num_tasks
Number of TaskMaps.
Definition: dynamic_time_indexed_shooting_problem.h:106
Eigen::MatrixXd R_
Control space penalty matrix.
Definition: dynamic_time_indexed_shooting_problem.h:199
std::vector< Eigen::VectorXd > state_cost_jacobian_
Definition: dynamic_time_indexed_shooting_problem.h:206
Eigen::MatrixXd get_F(int t) const
Returns the noise weight matrix at time t.
Eigen::VectorXd huber_rate_
Definition: dynamic_time_indexed_shooting_problem.h:226
std::vector< Eigen::MatrixXd > Ci_
Noise weight terms.
Definition: dynamic_time_indexed_shooting_problem.h:201
const Eigen::MatrixXd & get_X_star() const
Returns the target state trajectory X.
TaskSpaceVector cost_Phi
Definition: dynamic_time_indexed_shooting_problem.h:218
bool stochastic_updates_enabled_
Definition: dynamic_time_indexed_shooting_problem.h:190
double GetStateCost(int t) const
void set_control_cost_weight(const double control_cost_weight_in)
Definition: dynamic_time_indexed_shooting_problem.h:168
void UpdateTaskMaps(Eigen::VectorXdRefConst x, Eigen::VectorXdRefConst u, int t)
Eigen::VectorXd bimodal_huber_mode2_
Definition: dynamic_time_indexed_shooting_problem.h:227
std::vector< Hessian > ddPhi_ddx
Stacked TaskMap Hessian w.r.t. state.
Definition: dynamic_time_indexed_shooting_problem.h:99
Eigen::MatrixXd X_diff_
Difference between X_ and X_star_. Size: ndx x T.
Definition: dynamic_time_indexed_shooting_problem.h:195