Go to the documentation of this file.
45 std::string mode =
init.SweepMode;
46 if (mode ==
"Forwardly")
48 else if (mode ==
"Symmetric")
50 else if (mode ==
"LocalGaussNewton")
52 else if (mode ==
"LocalGaussNewtonDamped")
69 if (problem->type() !=
"exotica::UnconstrainedEndPoseProblem")
71 ThrowNamed(
"This solver can't use problem of type '" << problem->type() <<
"'!");
74 prob_ = std::static_pointer_cast<UnconstrainedEndPoseProblem>(problem);
85 Eigen::VectorXd q0 =
prob_->ApplyStartState();
118 if (
debug_)
HIGHLIGHT(
"Maximum backtrack iterations reached, exiting.");
163 solution.resize(1,
prob_->N);
170 s = Eigen::VectorXd::Zero(
prob_->N);
172 v = Eigen::VectorXd::Zero(
prob_->N);
187 b = Eigen::VectorXd::Zero(
prob_->N);
190 r = Eigen::VectorXd::Zero(
prob_->N);
247 Vinv.diagonal().setConstant(1);
257 double max_step_size)
259 Eigen::VectorXd diff = qhat_t -
qhat;
260 if ((diff.array().abs().maxCoeff() <
tolerance))
return;
261 double nrm = diff.norm();
262 if (max_step_size > 0. && nrm > max_step_size)
264 qhat += diff * (max_step_size / nrm);
284 for (
int i = 0; i <
prob_->cost.num_tasks; ++i)
286 prec =
prob_->cost.rho(i);
289 const int&
start =
prob_->cost.indexing[i].start_jacobian;
290 const int& len =
prob_->cost.indexing[i].length_jacobian;
291 Jt =
prob_->cost.jacobian.middleRows(
start, len).transpose();
292 R += prec * Jt *
prob_->cost.jacobian.middleRows(
start, len);
300 int max_relocation_iterations,
double tolerance,
bool force_relocation,
301 double max_step_size)
319 if (!((!k && force_relocation) || (
b -
qhat).array().abs().maxCoeff() >
tolerance))
break;
341 bool update_bwd,
int max_relocation_iterations,
double tolerance,
342 double max_step_size)
361 return prob_->GetScalarCost();
390 b_step_ = std::max((
b_old -
b).array().abs().maxCoeff(), 0.0);
395 if (
cost_ < 0)
return -1.0;
UnconstrainedEndPoseProblemPtr prob_
Shared pointer to the planning problem.
double Step()
Compute one step of the AICO algorithm.
@ LOCAL_GAUSS_NEWTON_DAMPED
bool sweep_improved_cost_
Whether the last sweep improved the cost (for backtrack iterations count)
int max_backtrack_iterations_
Max. number of sweeps without improvement before terminating (= line-search)
Eigen::VectorXd qhat_old
Point of linearisation (last most optimal value)
double function_tolerance_
Relative function tolerance/first-order optimality criterion.
Eigen::VectorXd b_old
Belief mean (last most optimal value)
Eigen::MatrixXd Binv
Belief covariance inverse.
void UpdateTimestep(bool update_fwd, bool update_bwd, int max_relocation_iterations, double tolerance, bool force_relocation, double max_step_size=-1.)
Update messages for given time step.
void RememberOldState()
Stores the previous state.
Eigen::VectorXd q
Configuration space trajectory.
Eigen::MatrixXd W
Configuration space weight matrix inverse.
void Instantiate(const BayesianIKSolverInitializer &init) override
Eigen::VectorXd qhat
Point of linearisation.
Eigen::MatrixXd Winv
Configuration space weight matrix inverse.
double EvaluateTrajectory(const Eigen::VectorXd &x, bool skip_update=false)
Computes the cost of the trajectory.
void GetTaskCosts()
Updates the task cost terms . UnconstrainedEndPoseProblem::Update() has to be called before calling t...
@ BacktrackIterationLimit
void UpdateFwdMessage()
Updates the forward message Updates the mean and covariance of the forward message using: ,...
int sweep_mode_
Sweep mode.
Eigen::MatrixXd Sinv_old
Forward message covariance inverse (last most optimal value)
Eigen::VectorXd b
Belief mean.
#define REGISTER_MOTIONSOLVER_TYPE(TYPE, DERIV)
Eigen::VectorXd r
Task message mean.
#define ROS_WARN_STREAM(args)
void SpecifyProblem(PlanningProblemPtr pointer) override
Binds the solver to a specific problem which must be pre-initalised.
void InitMessages()
Initializes message data.
Eigen::VectorXd s
Forward message mean.
Eigen::VectorXd v
Backward message mean.
Eigen::MatrixXd Vinv_old
Backward message covariance inverse (last most optimal value)
Eigen::MatrixXd Vinv
Backward message covariance inverse.
Solves motion planning problem using Approximate Inference Control method.
double cost_old_
cost of MAP trajectory (last most optimal value)
int GetNumberOfMaxIterations()
double minimum_step_tolerance_
Update tolerance to stop update of messages if change of maximum coefficient is less than this tolera...
int iteration_count_
Iteration counter.
void UpdateTimestepGaussNewton(bool update_fwd, bool update_bwd, int max_relocation_iterations, double tolerance, double max_step_size=-1.)
Update messages for given time step using the Gauss Newton method.
double damping_init_
Damping.
Eigen::MatrixXd Sinv
Forward message covariance inverse.
double cost_
cost of MAP trajectory
void InitTrajectory(const Eigen::VectorXd &q_init)
Initialise AICO messages from an initial trajectory.
double step_tolerance_
Relative step tolerance (termination criterion)
Eigen::VectorXd r_old
Task message mean (last most optimal value)
void PerhapsUndoStep()
Reverts back to previous state if the cost of the current state is higher.
Eigen::VectorXd s_old
Forward message mean (last most optimal value)
std::shared_ptr< PlanningProblem > PlanningProblemPtr
bool use_bwd_msg_
Flag for using backward message initialisation.
double rhat_old
Task message point of linearisation (last most optimal value)
void UpdateTaskMessage(const Eigen::Ref< const Eigen::VectorXd > &qhat_t, double tolerance, double max_step_size=-1.)
Updates the task message.
Eigen::VectorXd v_old
Backward message mean (last most optimal value)
static void inverseSymPosDef(T1 &Ainv, const T2 &A)
Computes an inverse of a symmetric positive definite matrix.
Eigen::MatrixXd R
Task message covariance.
double b_step_
Squared configuration space step.
void init(const M_string &remappings)
Eigen::MatrixXd R_old
Task message covariance (last most optimal value)
double rhat
Task message point of linearisation.
Eigen::VectorXd bwd_msg_v_
Backward message initialisation mean.
Eigen::VectorXd damping_reference_
Damping reference point.
Eigen::MatrixXd Binv_old
Belief covariance inverse (last most optimal value)
Eigen::MatrixXd bwd_msg_Vinv_
Backward message initialisation covariance.
Eigen::VectorXd q_old
Configuration space trajectory (last most optimal value)
virtual void SpecifyProblem(PlanningProblemPtr pointer)
void Solve(Eigen::MatrixXd &solution) override
Solves the problem.
double cost_prev_
previous iteration cost
double GetDuration() const
void UpdateBwdMessage()
Updates the backward message Updates the mean and covariance of the backward message using: ,...
static void AinvBSymPosDef(T1 &x, const T2 &A, const T3 &b)
Computes the solution to the linear problem for symmetric positive definite matrix A.