Test Haption Virtuose for testing the force feedback in articular mode. A force is felt when approaching to the Virtuose's joint limits (estimated experimentally).
#include <visp3/core/vpTime.h>
#include <visp3/robot/vpVirtuose.h>
#if defined(VISP_HAVE_VIRTUOSE)
void CallBackVirtuose(VirtContext VC, void *ptr)
{
(void)VC;
float maxQ[6] = {0.7811045051f, -0.07668215036f, 2.481732368f, 2.819076777f, 1.044736624f, 2.687076807f};
float minQ[6] = {-0.8011951447f, -1.648244739f, 0.7439950705f, -3.022218227f, -1.260564089f, -2.054088593f};
unsigned int numJoint = 6;
int feedbackRegionFactor = 10;
float saturationForce[6] = {5, 5, 5, 2.5, 2.5, 2.5};
for (unsigned int iter = 0; iter < numJoint; iter++)
feedbackRegion[iter] = (maxQ[iter] - minQ[iter]) / feedbackRegionFactor;
for (unsigned int iter = 0; iter < numJoint; iter++) {
if (currentQ[iter] >= (maxQ[iter] - feedbackRegion[iter])) {
forceFeedback[iter] =
-saturationForce[iter] * pow((currentQ[iter] - maxQ[iter] + feedbackRegion[iter]) / feedbackRegion[iter], 2);
std::cout << "WARNING! Getting close to the maximum joint limit. Joint #" << iter + 1 << std::endl;
} else if (currentQ[iter] <= (minQ[iter] + feedbackRegion[iter])) {
forceFeedback[iter] =
saturationForce[iter] * pow((minQ[iter] + feedbackRegion[iter] - currentQ[iter]) / feedbackRegion[iter], 2);
std::cout << "WARNING! Getting close to the minimum joint limit. Joint #" << iter + 1 << std::endl;
} else {
forceFeedback[iter] = 0;
std::cout << "Safe zone" << std::endl;
}
}
return;
}
int main()
{
try {
float period = 0.001f;
int counter = 0;
bool swtch = true;
while (swtch) {
if (counter >= 10) {
swtch = false;
}
counter++;
}
std::cout << "The end" << std::endl;
}
}
#else
int main() { std::cout << "You should install Virtuose API to use this binary..." << std::endl; }
#endif