20 #include <qpushbutton.h> 21 #include <qlineedit.h> 22 #include <qtextbrowser.h> 23 #include <qprogressbar.h> 24 #include <qmessagebox.h> 25 #include <qfiledialog.h> 30 #include <qcheckbox.h> 36 #include "qt_calibration.uic.h" 39 #define DIEonERR(x) if (x < 0) {printf("Fehler %u in %s:%u Datenbankbefehl\n",x,__FILE__,__LINE__);} 50 pushButton10->setEnabled(
false);
52 logBrowser->append(
"Started tracker calibration.\n");
62 { std::stringstream
s;
64 textFulcrumCount->setText(s.str().c_str());
72 std::string serverNameLeft((trackerName->text()).latin1());
73 std::string serverNameRight((trackerName_2->text()).latin1());
75 trackLeft = (Use_Left_Tracker->isChecked());
82 QMessageBox::critical(
this,
"TrackerCalibration",
"Could not connect to any tracker server.",
"OK");
83 logBrowser->append(
"Could not connect to any tracker server.\n");
84 connectedLabel->setText(
"Not connected");
85 connectedLabel->setPaletteForegroundColor(QColor(
"red"));
86 buttonConnectToTracker->setDefault(
true);
90 if (trackLeft) s <<
"Connected to left server " << trackerName->text() <<
"\n";
91 if (
trackRight) s <<
"Connected to right server " << trackerName->text() <<
"\n";
92 logBrowser->append(s.str().c_str());
93 if (trackLeft&
trackRight) connectedLabel->setText(
"Both connected");
else 94 if (trackLeft) connectedLabel->setText(
"Left connected");
else 95 connectedLabel->setText(
"Right connected");
96 connectedLabel->setPaletteForegroundColor(QColor(
"green"));
97 pushButton14->setDefault(
true);
99 logBrowser->scrollToBottom();
110 err = kogmo_rtdb_connect_initinfo (&
dbinfo,
"",
"TrackerCalibrationClient", 0.03);
DIEonERR(err);
117 temp = trackLeftId +
"_raw";
118 oidLeft = kogmo_rtdb_obj_searchinfo_wait (
dbc, temp.c_str(), KOGMO_RTDB_OBJTYPE_E1_FOBTRACKER_RAW, 0, 0);
DIEonERR(
oidLeft);
132 temp = trackRightId +
"_raw";
156 err = kogmo_rtdb_disconnect(
dbc, NULL);
DIEonERR(err);
167 s <<
"Calibration data:\n";
168 for (
unsigned int i=0; i<cal.size(); i++){
170 for (
unsigned int j=0; j<cal[i].size(); j++){
171 s << (cal[i])[j].first <<
":" << (cal[i])[j].second;
172 if(j < cal[i].size()-1)
178 logBrowser->append(s.str().c_str());
179 logBrowser->scrollToBottom();
188 QString qfile = QFileDialog::getSaveFileName(QString::null,
189 "Tracker calibrations (*.calib)",
192 "Choose a filename to save under" );
199 filename = std::string(qfile.latin1());
201 res = ((f=fopen(filename.c_str(),
"w"))!=NULL);
209 printf(
"\nentry %i:\n",i);
212 printf(
"fulcrumyArrayRight(%i):\n",
fcountLeft);
214 printf(
"\nentry %i:\n",i);
227 s <<
"Saved data to file " << filename <<
"\n";
229 s <<
"File " << filename <<
" not saved.\n";
230 logBrowser->append(s.str().c_str());
231 logBrowser->scrollToBottom();
244 QString qfile = QFileDialog::getOpenFileName(QString::null,
245 "Tracker calibrations (*.calib)",
248 "Choose a file to open" );
255 filename = std::string(qfile.latin1());
257 res = ((f=fopen(filename.c_str(),
"r"))!=NULL);
270 printf(
"\nentry %i:\n",i);
273 printf(
"fulcrumyArrayRight(%i):\n",
fcountLeft);
275 printf(
"\nentry %i:\n",i);
289 s <<
"Loaded data from file " << filename <<
"\n";
292 s <<
"File " << filename <<
" not opened.\n";
293 logBrowser->append(s.str().c_str());
294 logBrowser->scrollToBottom();
307 std::stringstream xl,yl,zl;
309 WorldX->setText(xl.str().c_str());
311 WorldY->setText(yl.str().c_str());
313 WorldZ->setText(zl.str().c_str());
317 std::stringstream xr,yr,zr;
319 WorldX_2->setText(xr.str().c_str());
321 WorldY_2->setText(yr.str().c_str());
323 WorldZ_2->setText(zr.str().c_str());
343 QMessageBox::about(
this,
344 "TrackerCalibration",
345 "If you really need some help, there should be a readme file in your Tracker Calibration directory.");
346 BGDBG(0,
"See readme file for help\n");
361 logBrowser->append(
"Left tracker server dead? Could not connect.\n");
364 logBrowser->append(
"RightTracker server dead? Could not connect.\n");
372 fLeft.
worldVal[0]=strtod(WorldX->text(),NULL);
373 fLeft.
worldVal[1]=strtod(WorldY->text(),NULL);
374 fLeft.
worldVal[2]=strtod(WorldZ->text(),NULL);
378 std::stringstream
x,
y,
z;
379 x << fulcrumarrayLeft[
fcountLeft].worldVal[0];
380 WorldX->setText(x.str().c_str());
381 y << fulcrumarrayLeft[
fcountLeft].worldVal[1];
382 WorldY->setText(y.str().c_str());
383 z << fulcrumarrayLeft[
fcountLeft].worldVal[2];
384 WorldZ->setText(z.str().c_str());
392 fRight.
worldVal[0]=strtod(WorldX_2->text(),NULL);
393 fRight.
worldVal[1]=strtod(WorldY_2->text(),NULL);
394 fRight.
worldVal[2]=strtod(WorldZ_2->text(),NULL);
398 std::stringstream
x,
y,
z;
400 WorldX_2->setText(x.str().c_str());
402 WorldY_2->setText(y.str().c_str());
404 WorldZ_2->setText(z.str().c_str());
410 for (
int i=0;i<3;i++)
416 for (
int i=0;i<3;i++)
419 logBrowser->append(s.str().c_str());
431 std::stringstream xl,yl,zl;
433 WorldX->setText(xl.str().c_str());
435 WorldY->setText(yl.str().c_str());
437 WorldZ->setText(zl.str().c_str());
441 std::stringstream xr,yr,zr;
443 WorldX_2->setText(xr.str().c_str());
445 WorldY_2->setText(yr.str().c_str());
447 WorldZ_2->setText(zr.str().c_str());
511 #if Tracker_Calibration_test 513 int main(
int argc,
char **argv)
521 fprintf(stderr,
"For testing simply run the application\n");
virtual void SendDataToTracker_clicked()
kogmo_rtdb_obj_e1_fobtracker_t * dataobj_right
kogmo_rtdb_objid_t oidRight
int main(int argc, char **argv)
virtual void clearAllData()
kogmo_rtdb_obj_info_t dataobj_left_info
TFSIMD_FORCE_INLINE const tfScalar & y() const
std::vector< sensorCal > trackerCal
~Tracker_Calibration_impl()
bool displayCal(trackerCal cal)
virtual void GetNAdd_clicked()
void printFulcrum(fulcrum fulc)
kogmo_rtdb_connect_info_t dbinfo
kogmo_rtdb_obj_e1_fobtracker_t * dataobj_left
fulcrum fulcrumarrayRight[255]
TFSIMD_FORCE_INLINE const tfScalar & x() const
Tracker_Calibration_impl()
virtual void connectSlot()
TFSIMD_FORCE_INLINE const tfScalar & z() const
int openDevice(std::string &trackLeftId, std::string &trackRightId)
kogmo_rtdb_obj_info_t dataobj_right_info
virtual void ResetCalib_clicked()
kogmo_rtdb_objid_t oidLeft
kogmo_rtdb_handle_t * dbc
fulcrum fulcrumarrayLeft[255]