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};
92 static unsigned char align2cmd[] = {
'q',0xFF,0x3F, 0x00,0x00, 0x00,0x80};
93 static unsigned char reframecmd[] = {
'P',0x18, 0x00,0x00, 0x00,0x80, 0x00,0x00};
94 static unsigned char birdsleep[] = {
'G'};
96 cout <<
"Autoconfig command wird an den ERC gesendet." << endl;
97 cout <<
"Tracker wird (werden) kurz gestartet..." << endl;
98 serial_object->write_serial(fd,&_erc, 1);
99 serial_object->write_serial(fd,birdchangevaluecmd,3);
102 cout <<
"Hemisphere command wird an die Snsrs gesendet." << endl;
103 serial_object->write_serial(fd,&_sensor1, 1);
104 serial_object->write_serial(fd,hemispherecmd, 3);
105 serial_object->write_serial(fd,&_sensor2, 1);
106 serial_object->write_serial(fd,hemispherecmd, 3);
109 cout <<
"ref frame command wird an die Snsrs gesendet." << endl;
110 serial_object->write_serial(fd,&_sensor1, 1);
111 serial_object->write_serial(fd,align2cmd, 7);
112 serial_object->write_serial(fd,&_sensor2, 1);
113 serial_object->write_serial(fd,align2cmd, 7);
117 cout <<
"ref frame command wird an den ERC gesendet." << endl;
118 serial_object->write_serial(fd,reframecmd, 8);
122 cout <<
"... und wieder schlafen gelegt, damit wir später nur noch sleep und wakeup machen müssen." << endl;
123 serial_object->empty_serial(fd);
124 serial_object->write_serial(fd,birdsleep,1);
132 pthread_mutex_lock(&fobMutex);
135 static unsigned char birdwakeup[] = {
'F'};
136 serial_object->empty_serial(fd);
138 serial_object->write_serial(fd,birdwakeup,1);
139 printf(
"Schicke wakeup.\n");
143 pthread_mutex_unlock(&fobMutex);
151 pthread_mutex_lock(&fobMutex);
152 cout <<
"Stopping Tracker" << endl;
155 pthread_mutex_unlock(&fobMutex);
158 if ((refcount-1) == 0){
159 static unsigned char birdsleep[] = {
'G'};
160 serial_object->empty_serial(fd);
161 serial_object->write_serial(fd,birdsleep,1);
162 printf(
"Schicke sleep.\n");
166 pthread_mutex_unlock(&fobMutex);
174 ofstream inf(argv, ios::ate | ios::app);
175 cout <<
"rele koordinaten [x y z]: ";
202 pthread_mutex_lock(&fobMutex);
205 cout <<
"get_rawposangles sagt refcount = " << refcount << endl;
206 pthread_mutex_unlock(&fobMutex);
214 unsigned char rs232tofbbcmd, pos_angl_cmd[4];
217 for (i=0; i<12; i++) {
221 for (i=0; i<6; i++) {
234 cout <<
"Falsche id abgefragt: " << whichtracker << endl;
235 pthread_mutex_unlock(&fobMutex);
239 pos_angl_cmd[0] = rs232tofbbcmd;
240 pos_angl_cmd[1] =
'Y';
241 pos_angl_cmd[2] = rs232tofbbcmd;
242 pos_angl_cmd[3] = 0x42;
249 serial_object->write_serial(fd,pos_angl_cmd,4);
250 serial_object->empty_serial(fd);
251 serial_object->read_serial(fd, (
unsigned char*)birddata, 12);
252 if (birddata[0] & 0x80)
break;
253 cout <<
"waiting..." <<endl;
258 for (i=0; i<12; i=i+2)
261 for (i=0; i<=10; i=i+2) {
270 raw[i] = (int) shortdata[i];
273 pthread_mutex_unlock(&fobMutex);
287 get_rawposangles(whichtracker, intdata);
292 v[i] = ( (double)intdata[i]) * 0.11162109375;
298 v[i] = ( (double)intdata[i]) * 0.0054931640625;
302 pthread_mutex_unlock(&fobMutex);
311 double x,
y,
z, rx, ry, rz;
313 x = (-1.0)*vec[0] * 10;
314 y = (+1.0)*vec[1] * 10;
315 z = (-1.0)*vec[2] * 10;
331 vec[3] = rx * M_PI / 180.0;
332 vec[4] = ry * M_PI / 180.0;
333 vec[5] = rz * M_PI / 180.0;
350 #if BirdTrack_impl_test 352 #include <bgcorba_impl.h> 353 #include "IPRFilter.hh" 354 #include "NotificationManager.hh" 355 #include "NotificationReceiver.hh" 357 int main(
int argc,
char **argv)
359 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)