10 #pragma GCC diagnostic push // include IIT headers and disable warnings 11 #pragma GCC diagnostic ignored "-Wunused-parameter" 12 #pragma GCC diagnostic ignored "-Wunused-value" 16 #pragma GCC diagnostic pop 60 template <
class Kinematics>
102 const SCALAR&
d =
SCALAR(500.0),
107 const std::shared_ptr<Kinematics>& kinematics = std::shared_ptr<Kinematics>(
new Kinematics()))
108 : kinematics_(kinematics),
125 : kinematics_(other.kinematics_->
clone()),
126 smoothing_(other.smoothing_),
129 alpha_(other.alpha_),
130 alpha_n_(other.alpha_n_),
131 zOffset_(other.zOffset_),
132 EEactive_(other.EEactive_)
141 void setActiveEE(
const ActiveMap& activeMap) { EEactive_ = activeMap; }
149 EEForcesLinear eeForces;
157 if (eeInContact(eePenetration))
159 Velocity3S eeVelocity = kinematics_->getEEVelocityInWorld(i, state);
160 eeForces[i] = computeEEForce(eePenetration, eeVelocity);
164 eeForces[i].setZero();
174 SCALAR&
k() {
return k_; }
175 SCALAR&
d() {
return d_; }
185 bool eeInContact(
const Vector3s& eePenetration)
187 if (smoothing_ ==
NONE && eePenetration(2) > 0.0)
201 Vector3s computePenetration(
const size_t&
eeId,
205 Position3S pos = kinematics_->getEEPositionInWorld(eeId, basePose, jointPosition);
208 Vector3s penetration;
220 EEForceLinear computeEEForce(
const Vector3s& eePenetration,
const Velocity3S& eeVelocity)
222 EEForceLinear eeForce;
224 computeDamperForce(eeForce, eePenetration, eeVelocity);
226 smoothEEForce(eeForce, eePenetration);
228 computeNormalSpring(eeForce, eePenetration(2) - zOffset_, eeVelocity.toImplementation()(2));
238 void smoothEEForce(EEForceLinear& eeForce,
const Vector3s& eePenetration)
245 eeForce *= 1. / (1. + TRAIT::exp(eePenetration(2) * alpha_));
249 eeForce *= 0.5 * TRAIT::tanh(-0.5 * eePenetration(2) * alpha_) + 0.5;
252 eeForce *= 0.5 * -eePenetration(2) * alpha_ / (1. + TRAIT::fabs(-eePenetration(2) * alpha_)) + 0.5;
255 throw std::runtime_error(
"undefined smoothing function");
265 void computeDamperForce(EEForceLinear& force,
const Vector3s& eePenetration,
const Velocity3S& eeVelocity)
267 force = -d_ * eeVelocity.toImplementation();
270 void computeNormalSpring(EEForceLinear& force,
const SCALAR& p_N,
const SCALAR& p_dot_N)
274 force(2) += k_ * TRAIT::exp(-alpha_n_ * p_N);
276 else if (p_N <=
SCALAR(0))
278 force(2) -= k_ * p_N;
284 std::shared_ptr<Kinematics> kinematics_;
typename ROBCOGEN::SCALAR SCALAR
Definition: Kinematics.h:53
RigidBodyPose_t & basePose()
get base pose
Definition: RBDState.h:67
JointState< NJOINTS, SCALAR >::JointPositionBlock jointPositions()
get joint positions
Definition: RBDState.h:99
size_t eeId
Definition: rbdJITtests.h:24
Pose of a single rigid body.
Definition: RigidBodyPose.h:29
joint state and joint velocity
Definition: JointState.h:21
ct::rbd::Kinematics< RobCoGenContainer< SCALAR >, Utils< SCALAR >::N_EE > Kinematics
Definition: robcogenHelpers.h:770
joint states and base states
Definition: RBDState.h:27
Vector3Tpl EEForceLinear
Definition: Kinematics.h:67
static const size_t NJOINTS
Definition: Kinematics.h:47
static const size_t NUM_EE
Definition: Kinematics.h:46
Definition: TraitSelector.h:16