Changeset 332 in flair-src for trunk/lib/FlairSensorActuator/src
- Timestamp:
- Oct 1, 2019, 5:12:28 PM (5 years ago)
- Location:
- trunk/lib/FlairSensorActuator/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp
r331 r332 89 89 90 90 VrpnClient_impl::~VrpnClient_impl() { 91 if (connectionType==VrpnClient::Vrpn ) {91 if (connectionType==VrpnClient::Vrpn|| connectionType==VrpnClient::VrpnLite) { 92 92 // on fait une copie car le delete touche a trackables_copy via 93 93 // RemoveTrackable … … 96 96 delete trackables_copy.at(i)->self; 97 97 // trackables.clear(); 98 } else if(connectionType==VrpnClient::Xbee || connectionType==VrpnClient::VrpnLite) {98 } else if(connectionType==VrpnClient::Xbee ) { 99 99 // on fait une copie car le delete touche a xbee_objects_copy via 100 100 // RemoveTrackable 101 vector< liteObject_t> liteObjects_copy = liteObjects;102 for (unsigned int i = 0; i < liteObjects_copy.size(); i++)103 delete liteObjects_copy.at(i).vrpnobject->self;101 vector<xbeeObject_t> xbeeObjects_copy = xbeeObjects; 102 for (unsigned int i = 0; i < xbeeObjects_copy.size(); i++) 103 delete xbeeObjects_copy.at(i).vrpnobject->self; 104 104 } 105 105 … … 128 128 mutex->ReleaseMutex(); 129 129 } else if (connectionType==VrpnClient::VrpnLite) { 130 if(liteObjects.size()<0xffff) { 131 liteObject_t tmp; 132 tmp.vrpnobject = obj; 133 uint16_t id=liteObjects.size(); 130 if(trackables.size()<0xffff) { 131 uint16_t id=trackables.size(); 134 132 mutex->GetMutex(); 135 liteObjects.push_back(tmp);133 trackables.push_back(obj); 136 134 mutex->ReleaseMutex(); 137 135 //Printf("%i %s\n",tmp.id,obj->self->ObjectName().c_str()); … … 151 149 152 150 void VrpnClient_impl::AddTrackable(VrpnObject_impl *obj, uint8_t id) { 153 if (connectionType==VrpnClient:: VrpnLite || connectionType==VrpnClient::Xbee) {154 liteObject_t tmp;151 if (connectionType==VrpnClient::Xbee) { 152 xbeeObject_t tmp; 155 153 tmp.vrpnobject = obj; 156 154 tmp.id = id; 157 155 mutex->GetMutex(); 158 liteObjects.push_back(tmp);156 xbeeObjects.push_back(tmp); 159 157 mutex->ReleaseMutex(); 160 158 } else { … … 165 163 void VrpnClient_impl::RemoveTrackable(VrpnObject_impl *obj) { 166 164 mutex->GetMutex(); 167 if (connectionType==VrpnClient::Vrpn ) {165 if (connectionType==VrpnClient::Vrpn || connectionType==VrpnClient::VrpnLite) { 168 166 for (vector<VrpnObject_impl *>::iterator it = trackables.begin();it < trackables.end(); it++) { 169 167 if (*it == obj) { … … 173 171 } 174 172 } 175 if ( connectionType==VrpnClient::VrpnLite ||connectionType==VrpnClient::Xbee) {176 for (vector< liteObject_t>::iterator it = liteObjects.begin();it < liteObjects.end(); it++) {173 if ( connectionType==VrpnClient::Xbee) { 174 for (vector<xbeeObject_t>::iterator it = xbeeObjects.begin();it < xbeeObjects.end(); it++) { 177 175 if ((*it).vrpnobject == obj) { 178 liteObjects.erase(it);176 xbeeObjects.erase(it); 179 177 break; 180 178 } … … 219 217 220 218 mutex->GetMutex(); 221 if (id < liteObjects.size()) {219 if (id < xbeeObjects.size()) { 222 220 memcpy(pos, &response[9], sizeof(pos)); 223 221 memcpy(quat, &response[9] + sizeof(pos), sizeof(quat)); … … 231 229 // self->Printf("%i %f %f %f 232 230 // %f\n",id,pos[0],pos[1],pos[2],(float)self->GetTime()/(1000*1000)); 233 VrpnObject_impl::handle_pos( liteObjects.at(id).vrpnobject, t);231 VrpnObject_impl::handle_pos(xbeeObjects.at(id).vrpnobject, t); 234 232 } 235 233 } … … 270 268 int16_t quat[4]; 271 269 Time time; 272 char datas[ liteObjects.size()*(sizeof(pos)+sizeof(quat))+ sizeof(time)];270 char datas[trackables.size()*(sizeof(pos)+sizeof(quat))+ sizeof(time)]; 273 271 char *datasPtr=datas; 274 272 … … 283 281 dataSocket->NetworkToHost((char*)(&time),sizeof(time)); 284 282 285 for (vector< liteObject_t>::iterator it = liteObjects.begin();it < liteObjects.end(); it++) {283 for (vector<VrpnObject_impl*>::iterator it = trackables.begin();it < trackables.end(); it++) { 286 284 memcpy(pos, datasPtr, sizeof(pos)); 287 285 datasPtr+=sizeof(pos); … … 303 301 t.msg_time.tv_usec=(time%((Time)1000000000))/((Time)1000); 304 302 //Printf("%i %lld %lld %lld\n",id,time,t.msg_time.tv_sec,t.msg_time.tv_usec); 305 VrpnObject_impl::handle_pos((void*)( it->vrpnobject), t);303 VrpnObject_impl::handle_pos((void*)(*it), t); 306 304 } 307 305 -
trunk/lib/FlairSensorActuator/src/unexported/VrpnClient_impl.h
r330 r332 72 72 uint16_t us_period; 73 73 std::vector<VrpnObject_impl *> trackables; 74 typedef struct liteObject_t {74 typedef struct xbeeObject_t { 75 75 VrpnObject_impl *vrpnobject; 76 76 uint8_t id; 77 } liteObject_t;77 } xbeeObject_t; 78 78 79 std::vector< liteObject_t> liteObjects;79 std::vector<xbeeObject_t> xbeeObjects; 80 80 flair::gui::Tab *main_tab; 81 81 flair::core::OneAxisRotation *rotation_1, *rotation_2;
Note:
See TracChangeset
for help on using the changeset viewer.