48 #include <visp3/core/vpTime.h> 49 #include <visp3/robot/vpVirtuose.h> 51 #if defined(VISP_HAVE_VIRTUOSE) 53 void CallBackVirtuose(VirtContext VC,
void *ptr)
57 static bool firstIteration =
true;
65 int force_increase_rate = 500;
66 float cube_size = 0.05f;
74 double virtualStiffnessAng = 20;
75 double virtualDamperAng = 0.182;
76 double virtualDamperAng2 = 0.0456;
105 if (firstIteration) {
106 localPosition0 = localPosition;
107 firstIteration =
false;
120 yd = zd.skew(zd) * xd;
171 rotzYZ = zeed.skew(zeed) * zYZ.normalize();
172 vpColVector forceStiff1 = virtualStiffnessAng * rotzYZ;
175 for (
unsigned int i = 0; i < 3; i++)
176 torque1[i] = forceStiff1[i] - forceDamp1[i];
182 rotzXZ = zeed.skew(zeed) * zXZ.normalize();
183 vpColVector forceStiff2 = virtualStiffnessAng * rotzXZ;
186 for (
unsigned int i = 0; i < 3; i++)
187 torque2[i] = forceStiff2[i] - forceDamp2[i];
197 rotxXY = xdd.skew(xdd) * xXY.normalize();
198 alpha = asin(rotxXY[2]);
200 vpColVector forceStiff3 = virtualStiffnessAng * alpha * zdd;
201 vpColVector forceDamp3 = virtualDamperAng2 * (omegad * zdd) * zdd;
202 for (
unsigned int i = 0; i < 3; i++)
203 torque3[i] = forceStiff3[i] - forceDamp3[i];
205 for (
unsigned int j = 0; j < 3; j++)
206 forceEe[j + 3] = torque1[j] + torque2[j] + torque3[j];
208 forceEe = dFMb * forceEe;
214 for (
unsigned int i = 0; i < 3; i++) {
215 p_min[i] = localPosition0[i] - cube_size / 2;
216 p_max[i] = localPosition0[i] + cube_size / 2;
219 for (
int i = 0; i < 3; i++) {
220 if ((p_min[i] >= localPosition[i])) {
221 forceFeedback[i] = (p_min[i] - localPosition[i]) * force_increase_rate;
222 if (forceFeedback[i] >= force_limit)
223 forceFeedback[i] = force_limit;
224 }
else if ((p_max[i] <= localPosition[i])) {
225 forceFeedback[i] = (p_max[i] - localPosition[i]) * force_increase_rate;
226 if (forceFeedback[i] <= -force_limit)
227 forceFeedback[i] = -force_limit;
229 forceFeedback[i] = 0;
232 for (
unsigned int j = 0; j < 6; j++)
233 finalForce[j] = forceFeedback[j] + forceEe[j];
263 std::cout <<
"The end" << std::endl;
272 std::cout <<
"You should install pthread and/or Virtuose API to use this " void startPeriodicFunction()
void extract(vpRotationMatrix &R) const
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpPoseVector getPhysicalPosition() const
error that can be emited by ViSP classes.
void setPeriodicFunction(VirtPeriodicFunction CallBackVirt)
void setForce(const vpColVector &force)
vpRotationMatrix inverse() const
Implementation of a rotation matrix and operations on such kind of matrices.
vpColVector & normalize()
vpColVector getCol(unsigned int j) const
void setVerbose(bool mode)
VISP_EXPORT void sleepMs(double t)
void setIpAddress(const std::string &ip)
void stopPeriodicFunction()
Implementation of column vector and the associated operations.
Implementation of a pose vector and operations on poses.
vpColVector getPhysicalVelocity() const
Class that consider the case of a translation vector.
const std::string & getStringMessage(void) const
Send a reference (constant) related the error message (can be empty).