29 bool CTuMicos::rangeMeasure()
    38     sprintf(command, 
"%u %s ", axis_index, 
"nrm");
    40     if (!transmit(command)) 
return false;
    49 bool CTuMicos::moveToAbsPos(
char axis, 
double nRad)
    54     if (!transmit(command)) 
return false;
    63 bool CTuMicos::absPosQ(
char axis, 
double& nRad)
    65     return radQuerry(axis, 
'p', nRad);
    72 bool CTuMicos::moveToOffPos(
char axis, 
double nRad)
    77     if (!transmit(command)) 
return false;
    86 bool CTuMicos::offPosQ(
char axis, 
double& nRad)
    88     return radQuerry(axis, 
'p', nRad);
    95 bool CTuMicos::maxPosQ(
char axis, 
double& nRad)
    97     return radQuerry(
'u', 
'l', nRad);  
   104 bool CTuMicos::minPosQ(
char axis, 
double& nRad)
   106     return radQuerry(
'l', 
'l', nRad);  
   113 bool CTuMicos::speed(
char axis, 
double radSec)
   115     return radAsign(axis, 
'v', radSec);
   122 bool CTuMicos::speedQ(
char axis, 
double& radSec)
   124     return radQuerry(axis, 
'v', radSec);
   131 bool CTuMicos::aceleration(
char axis, 
double radSec2)
   133     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   142 bool CTuMicos::acelerationQ(
char axis, 
double& radSec2)
   144     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   153 bool CTuMicos::baseSpeed(
char axis, 
double radSec)
   155     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   164 bool CTuMicos::baseSpeedQ(
char axis, 
double& radSec)
   166     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   175 bool CTuMicos::upperSpeed(
char axis, 
double radSec)
   177     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   186 bool CTuMicos::upperSpeedQ(
char axis, 
double& radSec)
   197 bool CTuMicos::lowerSpeed(
char axis, 
double radSec)
   199     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   208 bool CTuMicos::lowerSpeedQ(
char axis, 
double& radSec)
   219 bool CTuMicos::enableLimitsQ(
bool& enable)
   221     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   230 bool CTuMicos::enableLimits(
bool set)
   232     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   241 bool CTuMicos::inmediateExecution(
bool set)
   243     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   252 bool CTuMicos::aWait() { 
return true; }
   257 bool CTuMicos::haltAll()
   259     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   268 bool CTuMicos::halt(
char axis)
   271     sprintf(command, 
"%u %s", axis_index, 
"nabort");
   273     if (!transmit(command)) 
return false;
   282 bool CTuMicos::reset()
   284     char command[50], command2[50];
   285     sprintf(command, 
"%u %s ", axis_index, 
"nreset");
   287     if (!transmit(command)) 
return false;
   289     sprintf(command2, 
"%u %s ", axis_index, 
"ncal");
   291     std::this_thread::sleep_for(1000ms);
   293     if (!transmit(command2)) 
return false;
   302 bool CTuMicos::save()
   304     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   313 bool CTuMicos::restoreDefaults()
   315     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   324 bool CTuMicos::restoreFactoryDefaults()
   326     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   335 bool CTuMicos::version(
char* sVersion)
   337     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   346 void CTuMicos::nversion(
double& nVersion)
   348     if (!radQuerry(0, 
'n', nVersion))
   349         throw std::runtime_error(
"INCORRECT VERSION");
   356 bool CTuMicos::powerModeQ(
bool transit, 
char& mode)
   358     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   367 bool CTuMicos::powerMode(
bool transit, 
char mode)
   369     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   381     sprintf(command, 
"%u %s", axis_index, 
"nclear");
   383     if (!transmit(command)) 
return false;
   392 bool CTuMicos::setLimits(
char axis, 
double& l, 
double& u)
   394     char command[300] = 
"";
   395     sprintf(command, 
"%f %f %u setnlimit", l, u, axis_index);
   397     if (!transmit(command)) 
return false;
   406 bool CTuMicos::changeMotionDir()
   409     unsigned int newMotionDir;
   410     char command[300] = 
"";
   413     if (!radQuerry(0, 
'c', motionDir)) 
return false;
   421     sprintf(command, 
"%u %u setmotiondir", newMotionDir, axis_index);
   423     if (!transmit(command)) 
return false;
   432 bool CTuMicos::init(
const string& port)
   438         cout << endl << 
"[INFO] Start Tu MICOS communication config:" << endl;
   440         cout << 
"[PTU::OpenSerialPort] Opening serial port...";
   442         if (serPort.isOpen())
   444             cout << 
"OK" << endl;
   448             cout << 
" Error opening serial port";
   452         cout << 
"[PTU::SetTimeouts] Setting timeouts...";
   453         serPort.setTimeouts(1000, 1, 1000, 1, 1000);
   454         cout << 
"OK" << endl;
   456         cout << 
"[PTU::setBaudRate] Setting baud rate...";
   457         serPort.setConfig(19200);
   458         cout << 
"OK" << endl;
   461         cout << 
"[PTU::setInitialConfiguration] Setting initial "   467         if ((!version) || (!
clear()))
   469             cout << 
" Error setting initial configuration";
   474         cout << 
"OK" << endl;
   476     catch (
const std::exception& e)
   494 void CTuMicos::close()
   497     if (serPort.isOpen())
   500         cout << endl << 
"[INFO] TuMICOS Serial port closed" << endl;
   508 double CTuMicos::radError(
char axis, 
double nRadMoved)
   510     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   519 bool CTuMicos::transmit(
const char* command)
   528     size_t written = serPort.Write(str, strlen(str));
   542 bool CTuMicos::receive(
const char* command, 
char* response)
   545     unsigned long nReaden;
   551         nReaden = serPort.Read(&str[cnt], 1);
   552         if (nReaden != 0) cnt++;
   553     } 
while ((nReaden != 0) && (str[cnt - 1] != 
'\n'));
   555     if (nReaden == 0) 
return false;
   572 bool CTuMicos::verboseQ(
bool& mode)
   574     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   585     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   594 bool CTuMicos::echoModeQ(
bool& mode)
   596     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   605 bool CTuMicos::echoMode(
bool mode)
   607     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   616 bool CTuMicos::resolution()
   618     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   627 double CTuMicos::status(
double& rad) { 
return radQuerry(0, 
's', rad); }
   632 bool CTuMicos::radQuerry(
char axis, 
char command, 
double& rad)
   636     bool toRad = 
true, select = 
false;
   640         sprintf(command2, 
"%u %s", axis_index, 
"np");
   642     else if (command == 
'v')
   644         sprintf(command2, 
"%u %s", axis_index, 
"gnv");
   646     else if (command == 
's')
   648         sprintf(command2, 
"%u %s", axis_index, 
"nst");
   651     else if (command == 
'e')
   653         sprintf(command2, 
"%u %s", axis_index, 
"gne");
   656     else if (command == 
'l')
   658         sprintf(command2, 
"%u %s", axis_index, 
"getnlimit");
   661     else if (command == 
'n')
   663         sprintf(command2, 
"%u %s", axis_index, 
"nversion");
   666     else if (command == 
'c')
   668         sprintf(command2, 
"%u %s", axis_index, 
"getmotiondir");
   672     if ((!transmit(command2)) || (!receive(
nullptr, response))) 
return false;
   686                 rad = (long)atof((
const char*)ptr1);
   688                 rad = (long)atof((
const char*)ptr2);
   693             rad = 
DEG2RAD((
double)atof((
const char*)response));
   699         rad = (long)atof((
const char*)response);
   709 bool CTuMicos::radAsign(
char axis, 
char command, 
double nRad)
   718     return transmit(command2);
   726     char axis, 
int tWait, 
float initial, 
float final, 
double radPre)
   728     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   737 long CTuMicos::radToPos(
char axis, 
double nrad)
   739     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   748 double CTuMicos::posToRad(
char axis, 
long nPos)
   750     cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   761     long a = (long)atof((
const char*)sLong);
   770 double CTuMicos::convertToDouble(
char* sDouble)
   772     char* result = strpbrk(sDouble, 
"-0123456789");
   775     return strtod(result, &stop);
   782 int CTuMicos::checkErrors()
   786     radQuerry(0, 
'e', code);
   790         cout << endl << 
"[No Error]" << endl;
   800                 cout << endl << 
"[Error] Internal error" << endl;
   803                 cout << endl << 
"[Error] Wrong parameter type" << endl;
   807                      << 
"[Error] Insufficient parameters on the stack" << endl;
   810                 cout << endl << 
"[Error] Value range is exceeded" << endl;
   814                      << 
"[Error] Movement range should be exceeded" << endl;
   818                      << 
"[Error] Insufficient parameters on the stack" << endl;
   822                      << 
"[Error] Parameter out of the movement area" << endl;
   825                 cout << endl << 
"[Error] Unknown command" << endl;
 
char * strcat(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcat. 
 
Contains classes for various device interfaces. 
 
char * strcpy(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcpy. 
 
char * strtok(char *str, const char *strDelimit, char **context) noexcept
An OS-independent method for tokenizing a string. 
 
long convertToLong(char *sLong)
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
#define MRPT_LOG_ERROR_STREAM(__CONTENTS)
 
void clear()
Clear the contents of this container. 
 
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...