42 #include <visp3/core/vpTime.h>
43 #include <visp3/robot/vpVirtuose.h>
45 #if defined(VISP_HAVE_VIRTUOSE)
47 #ifdef ENABLE_VISP_NAMESPACE
51 void CallBackVirtuose(VirtContext VC,
void *ptr)
56 float maxQ[6] = { 0.7811045051f, -0.07668215036f, 2.481732368f, 2.819076777f, 1.044736624f, 2.687076807f };
57 float minQ[6] = { -0.8011951447f, -1.648244739f, 0.7439950705f, -3.022218227f, -1.260564089f, -2.054088593f };
58 unsigned int numJoint = 6;
63 int feedbackRegionFactor = 10;
64 float saturationForce[6] = { 5, 5, 5, 2.5, 2.5, 2.5 };
66 for (
unsigned int iter = 0; iter < numJoint; iter++)
67 feedbackRegion[iter] = (maxQ[iter] - minQ[iter]) / feedbackRegionFactor;
72 for (
unsigned int iter = 0; iter < numJoint; iter++) {
73 if (currentQ[iter] >= (maxQ[iter] - feedbackRegion[iter])) {
75 -saturationForce[iter] * pow((currentQ[iter] - maxQ[iter] + feedbackRegion[iter]) / feedbackRegion[iter], 2);
76 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;
84 forceFeedback[iter] = 0;
85 std::cout <<
"Safe zone" << std::endl;
98 int main(
int argc,
char **argv)
100 std::string opt_ip =
"localhost";
102 for (
int i = 0; i < argc; i++) {
103 if (std::string(argv[i]) ==
"--ip")
104 opt_ip = std::string(argv[i + 1]);
105 else if (std::string(argv[i]) ==
"--port")
106 opt_port = std::atoi(argv[i + 1]);
107 else if (std::string(argv[i]) ==
"--help" || std::string(argv[i]) ==
"-h") {
108 std::cout <<
"\nUsage: " << argv[0]
109 <<
" [--ip <localhost>] [--port <port>]"
112 <<
"Description: " << std::endl
113 <<
" --ip <localhost>" << std::endl
114 <<
"\tHost IP address. Default value: \"localhost\"." << std::endl
116 <<
" --port <port>" << std::endl
117 <<
"\tCommunication port. Default value: 5000." << std::endl
118 <<
"\tSuggested values: " << std::endl
119 <<
"\t- 5000 to communicate with the Virtuose." << std::endl
120 <<
"\t- 53210 to communicate with the Virtuose equipped with the Glove." << std::endl
128 float period = 0.001f;
131 std::cout <<
"Try to connect to " << opt_ip <<
" port " << opt_port << std::endl;
189 std::cout <<
"The end" << std::endl;
201 std::cout <<
"You should install Virtuose API to use this binary..." << std::endl;
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)