Changeset 139 in flair-src for trunk/lib/FlairSensorActuator
- Timestamp:
- Feb 14, 2017, 5:02:06 PM (8 years ago)
- Location:
- trunk/lib/FlairSensorActuator/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp
r136 r139 215 215 } 216 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 } 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 //timeout in mainloop is not well handled if not connected... 226 if(isConnected) { 227 //this is when trackables callbacks are called: 228 if(connection->mainloop(&timeout)!=0) { 229 self->Warn("connection dropped\n"); 230 } 231 //printf("%lld\n",GetTime()/(1000*1000)); 232 mutex->GetMutex(); 233 for (unsigned int i = 0; i < trackables.size(); i++) 234 trackables.at(i)->mainloop(); 235 mutex->ReleaseMutex(); 236 } else { 237 connection->mainloop(); 238 self->SleepMS(10); 239 } 241 240 } 242 241 } -
trunk/lib/FlairSensorActuator/src/VrpnObject_impl.cpp
r135 r139 56 56 } 57 57 58 if (parent->UseXbee()) {59 parent->pimpl_->AddTrackable(this, id);60 tracker = NULL;61 } else {62 parent->pimpl_->AddTrackable(self);63 tracker = new vrpn_Tracker_Remote(name.c_str(), parent->pimpl_->connection);64 tracker->register_change_handler(this, handle_pos);65 tracker->shutup = true;66 }67 68 58 // state 69 59 cvmatrix_descriptor *desc = new cvmatrix_descriptor(7, 1); … … 91 81 z_plot = new DataPlot1D(plot_tab->LastRowLastCol(), "z", -2, 0); 92 82 z_plot->AddCurve(output->Element(6)); 83 84 if(parent->IsRunning()) { 85 self->Warn("adding VrpnObject on running VrpnClient can crash\n"); 86 } 87 88 if (parent->UseXbee()) { 89 tracker = NULL; 90 parent->pimpl_->AddTrackable(this, id); 91 } else { 92 tracker = new vrpn_Tracker_Remote(name.c_str(), parent->pimpl_->connection); 93 tracker->register_change_handler(this, handle_pos); 94 tracker->shutup = true; 95 parent->pimpl_->AddTrackable(self); 96 } 93 97 } 94 98 … … 106 110 } 107 111 108 void VrpnObject_impl::mainloop(void) { tracker->mainloop(); } 112 void VrpnObject_impl::mainloop(void) { 113 tracker->mainloop(); 114 } 109 115 110 116 bool VrpnObject_impl::IsTracked(unsigned int timeout_ms) {
Note:
See TracChangeset
for help on using the changeset viewer.