32 #define ANGK (double)(180.0/32758.0) 35 #define RIGHT_TRACKER_ID 1 36 #define LEFT_TRACKER_ID 2 39 #define POLHEMUS_POS_X 1284.6 40 #define POLHEMUS_POS_Y 1319.2 41 #define POLHEMUS_POS_Z -553.0 42 #define KOORD_OFFSET_X -16.0 43 #define KOORD_OFFSET_Y 65.0 44 #define KOORD_OFFSET_Z 0.0 62 printf(
"try to open serialdev\n");
65 fd = serial_object->open_serial(serial_port.c_str());
67 pthread_mutex_init(&fobMutex,NULL);
76 serial_object->empty_serial(fd);
77 serial_object->close_serial(fd);
79 pthread_mutex_destroy(&fobMutex);
84 _erc = (
unsigned char)(0xF0 | 1);
85 _sensor1 = (
unsigned char)(0xF0 | 2);
86 _sensor2 = (
unsigned char)(0xF0 | 3);
89 static unsigned char birdchangevaluecmd[] = {
'P',50,3};
91 static unsigned char hemispherecmd[] = {
'L',0x00,0x00};
93 static unsigned char align2cmd[] = {
'q',0xFF,0x3F, 0x00,0x00, 0x00,0x80};
94 static unsigned char reframecmd[] = {
'P',0x18, 0x00,0x00, 0x00,0x80, 0x00,0x00};
95 static unsigned char birdsleep[] = {
'G'};
98 cout <<
"Autoconfig command wird an den ERC gesendet." << endl;
99 cout <<
"Tracker wird (werden) kurz gestartet..." << endl;
100 serial_object->write_serial(fd,&_erc, 1);
101 serial_object->write_serial(fd,birdchangevaluecmd,3);
104 cout <<
"Hemisphere command wird an die Snsrs gesendet." << endl;
105 serial_object->write_serial(fd,&_sensor1, 1);
106 serial_object->write_serial(fd,hemispherecmd, 3);
107 serial_object->write_serial(fd,&_sensor2, 1);
108 serial_object->write_serial(fd,hemispherecmd, 3);
111 cout <<
"ref frame command wird an die Snsrs gesendet." << endl;
112 serial_object->write_serial(fd,&_sensor1, 1);
113 serial_object->write_serial(fd,align2cmd, 7);
114 serial_object->write_serial(fd,&_sensor2, 1);
115 serial_object->write_serial(fd,align2cmd, 7);
119 cout <<
"ref frame command wird an den ERC gesendet." << endl;
120 serial_object->write_serial(fd,reframecmd, 8);
124 cout <<
"... und wieder schlafen gelegt, damit wir später nur noch sleep und wakeup machen müssen." << endl;
125 serial_object->empty_serial(fd);
126 serial_object->write_serial(fd,birdsleep,1);
134 pthread_mutex_lock(&fobMutex);
137 static unsigned char birdwakeup[] = {
'F'};
138 serial_object->empty_serial(fd);
140 serial_object->write_serial(fd,birdwakeup,1);
141 printf(
"Schicke wakeup.\n");
145 pthread_mutex_unlock(&fobMutex);
153 pthread_mutex_lock(&fobMutex);
154 cout <<
"Stopping Tracker" << endl;
157 pthread_mutex_unlock(&fobMutex);
160 if ((refcount-1) == 0){
161 static unsigned char birdsleep[] = {
'G'};
162 serial_object->empty_serial(fd);
163 serial_object->write_serial(fd,birdsleep,1);
164 printf(
"Schicke sleep.\n");
168 pthread_mutex_unlock(&fobMutex);
176 ofstream inf(argv, ios::ate | ios::app);
177 cout <<
"rele koordinaten [x y z]: ";
204 pthread_mutex_lock(&fobMutex);
207 cout <<
"get_rawposangles sagt refcount = " << refcount << endl;
208 pthread_mutex_unlock(&fobMutex);
214 unsigned char rs232tofbbcmd, pos_angl_cmd[4];
217 for (i=0; i<12; i++) {
231 cout <<
"Falsche id abgefragt: " << whichtracker << endl;
232 pthread_mutex_unlock(&fobMutex);
236 pos_angl_cmd[0] = rs232tofbbcmd;
237 pos_angl_cmd[1] =
'Y';
238 pos_angl_cmd[2] = rs232tofbbcmd;
239 pos_angl_cmd[3] = 0x42;
246 serial_object->write_serial(fd,pos_angl_cmd,4);
247 serial_object->empty_serial(fd);
248 serial_object->read_serial(fd, (
unsigned char*)birddata, 12);
249 if (birddata[0] & 0x80)
break;
250 cout <<
"waiting..." <<endl;
255 for (i=0; i<12; i=i+2)
258 for (i=0; i<=10; i=i+2) {
267 raw[i] = (int) shortdata[i];
270 pthread_mutex_unlock(&fobMutex);
284 get_rawposangles(whichtracker, intdata);
289 v[i] = ( (double)intdata[i]) * 0.11162109375;
295 v[i] = ( (double)intdata[i]) * 0.0054931640625;
299 pthread_mutex_unlock(&fobMutex);
308 double x,
y,
z, rx, ry, rz;
310 x = (-1.0)*vec[0] * 10;
311 y = (+1.0)*vec[1] * 10;
312 z = (-1.0)*vec[2] * 10;
328 vec[3] = rx * M_PI / 180.0;
329 vec[4] = ry * M_PI / 180.0;
330 vec[5] = rz * M_PI / 180.0;
347 #if BirdTrack_impl_test 349 #include <bgcorba_impl.h> 350 #include "IPRFilter.hh" 351 #include "NotificationManager.hh" 352 #include "NotificationReceiver.hh" 354 int main(
int argc,
char **argv)
356 bgcorba::init(argc, argv);
int main(int argc, char **argv)
void initialize_Tracker()
TFSIMD_FORCE_INLINE const tfScalar & y() const
int polhemus_coord_to_world_coord(double *vec)
void write_to_file(double *v, char *argv)
int get_rawposangles(int whichtracker, int *raw)
TFSIMD_FORCE_INLINE const tfScalar & x() const
BirdTrack_impl(std::string serial_device)
TFSIMD_FORCE_INLINE const tfScalar & z() const
int get_posangles(int whichtracker, double *v)