30 bool CTuMicos::rangeMeasure() {
    39         sprintf(command,
"%u %s ",axis_index,
"nrm");
    41         if (!transmit(command)) 
return false;
    51 bool CTuMicos::moveToAbsPos(
char axis,
double nRad) {
    56         if (!transmit(command)) 
return false;
    66 bool CTuMicos::absPosQ(
char axis,
double &nRad) {
    68         return radQuerry(axis,
'p',nRad);
    76 bool CTuMicos::moveToOffPos(
char axis,
double nRad) {
    81         if (!transmit(command)) 
return false;
    91 bool CTuMicos::offPosQ(
char axis,
double &nRad) {
    93         return radQuerry(axis,
'p',nRad);
   101 bool CTuMicos::maxPosQ(
char axis,
double &nRad) {
   103         return radQuerry(
'u',
'l',nRad); 
   112 bool CTuMicos::minPosQ(
char axis,
double &nRad) {
   114         return radQuerry(
'l',
'l',nRad); 
   122 bool CTuMicos::speed(
char axis,
double radSec) {
   124         return radAsign(axis,
'v',radSec);
   131 bool CTuMicos::speedQ(
char axis,
double &radSec) {
   133         return radQuerry(axis,
'v',radSec);
   141 bool CTuMicos::aceleration(
char axis,
double radSec2){
   143         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   153 bool CTuMicos::acelerationQ(
char axis,
double &radSec2) {
   155         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   165 bool CTuMicos::baseSpeed(
char axis,
double radSec) {
   167         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   176 bool CTuMicos::baseSpeedQ(
char axis,
double &radSec) {
   178         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   188 bool CTuMicos::upperSpeed(
char axis,
double radSec) {
   190         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   199 bool CTuMicos::upperSpeedQ(
char axis,
double &radSec) {
   211 bool CTuMicos::lowerSpeed(
char axis,
double radSec) {
   213         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   223 bool CTuMicos::lowerSpeedQ(
char axis,
double &radSec) {
   235 bool CTuMicos::enableLimitsQ(
bool &enable) {
   237         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   247 bool CTuMicos::enableLimits(
bool set) {
   249         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   259 bool CTuMicos::inmediateExecution(
bool set) {
   261         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   272 bool CTuMicos::aWait(
void) {
   282 bool CTuMicos::haltAll() {
   284         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   293 bool CTuMicos::halt(
char axis) {
   296         sprintf(command,
"%u %s",axis_index,
"nabort");
   298         if (!transmit(command)) 
return false;
   310         char command[50], command2[50];
   311         sprintf(command,
"%u %s ",axis_index,
"nreset");
   313         if (!transmit(command)) 
return false;
   315         sprintf(command2,
"%u %s ",axis_index,
"ncal");
   319         if (!transmit(command2)) 
return false;
   328 bool CTuMicos::save(
void) {
   330         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   341 bool CTuMicos::restoreDefaults(
void){
   343         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   354 bool CTuMicos::restoreFactoryDefaults(
void){
   356         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   369         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   380 void CTuMicos::nversion(
double &nVersion) {
   382         if(!radQuerry(0,
'n',nVersion))
   383                 throw std::runtime_error(
"INCORRECT VERSION");
   391 bool CTuMicos::powerModeQ(
bool transit,
char &
mode){
   393         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   404 bool CTuMicos::powerMode(
bool transit,
char mode){
   406         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   420         sprintf(command,
"%u %s", axis_index, 
"nclear");
   422         if(!transmit(command)) 
return false;
   432 bool CTuMicos::setLimits(
char axis, 
double &l, 
double &u) {
   434         char command[300]=
"";
   435         sprintf(command,
"%f %f %u setnlimit", l, u, axis_index);
   437         if(!transmit(command)) 
return false;
   447 bool CTuMicos::changeMotionDir() {
   450         unsigned int newMotionDir;
   451         char command[300]=
"";
   454         if (!radQuerry(0,
'c',motionDir))
   463         sprintf(command,
"%u %u setmotiondir", newMotionDir, axis_index);
   465         if(!transmit(command))
   475 bool CTuMicos::init(
const string &port){
   482                 cout << endl << 
"[INFO] Start Tu MICOS comunication config:" << endl;
   484                 cout << 
"[PTU::OpenSerialPort] Opening serial port...";
   486                 if(serPort.isOpen()) {
   488                         cout << 
"OK" << endl;
   492                         cout << 
" Error opening serial port";
   497                 cout << 
"[PTU::SetTimeouts] Setting timeouts...";
   498                 serPort.setTimeouts(1000, 1, 1000, 1, 1000);
   499                 cout << 
"OK" << endl;
   501                 cout << 
"[PTU::setBaudRate] Setting baud rate...";
   502                 serPort.setConfig(19200);
   503                 cout << 
"OK" << endl;
   506                 cout << 
"[PTU::setInitialConfiguration] Setting initial configuration...";
   513                         cout << 
" Error setting initial configuration";
   519                 cout << 
"OK" << endl;
   522         catch(std::exception &e)
   541 void CTuMicos::close(){
   544         if (serPort.isOpen()) {
   547                 cout << endl << 
"[INFO] TuMICOS Serial port closed" << endl;
   557 double CTuMicos::radError(
char axis,
double nRadMoved) {
   559         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   570 bool CTuMicos::transmit(
const char * command) {
   579         size_t written = serPort.Write(str,strlen(str));
   593 bool CTuMicos::receive(
const char * command,
char * response) {
   596         unsigned long nReaden;
   601                    nReaden=serPort.Read(&str[cnt],1);
   602                    if (nReaden!=0) cnt++;
   603     } 
while ( (nReaden!=0) && (str[cnt-1]!=
'\n') );
   605         if (nReaden==0)  
return false;
   624 bool CTuMicos::verboseQ(
bool &
mode) {
   626         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   638 bool CTuMicos::verbose(
bool set) {
   640         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   651 bool CTuMicos::echoModeQ(
bool &
mode) {
   653         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   664 bool CTuMicos::echoMode(
bool mode) {
   666         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   677 bool CTuMicos::resolution(
void) {
   679         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   691         return radQuerry(0,
's',rad);
   700 bool CTuMicos::radQuerry(
char axis,
char command,
double &rad) {
   704         bool toRad = 
true, select = 
false;
   706         if (command == 
'p') { 
   707                 sprintf(command2,
"%u %s", axis_index, 
"np");
   708         } 
else if (command == 
'v') { 
   709                 sprintf(command2,
"%u %s", axis_index, 
"gnv");
   710         } 
else if (command == 
's') { 
   711                 sprintf(command2,
"%u %s", axis_index, 
"nst");
   713         } 
else if (command == 
'e') { 
   714                 sprintf(command2,
"%u %s", axis_index, 
"gne");
   716         } 
else if (command == 
'l') { 
   717                 sprintf(command2,
"%u %s", axis_index, 
"getnlimit");
   719         } 
else if (command == 
'n') { 
   720                 sprintf(command2,
"%u %s", axis_index, 
"nversion");
   722         } 
else if (command == 
'c') { 
   723                 sprintf(command2,
"%u %s", axis_index, 
"getmotiondir");
   727         if ( ( !transmit(command2) ) || (!receive(NULL,response)) ) 
return false;
   741                                 rad = (long)atof((
const char*)ptr1);
   743                                 rad = (long)atof((
const char*)ptr2);
   748                         rad = 
DEG2RAD((
double)atof((
const char*)response));
   754                 rad = (long)atof((
const char*)response);
   766 bool CTuMicos::radAsign(
char axis,
char command,
double nRad) {
   771         if (command == 
'v') {
   775         return transmit(command2);
   783 bool CTuMicos::scan(
char axis, 
int tWait, 
float initial, 
float final, 
double radPre){
   785         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   795 long CTuMicos::radToPos(
char axis,
double nrad) {
   797         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   808 double CTuMicos::posToRad(
char axis,
long nPos) {
   810         cout << endl << 
"[ERROR] Command not defined for this PTunit" << endl;
   823         long a = (long)atof((
const char*)sLong);
   833 double CTuMicos::convertToDouble(
char *sDouble) {
   835  char * result=strpbrk(sDouble,
"-0123456789");
   838  return strtod(result,&stop);
   846 int CTuMicos::checkErrors(){
   850         radQuerry(0,
'e',
code);
   852         if ((
int)
code == 0) {
   854                 cout << endl << 
"[No Error]" << endl;
   864                                 cout << endl << 
"[Error] Internal error" << endl;
   867                                 cout << endl << 
"[Error] Wrong parameter type" << endl;
   870                                 cout << endl << 
"[Error] Insufficient parameters on the stack" << endl;
   873                                 cout << endl << 
"[Error] Value range is exceeded" << endl;
   876                                 cout << endl << 
"[Error] Movement range should be exceeded" << endl;
   879                                 cout << endl << 
"[Error] Insufficient parameters on the stack" << endl;
   882                                 cout << endl << 
"[Error] Parameter out of the movement area" << endl;
   885                                 cout << endl << 
"[Error] Unknown command" << endl;
 Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL. 
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Contains classes for various device interfaces. 
char BASE_IMPEXP * strcpy(char *dest, size_t destSize, const char *source) MRPT_NO_THROWS
An OS-independent version of strcpy. 
void clear()
Clear the contents of this container. 
void BASE_IMPEXP sleep(int time_ms) MRPT_NO_THROWS
An OS-independent method for sending the current thread to "sleep" for a given period of time...
long convertToLong(char *sLong)
char BASE_IMPEXP * strcat(char *dest, size_t destSize, const char *source) MRPT_NO_THROWS
An OS-independent version of strcat. 
int BASE_IMPEXP sprintf(char *buf, size_t bufSize, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
#define MRPT_LOG_ERROR_STREAM(__CONTENTS)
GLubyte GLubyte GLubyte a
char BASE_IMPEXP * strtok(char *str, const char *strDelimit, char **context) MRPT_NO_THROWS
An OS-independent method for tokenizing a string.