21 #include <pinocchio/spatial/skew.hpp> 27 using namespace tasks;
32 const double frictionCoefficient,
33 const double minNormalForce,
const double maxNormalForce)
35 m_motionTask(name, robot, frameName),
36 m_forceInequality(name, 17, 12),
37 m_forceRegTask(name, 6, 12),
38 m_contactPoints(contactPoints),
39 m_contactNormal(contactNormal),
40 m_mu(frictionCoefficient),
41 m_fMin(minNormalForce),
42 m_fMax(maxNormalForce) {
49 const double frictionCoefficient,
50 const double minNormalForce,
const double maxNormalForce,
58 m_mu(frictionCoefficient),
61 std::cout <<
"[Contact6d] The constructor with forceRegWeight is deprecated " 62 "now. forceRegWeight should now be specified when calling " 63 "addRigidContact()\n";
78 const int n_in = 4 * 4 + 1;
79 const int n_var = 3 * 4;
80 Matrix B = Matrix::Zero(n_in, n_var);
81 Vector lb = -1e10 * Vector::Ones(n_in);
90 B.block<1, 3>(1, 0) = (t1 -
m_mu * m_contactNormal).transpose();
91 B.block<1, 3>(2, 0) = (-t2 -
m_mu * m_contactNormal).transpose();
92 B.block<1, 3>(3, 0) = (t2 -
m_mu * m_contactNormal).transpose();
94 for (
int i = 1;
i < 4;
i++) {
95 B.block<4, 3>(4 *
i, 3 *
i) = B.topLeftCorner<4, 3>();
98 B.block<1, 3>(n_in - 1, 0) = m_contactNormal.transpose();
99 B.block<1, 3>(n_in - 1, 3) = m_contactNormal.transpose();
100 B.block<1, 3>(n_in - 1, 6) = m_contactNormal.transpose();
101 B.block<1, 3>(n_in - 1, 9) = m_contactNormal.transpose();
113 "f needs to contain " + std::to_string(
n_force()) +
" rows");
125 typedef Eigen::Matrix<double, 6, 6> Matrix6;
126 Matrix6
A = Matrix6::Zero();
135 for (
int i = 0;
i < 4;
i++) {
152 "The number of rows needs to be 3");
154 "The number of cols needs to be 4");
155 if (contactPoints.rows() != 3 || contactPoints.cols() != 4)
return false;
165 contactNormal.size() == 3,
166 "The size of the contactNormal vector needs to equal 3");
167 if (contactNormal.size() != 3)
return false;
175 frictionCoefficient > 0.0,
176 "The friction coefficient needs to be positive");
177 if (frictionCoefficient <= 0.0)
return false;
178 m_mu = frictionCoefficient;
185 minNormalForce > 0.0 && minNormalForce <=
m_fMax,
186 "The minimal normal force needs to be greater than 0 and less than or " 187 "equal to the maximal force");
188 if (minNormalForce <= 0.0 || minNormalForce >
m_fMax)
return false;
197 "The maximal force needs to be greater than " 198 "or equal to the minimal force");
199 if (maxNormalForce <
m_fMin)
return false;
const Vector & lowerBound() const
const Eigen::Ref< const Matrix > ConstRefMatrix
bool setLowerBound(ConstRefVector lb)
bool setUpperBound(ConstRefVector ub)
const Vector & Kp() const
virtual bool setMatrix(ConstRefMatrix A)
void setReference(TrajectorySample &ref)
const Vector & Kd() const
const Vector & upperBound() const
Wrapper for a robot based on pinocchio.
bool setVector(ConstRefVector b)
void skew(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3 > &M)
const ConstraintBase & compute(const double t, ConstRefVector q, ConstRefVector v, Data &data)
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...)
const ConstraintBase & getConstraint() const