1 #include <Eigen/Geometry>
2 #include <boost/format.hpp>
4 #include <trajopt_sco/expr_ops.hpp>
5 #include <trajopt_sco/modeling_utils.hpp>
11 using namespace Eigen;
15 VectorXd CartPoseErrCalculator::operator()(
const VectorXd& dof_vals)
const
22 VectorXd JointVelErrCalculator::operator()(
const VectorXd& var_vals)
const
24 assert(var_vals.rows() % 2 == 0);
26 int half =
static_cast<int>(var_vals.rows() / 2);
27 int num_vels = half - 1;
29 VectorXd vel = (var_vals.segment(1, num_vels) - var_vals.segment(0, num_vels)).array() *
30 var_vals.segment(half + 1, num_vels).array();
33 VectorXd result(vel.rows() * 2);
34 result.topRows(vel.rows()) = -(upper_tol_ - (vel.array() - target_));
35 result.bottomRows(vel.rows()) = lower_tol_ - (vel.array() - target_);
39 MatrixXd JointVelJacobianCalculator::operator()(
const VectorXd& var_vals)
const
42 int num_vals =
static_cast<int>(var_vals.rows());
43 int half = num_vals / 2;
44 int num_vels = half - 1;
45 MatrixXd jac = MatrixXd::Zero(num_vels * 2, num_vals);
47 for (
int i = 0; i < num_vels; ++i)
51 int time_index = i + half + 1;
52 jac(i, i) = -1.0 * var_vals(time_index);
53 jac(i, i + 1) = 1.0 * var_vals(time_index);
54 jac(i, time_index) = var_vals(i + 1) - var_vals(i);
59 jac.bottomRows(num_vels) = -jac.topRows(num_vels);