QBSOFTHAND RESEARCH USER MANUAL —
39
if
(result != 0 || status != TRUE) {
std::cout <<
"ERROR: fails while activating motor"
<< std::endl;
return
-1;
}
// ...
short
int
currents[2];
// only the first value is meaningful
short
int
positions[3];
// only the first value is meaningful
if
(commGetMeasurements(&file_descriptor, device_id, positions) < 0) {
std::cout <<
"ERROR: fails while retrieving motor position"
<< std::endl;
return
-1;
}
std::cout <<
"INFO : motor position is "
<< positions[0] << std::endl;
if
(commGetCurrents(&file_descriptor, device_id, currents) < 0) {
std::cout <<
"ERROR: fails while retrieving motor current"
<< std::endl;
return
-1;
}
std::cout <<
"INFO : motor current is "
<< currents[0] << std::endl;
// ...
short
int
commands[2];
commands[0] = 10000;
// nearly half closure (max is 19000, min is 0)
commands[1] = 0;
// must be always 0 (only the first value is meaningful)
commSetInputs(&file_descriptor, device_id, commands);
usleep(1000000);
if
(commGetMeasurements(&file_descriptor, device_id, positions) < 0) {
std::cout <<
"ERROR: fails while retrieving motor position"
<< std::endl;
return
-1;
}
std::cout <<
"INFO : motor position is "
<< positions[0] << std::endl;
commands[0] = 0;
// fully open (max is 19000, min is 0)
commands[1] = 0;
// must be always 0 (only the first value is meaningful)
commSetInputs(&file_descriptor, device_id, commands);
usleep(1000000);
// ...
commActivate(&file_descriptor, device_id, FALSE);
//deactivate motor
usleep(10000);
char
status;
int
result = commGetActivate(&file_descriptor, device_id, &status);
if
(result != 0 || status != FALSE) {
std::cout <<
"ERROR: fails while deactivating motor"
<< std::endl;
return
-1;
}
// ...