47 #include <visp3/core/vpTime.h> 48 #include <visp3/robot/vpVirtuose.h> 50 #if defined(VISP_HAVE_VIRTUOSE) 52 void CallBackVirtuose(VirtContext VC,
void *ptr)
57 float maxQ[6] = {0.7811045051f, -0.07668215036f, 2.481732368f, 2.819076777f, 1.044736624f, 2.687076807f};
58 float minQ[6] = {-0.8011951447f, -1.648244739f, 0.7439950705f, -3.022218227f, -1.260564089f, -2.054088593f};
59 unsigned int numJoint = 6;
64 int feedbackRegionFactor = 10;
65 float saturationForce[6] = {5, 5, 5, 2.5, 2.5, 2.5};
67 for (
unsigned int iter = 0; iter < numJoint; iter++)
68 feedbackRegion[iter] = (maxQ[iter] - minQ[iter]) / feedbackRegionFactor;
73 for (
unsigned int iter = 0; iter < numJoint; iter++) {
74 if (currentQ[iter] >= (maxQ[iter] - feedbackRegion[iter])) {
76 -saturationForce[iter] * pow((currentQ[iter] - maxQ[iter] + feedbackRegion[iter]) / feedbackRegion[iter], 2);
77 std::cout <<
"WARNING! Getting close to the maximum joint limit. Joint #" << iter + 1 << std::endl;
78 }
else if (currentQ[iter] <= (minQ[iter] + feedbackRegion[iter])) {
80 saturationForce[iter] * pow((minQ[iter] + feedbackRegion[iter] - currentQ[iter]) / feedbackRegion[iter], 2);
81 std::cout <<
"WARNING! Getting close to the minimum joint limit. Joint #" << iter + 1 << std::endl;
83 forceFeedback[iter] = 0;
84 std::cout <<
"Safe zone" << std::endl;
97 int main(
int argc,
char **argv)
99 std::string opt_ip =
"localhost";
101 for (
int i = 0; i < argc; i++) {
102 if (std::string(argv[i]) ==
"--ip")
103 opt_ip = std::string(argv[i + 1]);
104 else if (std::string(argv[i]) ==
"--port")
105 opt_port = std::atoi(argv[i + 1]);
106 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
107 std::cout <<
"\nUsage: " << argv[0]
108 <<
" [--ip <localhost>] [--port <port>]" 111 <<
"Description: " << std::endl
112 <<
" --ip <localhost>" << std::endl
113 <<
"\tHost IP address. Default value: \"localhost\"." << std::endl
115 <<
" --port <port>" << std::endl
116 <<
"\tCommunication port. Default value: 5000." << std::endl
117 <<
"\tSuggested values: " << std::endl
118 <<
"\t- 5000 to communicate with the Virtuose." << std::endl
119 <<
"\t- 53210 to communicate with the Virtuose equipped with the Glove." << std::endl
126 float period = 0.001f;
129 std::cout <<
"Try to connect to " << opt_ip <<
" port " << opt_port << std::endl;
187 std::cout <<
"The end" << std::endl;
194 int main() { std::cout <<
"You should install Virtuose API to use this binary..." << std::endl; }
void startPeriodicFunction()
error that can be emited by ViSP classes.
void setPeriodicFunction(VirtPeriodicFunction CallBackVirt)
void setIpAddressAndPort(const std::string &ip, int port)
vpColVector getArticularPosition() const
void setVerbose(bool mode)
VISP_EXPORT void sleepMs(double t)
void setCommandType(const VirtCommandType &type)
void setArticularForce(const vpColVector &articularForce)
void stopPeriodicFunction()
Implementation of column vector and the associated operations.
const std::string & getStringMessage() const
Send a reference (constant) related the error message (can be empty).
void setTimeStep(const float &timeStep)