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)
#ifdef ENABLE_VISP_NAMESPACE
#endif
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(int argc, char **argv)
{
std::string opt_ip = "localhost";
int opt_port = 5000;
for (int i = 0; i < argc; i++) {
if (std::string(argv[i]) == "--ip")
opt_ip = std::string(argv[i + 1]);
else if (std::string(argv[i]) == "--port")
opt_port = std::atoi(argv[i + 1]);
else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") {
std::cout << "\nUsage: " << argv[0]
<< " [--ip <localhost>] [--port <port>]"
" [--help] [-h]\n"
<< std::endl
<< "Description: " << std::endl
<< " --ip <localhost>" << std::endl
<< "\tHost IP address. Default value: \"localhost\"." << std::endl
<< std::endl
<< " --port <port>" << std::endl
<< "\tCommunication port. Default value: 5000." << std::endl
<< "\tSuggested values: " << std::endl
<< "\t- 5000 to communicate with the Virtuose." << std::endl
<< "\t- 53210 to communicate with the Virtuose equipped with the Glove." << std::endl
<< std::endl;
return EXIT_SUCCESS;
;
}
}
try {
float period = 0.001f;
std::cout << "Try to connect to " << opt_ip << " port " << opt_port << std::endl;
int counter = 0;
bool swtch = true;
while (swtch) {
if (counter >= 10) {
swtch = false;
}
counter++;
}
std::cout << "The end" << std::endl;
}
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
#else
int main()
{
std::cout << "You should install Virtuose API to use this binary..." << std::endl;
return EXIT_SUCCESS;
}
#endif
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
const std::string & getStringMessage() const
vpColVector getArticularPosition() const
void setIpAddressAndPort(const std::string &ip, int port)
void setTimeStep(const float &timeStep)
void setCommandType(const VirtCommandType &type)
void setPeriodicFunction(VirtPeriodicFunction CallBackVirt)
void stopPeriodicFunction()
void setVerbose(bool mode)
void setArticularForce(const vpColVector &articularForce)
void startPeriodicFunction()
VISP_EXPORT void sleepMs(double t)