Changeset 136 in flair-src for trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp
- Timestamp:
- 02/13/17 15:02:54 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp
r15 r136 42 42 43 43 VrpnClient_impl::VrpnClient_impl(VrpnClient *self, std::string name, 44 std::string address, uint16_t us_period) { 45 this->us_period = us_period; 44 std::string address) { 46 45 this->self = self; 47 46 serialport = NULL; 47 isConnected=false; 48 48 49 49 mutex = new Mutex(self, name); … … 162 162 163 163 void VrpnClient_impl::Run(void) { 164 struct timeval timeout; 165 timeout.tv_sec=0; 166 timeout.tv_usec=100000; 167 164 168 while (!self->ToBeStopped()) { 165 169 if (UseXbee()) { … … 200 204 t.quat[i] = quat[i]; 201 205 if (fabs(pos[0] > 10) || fabs(pos[1] > 10) || fabs(pos[2] > 10)) { 202 printf("prob pos %f %f %f\n", pos[0], pos[1], pos[2]);206 Printf("prob pos %f %f %f\n", pos[0], pos[1], pos[2]); 203 207 } else { 204 208 // self->Printf("%i %f %f %f … … 210 214 } 211 215 } 212 } else { 213 connection->mainloop(); 214 mutex->GetMutex(); 215 for (unsigned int i = 0; i < trackables.size(); i++) 216 trackables.at(i)->mainloop(); 217 mutex->ReleaseMutex(); 218 219 self->SleepUS(us_period); 216 } else {//!UseXbee() 217 if(connection->connected()==vrpn_true && !isConnected) { 218 isConnected=true; 219 Printf("VRPN connected\n"); 220 } 221 if(connection->connected()==vrpn_false && isConnected) { 222 isConnected=false; 223 Printf("VRPN disconnected\n"); 224 } 225 226 //timeout in mainloop is not well handled if not connected... 227 if(isConnected) { 228 //this is when trackables callbacks are called: 229 if(connection->mainloop(&timeout)!=0) { 230 self->Warn("connection dropped\n"); 231 } 232 //printf("%lld\n",GetTime()/(1000*1000)); 233 mutex->GetMutex(); 234 for (unsigned int i = 0; i < trackables.size(); i++) 235 trackables.at(i)->mainloop(); 236 mutex->ReleaseMutex(); 237 } else { 238 connection->mainloop(); 239 self->SleepMS(10); 240 } 220 241 } 221 242 }
Note:
See TracChangeset
for help on using the changeset viewer.