Go to the documentation of this file.
44 return scene_->GetKinematicTree().GetJointLimits();
63 Phi.assign(
T_, y_ref_);
65 x.assign(
T_, Eigen::VectorXd::Zero(
N));
66 xdiff.assign(
T_, Eigen::VectorXd::Zero(
N));
87 typedef Eigen::Triplet<double> T;
89 for (
int t = 1;
t <
T_; ++
t)
91 for (
int n = 0;
n <
N; ++
n)
122 ThrowNamed(
"Invalid number of timesteps: " << T_in);
135 if (tau_in <= 0.)
ThrowPretty(
"tau_ is expected to be greater than 0. (tau_=" << tau_in <<
")");
143 for (
int i = 0; i <
tasks_.size(); ++i)
tasks_[i]->is_used =
false;
153 for (
int t = 1;
t <
T_; ++
t)
183 for (
int i = 0; i < T_; ++i) kinematic_solutions_[i] = std::make_shared<KinematicResponse>(*
scene_->GetKinematicTree().GetKinematicResponse());
188 if (q_init_in.size() !=
T_)
189 ThrowPretty(
"Expected initial trajectory of length "
190 <<
T_ <<
" but got " << q_init_in.size());
191 if (q_init_in[0].rows() !=
N)
192 ThrowPretty(
"Expected states to have " <<
N <<
" rows but got "
193 << q_init_in[0].rows());
206 return tau_ *
static_cast<double>(
T_);
211 if (x_trajectory_in.size() != (
T_ - 1) *
N)
212 ThrowPretty(
"To update using the trajectory Update method, please use a trajectory of size N x (T-1) (" <<
N * (
T_ - 1) <<
"), given: " << x_trajectory_in.size());
214 for (
int t = 1;
t <
T_; ++
t)
216 Update(x_trajectory_in.segment((
t - 1) *
N,
N),
t);
302 for (
int t = 1;
t <
T_; ++
t)
311 Eigen::RowVectorXd jac = Eigen::RowVectorXd::Zero(
N * (
T_ - 1));
312 for (
int t = 1;
t <
T_; ++
t)
373 jac.setFromTriplets(triplet_list.begin(), triplet_list.end());
379 typedef Eigen::Triplet<double> T;
380 std::vector<T> triplet_list;
388 const int row_start =
start;
390 const int column_start = (constraint.first - 1) *
N;
391 const int column_length =
N;
395 for (
int row = row_start; row < row_start + row_length; ++row)
398 for (
int column = column_start; column < column_start + column_length; ++column)
400 triplet_list.emplace_back(Eigen::Triplet<double>(row, column,
jacobian(row_idx, column_idx)));
442 jac.setFromTriplets(triplet_list.begin(), triplet_list.end());
448 typedef Eigen::Triplet<double> T;
449 std::vector<T> triplet_list;
457 const int row_start =
start;
459 const int column_start = (constraint.first - 1) *
N;
460 const int column_length =
N;
464 for (
int row = row_start; row < row_start + row_length; ++row)
467 for (
int column = column_start; column < column_start + column_length; ++column)
469 triplet_list.emplace_back(Eigen::Triplet<double>(row, column,
jacobian(row_idx, column_idx)));
499 WARNING(
"Deprecated method: Please use KinematicTree::GetVelocityLimits");
500 return scene_->GetKinematicTree().GetVelocityLimits();
505 WARNING(
"Deprecated method: Please use KinematicTree::SetJointVelocityLimits");
506 scene_->GetKinematicTree().SetJointVelocityLimits(qdot_max_in);
514 for (
int t = 1;
t <
T_; ++
t)
524 for (
int t = 1;
t <
T_; ++
t)
unsigned int number_of_problem_updates_
void ReinitializeVariables(int _T, std::shared_ptr< PlanningProblem > _prob, const TaskSpaceVector &_Phi)
std::vector< Eigen::VectorXd > initial_trajectory_
void AppendVector(std::vector< Val > &orig, const std::vector< Val > &extra)
void SetGoalNEQ(const std::string &task_name, Eigen::VectorXdRefConst goal, int t=0)
Sets goal for a given task at a given timestep (inequality task).
int get_active_nonlinear_inequality_constraints_dimension() const
Returns the dimension of the active inequality constraints.
Eigen::MatrixXd GetJointVelocityConstraintBounds() const
Returns the joint velocity constraint bounds (constant terms).
std::vector< std::pair< int, int > > active_nonlinear_inequality_constraints_
KinematicRequestFlags flags_
int GetT() const
Returns the number of timesteps in the trajectory.
void SetStartState(Eigen::VectorXdRefConst x)
double GetScalarTransitionCost(int t) const
Returns the scalar transition cost (x^T*W*x) at timestep t.
int joint_velocity_constraint_dimension_
std::vector< Eigen::VectorXd > x
Current internal problem state.
double GetDuration() const
Returns the duration of the trajectory (T * tau).
void SetTau(const double tau_in)
Sets the time discretization tau for the trajectory.
Eigen::VectorXd GetGoalEQ(const std::string &task_name, int t=0)
Returns the goal for a given task at a given timestep (equality task).
void Update(const TaskSpaceVector &big_Phi, Eigen::MatrixXdRefConst big_dPhi_dx, Eigen::MatrixXdRefConst big_dPhi_du, HessianRefConst big_ddPhi_ddx, HessianRefConst big_ddPhi_ddu, HessianRefConst big_ddPhi_dxdu, int t)
Eigen::VectorXd GetEquality() const
Returns the equality constraint values for the entire trajectory.
std::vector< Eigen::MatrixXd > jacobian
void ValidateTimeIndex(int &t_in) const
Checks the desired time index for bounds and supports -1 indexing.
void Update(Eigen::VectorXdRefConst x_trajectory_in)
Updates the entire problem from a given trajectory (e.g., used in an optimization solver)
Eigen::VectorXd GetGoal(const std::string &task_name, int t=0)
Returns the goal for a given task at a given timestep (cost task).
void UpdateMultipleTaskKinematics(std::vector< std::shared_ptr< KinematicResponse >> responses)
void SetGoal(const std::string &task_name, Eigen::VectorXdRefConst goal, int t=0)
Sets goal for a given task at a given timestep (cost task).
void SetGoal(const std::string &task_name, Eigen::VectorXdRefConst goal, int t)
Eigen::Array< Eigen::MatrixXd, Eigen::Dynamic, 1 > Hessian
double GetScalarTaskCost(int t) const
Returns the scalar task cost at timestep t.
void SetRho(const std::string &task_name, const double rho_in, int t)
std::vector< Eigen::Triplet< double > > GetEqualityJacobianTriplets() const
Returns a vector of triplets to fill a sparse Jacobian for the equality constraints.
Eigen::VectorXd GetJointVelocityConstraint() const
Returns the joint velocity constraint inequality terms (linear).
double GetRhoEQ(const std::string &task_name, int t=0)
Returns the precision (Rho) for a given task at a given timestep (equality task).
std::vector< Eigen::VectorXd > GetInitialTrajectory() const
Returns the initial trajectory/seed.
TaskSpaceVector equality_Phi
Eigen::VectorXd GetJointVelocityLimits() const
Returns the per-DoF joint velocity limit vector.
#define HIGHLIGHT_NAMED(name, x)
virtual void PreUpdate()
Updates internal variables before solving, e.g., after setting new values for Rho.
int T_
Number of time steps.
Eigen::VectorXd xdiff_max_
Maximum change in the variables in a single timestep tau_. Gets set/updated via SetJointVelocityLimit...
void SetRhoEQ(const std::string &task_name, const double rho, int t=0)
Sets Rho for a given task at a given timestep (equality task).
void SetT(const int T_in)
Sets the number of timesteps in the trajectory. Note: Rho/Goal need to be updated for every timestep ...
const typedef Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
virtual void ReinitializeVariables()
double tau_
Time step duration.
Eigen::SparseMatrix< double > GetInequalityJacobian() const
Returns the sparse Jacobian matrix of the inequality constraints over the entire trajectory.
std::vector< Hessian > hessian
void SetJointVelocityLimits(const Eigen::VectorXd &qdot_max_in)
Sets the joint velocity limits. Supports N- and 1-dimensional vectors.
void SetRho(const std::string &task_name, const double rho, int t=0)
Sets Rho for a given task at a given timestep (cost task).
Eigen::Ref< Eigen::MatrixXd > MatrixXdRef
TimeIndexedTask equality
General equality task.
std::vector< TaskVectorEntry > map
Eigen::VectorXd GetGoalNEQ(const std::string &task_name, int t=0)
Returns the goal for a given task at a given timestep (goal task).
Eigen::VectorXd GetGoal(const std::string &task_name, int t) const
TimeIndexedTask cost
Cost task.
virtual ~AbstractTimeIndexedProblem()
std::vector< TaskIndexing > indexing
std::vector< TaskSpaceVector > Phi
int get_joint_velocity_constraint_dimension() const
Returns the dimension of the joint velocity constraint (linear inequality).
double GetCost() const
Returns the scalar cost for the entire trajectory (both task and transition cost).
double get_ct() const
Returns the cost scaling factor.
int active_nonlinear_inequality_constraints_dimension_
double GetRho(const std::string &task_name, int t) const
std::vector< Eigen::Triplet< double > > GetJointVelocityConstraintJacobianTriplets() const
Returns the joint velocity constraint Jacobian as triplets.
std::vector< Eigen::VectorXd > rho
std::vector< Eigen::MatrixXd > jacobian
Eigen::RowVectorXd GetScalarTaskJacobian(int t) const
Returns the Jacobian of the scalar task cost at timestep t.
std::vector< Eigen::MatrixXd > S
double GetRho(const std::string &task_name, int t=0)
Returns the precision (Rho) for a given task at a given timestep (cost task).
void SetInitialTrajectory(const std::vector< Eigen::VectorXd > &q_init_in)
Sets the initial trajectory/seed.
std::vector< Eigen::VectorXd > ydiff
Eigen::MatrixXd GetBounds() const
Returns the joint bounds (first column lower, second column upper).
Eigen::SparseMatrix< double > GetEqualityJacobian() const
Returns the sparse Jacobian matrix of the equality constraints over the entire trajectory.
std::vector< std::pair< int, int > > active_nonlinear_equality_constraints_
std::vector< Eigen::VectorXd > xdiff
void SetRhoNEQ(const std::string &task_name, const double rho, int t=0)
Sets Rho for a given task at a given timestep (inequality task).
#define WARNING(x)
With endline.
Eigen::RowVectorXd GetCostJacobian() const
Returns the Jacobian of the scalar cost over the entire trajectory (Jacobian of GetCost).
Eigen::VectorXd q_dot_max_
Joint velocity limit (rad/s)
std::vector< std::shared_ptr< KinematicResponse > > kinematic_solutions_
void SetGoalEQ(const std::string &task_name, Eigen::VectorXdRefConst goal, int t=0)
Sets goal for a given task at a given timestep (equality task).
TimeIndexedTask inequality
General inequality task.
TaskSpaceVector inequality_Phi
double GetTau() const
Returns the time discretization tau for the trajectory.
AbstractTimeIndexedProblem()
std::vector< Eigen::Triplet< double > > GetInequalityJacobianTriplets() const
Returns a vector of triplets to fill a sparse Jacobian for the inequality constraints.
int get_active_nonlinear_equality_constraints_dimension() const
Returns the dimension of the active equality constraints.
std::vector< Eigen::Triplet< double > > joint_velocity_constraint_jacobian_triplets_
Eigen::RowVectorXd GetScalarTransitionJacobian(int t) const
Returns the Jacobian of the transition cost at timestep t.
double GetRhoNEQ(const std::string &task_name, int t=0)
Returns the precision (Rho) for a given task at a given timestep (equality task).
Eigen::VectorXd GetInequality() const
Returns the inequality constraint values for the entire trajectory.
double ct
Normalisation of scalar cost and Jacobian over trajectory length.
geometry_msgs::TransformStamped t
void SetZero(const int n)
int active_nonlinear_equality_constraints_dimension_
exotica_core
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Fri Aug 2 2024 08:43:02