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")
56 ThrowNamed(
"Unknown sweep mode '" << init.SweepMode <<
"'");
69 if (problem->type() !=
"exotica::UnconstrainedEndPoseProblem")
71 ThrowNamed(
"This solver can't use problem of type '" << problem->type() <<
"'!");
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);
293 r += prec * Jt * (-
prob_->cost.ydiff.segment(start, len) +
prob_->cost.jacobian.middleRows(start, len) *
qhat);
294 rhat += prec * (-
prob_->cost.ydiff.segment(start, len) +
prob_->cost.jacobian.middleRows(start, len) *
qhat).squaredNorm();
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();
395 if (
cost_ < 0)
return -1.0;
static void AinvBSymPosDef(T1 &x, const T2 &A, const T3 &b)
Computes the solution to the linear problem for symmetric positive definite matrix A...
Solves motion planning problem using Approximate Inference Control method.
double cost_
cost of MAP trajectory
bool sweep_improved_cost_
Whether the last sweep improved the cost (for backtrack iterations count)
double rhat
Task message point of linearisation.
Eigen::VectorXd s
Forward message mean.
double b_step_
Squared configuration space step.
Eigen::MatrixXd R
Task message covariance.
Eigen::VectorXd qhat
Point of linearisation.
double Step()
Compute one step of the AICO algorithm.
void UpdateFwdMessage()
Updates the forward message Updates the mean and covariance of the forward message using: ...
Eigen::VectorXd b_old
Belief mean (last most optimal value)
double cost_old_
cost of MAP trajectory (last most optimal value)
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.
IMETHOD Vector diff(const Vector &p_w_a, const Vector &p_w_b, double dt=1)
Eigen::VectorXd q_old
Configuration space trajectory (last most optimal value)
Eigen::MatrixXd bwd_msg_Vinv_
Backward message initialisation covariance.
int GetNumberOfMaxIterations()
virtual void SpecifyProblem(PlanningProblemPtr pointer)
double GetDuration() const
#define REGISTER_MOTIONSOLVER_TYPE(TYPE, DERIV)
bool use_bwd_msg_
Flag for using backward message initialisation.
void InitTrajectory(const Eigen::VectorXd &q_init)
Initialise AICO messages from an initial trajectory.
Eigen::VectorXd bwd_msg_v_
Backward message initialisation mean.
Eigen::MatrixXd Vinv_old
Backward message covariance inverse (last most optimal value)
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.
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)
double minimum_step_tolerance_
Update tolerance to stop update of messages if change of maximum coefficient is less than this tolera...
double cost_prev_
previous iteration cost
double EvaluateTrajectory(const Eigen::VectorXd &x, bool skip_update=false)
Computes the cost of the trajectory.
Eigen::MatrixXd R_old
Task message covariance (last most optimal value)
void InitMessages()
Initializes message data.
Eigen::VectorXd v_old
Backward message mean (last most optimal value)
void GetTaskCosts()
Updates the task cost terms . UnconstrainedEndPoseProblem::Update() has to be called before calling t...
Eigen::MatrixXd Winv
Configuration space weight matrix inverse.
Eigen::VectorXd damping_reference_
Damping reference point.
Eigen::MatrixXd Sinv_old
Forward message covariance inverse (last most optimal value)
Eigen::MatrixXd Binv_old
Belief covariance inverse (last most optimal value)
#define ROS_WARN_STREAM(args)
BayesianIKSolverInitializer parameters_
UnconstrainedEndPoseProblemPtr prob_
Shared pointer to the planning problem.
static void inverseSymPosDef(T1 &Ainv, const T2 &A)
Computes an inverse of a symmetric positive definite matrix.
Eigen::VectorXd qhat_old
Point of linearisation (last most optimal value)
Eigen::VectorXd q
Configuration space trajectory.
Eigen::MatrixXd W
Configuration space weight matrix inverse.
void Solve(Eigen::MatrixXd &solution) override
Solves the problem.
int sweep_mode_
Sweep mode.
Eigen::MatrixXd Vinv
Backward message covariance inverse.
int max_backtrack_iterations_
Max. number of sweeps without improvement before terminating (= line-search)
INLINE Rall1d< T, V, S > abs(const Rall1d< T, V, S > &x)
double damping_init_
Damping.
Eigen::VectorXd v
Backward message mean.
Eigen::VectorXd r_old
Task message mean (last most optimal value)
void SpecifyProblem(PlanningProblemPtr pointer) override
Binds the solver to a specific problem which must be pre-initalised.
Eigen::MatrixXd Binv
Belief covariance inverse.
Eigen::VectorXd b
Belief mean.
void Instantiate(const BayesianIKSolverInitializer &init) override
std::shared_ptr< PlanningProblem > PlanningProblemPtr
double function_tolerance_
Relative function tolerance/first-order optimality criterion.
void UpdateTaskMessage(const Eigen::Ref< const Eigen::VectorXd > &qhat_t, double tolerance, double max_step_size=-1.)
Updates the task message.
int iteration_count_
Iteration counter.
void RememberOldState()
Stores the previous state.
double rhat_old
Task message point of linearisation (last most optimal value)
void UpdateBwdMessage()
Updates the backward message Updates the mean and covariance of the backward message using: ...
Eigen::MatrixXd Sinv
Forward message covariance inverse.
double step_tolerance_
Relative step tolerance (termination criterion)
Eigen::VectorXd r
Task message mean.