31 void boardDumperThread::setDevice(PolyDriver *board_d, PolyDriver *debug_d,
int rate, std::string portPrefix, std::string dataToDump,
bool logOnDisk)
40 ok &= board_d->view(pos);
41 ok &= board_d->view(vel);
42 ok &= board_d->view(enc);
43 ok &= board_d->view(pid);
44 ok &= board_d->view(amp);
45 ok &= board_d->view(lim);
46 ok &= board_d->view(trq);
47 ok &= board_d->view(cmod);
48 ok &= board_d->view(imod);
49 ok &= board_d->view(imot);
50 ok &= board_d->view(imotenc);
53 printf(
"Problems acquiring interfaces\n");
55 printf(
"Control board was accessed succesfully!\n");
57 pos->getAxes(&numberOfJoints);
58 fprintf(stderr,
"Number of axes is: %d \n", numberOfJoints);
61 data =
new double [numberOfJoints];
65 portName = portPrefix + dataToDump;
68 logToFile = logOnDisk;
69 this->setPeriod((
double)rate/1000.0);
78 fprintf(stderr,
"Setting the map dimension %d \n",
n);
79 numberOfJointsRead =
n;
80 dataRead =
new double [numberOfJointsRead];
81 dataMap =
new int [numberOfJointsRead];
82 for (
int i = 0; i < numberOfJointsRead; i++)
98 strcpy(buff, this->portName.c_str());
99 for (
size_t i=0; i<strlen(buff); i++)
100 if (buff[i]==
'/') buff[i]=
'_';
105 logFile = fopen(buff,
"w");
108 printf (
"error opening logfile: %s\n",this->portName.c_str());
112 printf (
"logfile opened: %s\n",this->portName.c_str());
141 fprintf(stderr,
"Closing thread \n");
144 fprintf(stderr,
"Closing ports \n");
150 fprintf(stderr,
"Closing logFile \n");
170 getter -> getData(data);
175 for (
int i = 0; i < numberOfJointsRead; i++)
178 dataRead[i] = data[dataMap[i]];
179 bData.addFloat64(dataRead[i]);
186 port->setEnvelope(stmp);
192 port->setEnvelope(stmp);
197 fprintf(stderr,
"boardDumperThread::warning. Trying to get a stamp without a proper IPreciselyTimed defined. \n");
203 sprintf(buff,
"%d ",stmp.getCount());
204 fputs (buff,logFile);
205 sprintf(buff,
"%f ",stmp.getTime());
206 fputs (buff,logFile);
207 fputs (bData.toString().c_str(),logFile);
208 fputs (
"\n",logFile);
void setThetaMap(int *, int)
void setGetter(GetData *)
void setDevice(PolyDriver *board_d, PolyDriver *debug_d, int rate, std::string portPrefix, std::string dataToDump, bool logOnDisk)
yarp::sig::Vector & map(yarp::sig::Vector &v, double(op)(double))
Performs a unary operator inplace on each element of a vector.