Changeset 136 in flair-src for trunk/lib/FlairSensorActuator/src
- Timestamp:
- Feb 13, 2017, 3:02:54 PM (8 years ago)
- Location:
- trunk/lib/FlairSensorActuator/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/VrpnClient.cpp
r122 r136 37 37 38 38 VrpnClient::VrpnClient(string name, 39 string address, uint 16_t us_period, uint8_t priority)39 string address, uint8_t priority) 40 40 : Thread(getFrameworkManager(), name, priority) { 41 41 if (singleton != NULL) { … … 45 45 46 46 singleton = this; 47 pimpl_ = new VrpnClient_impl(this, name, address , us_period);47 pimpl_ = new VrpnClient_impl(this, name, address); 48 48 } 49 49 -
trunk/lib/FlairSensorActuator/src/VrpnClient.h
r122 r136 49 49 * \param name name 50 50 * \param address server address 51 * \param us_period Thread period in us52 51 * \param priority priority of the Thread 53 52 */ 54 53 VrpnClient(std::string name, 55 std::string address, uint16_t us_period,uint8_t priority);54 std::string address, uint8_t priority); 56 55 57 56 /*! -
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 } -
trunk/lib/FlairSensorActuator/src/unexported/VrpnClient_impl.h
r16 r136 47 47 public: 48 48 VrpnClient_impl(flair::sensor::VrpnClient *self, std::string name, 49 std::string address , uint16_t us_period);49 std::string address); 50 50 VrpnClient_impl(flair::sensor::VrpnClient *self, std::string name, 51 51 flair::core::SerialPort *serialport, uint16_t us_period); … … 77 77 flair::core::OneAxisRotation *rotation_1, *rotation_2; 78 78 flair::core::SerialPort *serialport; 79 bool isConnected;//only for ip connection, not for xbee 79 80 }; 80 81
Note:
See TracChangeset
for help on using the changeset viewer.