5 #ifndef __pinocchio_algorithm_contact_solver_utils_hpp__
6 #define __pinocchio_algorithm_contact_solver_utils_hpp__
22 typename ConstraintAllocator,
23 typename VectorLikeIn,
24 typename VectorLikeOut>
27 const Eigen::DenseBase<VectorLikeIn> & x,
28 const Eigen::DenseBase<VectorLikeOut> & x_proj_)
30 assert(
x.size() == x_proj_.size());
31 Eigen::DenseIndex
index = 0;
32 VectorLikeOut & x_proj = x_proj_.const_cast_derived();
33 for (
const auto & cone : cones)
35 x_proj.template segment<3>(
index) = cone.project(
x.template segment<3>(
index));
36 assert(cone.isInside(x_proj.template segment<3>(
index),
Scalar(1e-12)));
44 typename ConstraintAllocator,
45 typename VectorLikeIn,
46 typename VectorLikeOut>
49 const Eigen::DenseBase<VectorLikeIn> & x,
50 const Eigen::DenseBase<VectorLikeOut> & x_proj_)
52 assert(
x.size() == x_proj_.size());
53 Eigen::DenseIndex
index = 0;
54 VectorLikeOut & x_proj = x_proj_.const_cast_derived();
55 for (
const auto & cone : cones)
57 x_proj.template segment<3>(
index) = cone.dual().project(
x.template segment<3>(
index));
58 assert(cone.dual().isInside(x_proj.template segment<3>(
index),
Scalar(1e-12)));
65 typename ConstraintAllocator,
66 typename VectorLikeVelocity,
67 typename VectorLikeForce>
70 const Eigen::DenseBase<VectorLikeVelocity> & velocities,
71 const Eigen::DenseBase<VectorLikeForce> & forces)
73 assert(velocities.size() == forces.size());
74 Eigen::DenseIndex
index = 0;
75 Scalar complementarity = 0;
76 for (
const auto & cone : cones)
78 const Scalar cone_complementarity = cone.computeConicComplementarity(
79 velocities.template segment<3>(
index), forces.template segment<3>(
index));
80 complementarity =
math::max(complementarity, cone_complementarity);
84 return complementarity;
89 typename ConstraintAllocator,
90 typename VectorLikeIn,
91 typename VectorLikeOut>
94 const Eigen::DenseBase<VectorLikeIn> & velocities,
95 const Eigen::DenseBase<VectorLikeOut> & shift_)
97 assert(velocities.size() == shift_.size());
98 Eigen::DenseIndex
index = 0;
99 VectorLikeOut & shift = shift_.const_cast_derived();
100 for (
const auto & cone : cones)
102 shift.template segment<3>(
index) =
103 cone.computeNormalCorrection(velocities.template segment<3>(
index));
108 template<
typename Scalar,
typename Constra
intAllocator,
typename VectorLikeIn>
111 const Eigen::DenseBase<VectorLikeIn> & forces)
116 Eigen::DenseIndex
index = 0;
118 for (
const auto & cone : cones)
121 cone.project(forces.template segment<3>(
index)) - forces.template segment<3>(
index);
122 norm =
math::max(norm, df_projected.norm());
131 typename ConstraintAllocator,
132 typename ForceVector,
133 typename VelocityVector>
136 const Eigen::DenseBase<ForceVector> & forces,
137 const Eigen::DenseBase<VelocityVector> & velocities)
142 Eigen::DenseIndex
index = 0;
144 for (
const auto & cone : cones)
147 forces.template segment<3>(
index)
148 - cone.project(forces.template segment<3>(
index) - velocities.template segment<3>(
index));
149 norm =
math::max(norm, df_projected.norm());
182 #endif // ifndef __pinocchio_algorithm_contact_solver_utils_hpp__