Changeset 140 in flair-src for trunk/lib/FlairSensorActuator/src
- Timestamp:
- Feb 15, 2017, 2:41:36 PM (8 years ago)
- Location:
- trunk/lib/FlairSensorActuator/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp
r139 r140 82 82 VrpnClient_impl::~VrpnClient_impl() { 83 83 if (!UseXbee()) { 84 // on fait une copie car le delete touche a xbee_objects_copy via84 // on fait une copie car le delete touche a trackables_copy via 85 85 // RemoveTrackable 86 vector<VrpnObject *> trackables_copy = trackables;86 vector<VrpnObject_impl *> trackables_copy = trackables; 87 87 for (unsigned int i = 0; i < trackables_copy.size(); i++) 88 delete trackables_copy.at(i) ;88 delete trackables_copy.at(i)->self; 89 89 // trackables.clear(); 90 90 } else { … … 114 114 } 115 115 116 void VrpnClient_impl::AddTrackable(VrpnObject *obj) {116 void VrpnClient_impl::AddTrackable(VrpnObject_impl *obj) { 117 117 mutex->GetMutex(); 118 118 trackables.push_back(obj); … … 120 120 } 121 121 122 void VrpnClient_impl::RemoveTrackable(VrpnObject *obj) {122 void VrpnClient_impl::RemoveTrackable(VrpnObject_impl *obj) { 123 123 mutex->GetMutex(); 124 for (vector<VrpnObject *>::iterator it = trackables.begin();124 for (vector<VrpnObject_impl *>::iterator it = trackables.begin(); 125 125 it < trackables.end(); it++) { 126 126 if (*it == obj) { 127 127 trackables.erase(it); 128 break; 129 } 130 } 131 for (vector<xbee_object>::iterator it = xbee_objects.begin(); 132 it < xbee_objects.end(); it++) { 133 if ((*it).vrpnobject == obj) { 134 xbee_objects.erase(it); 128 135 break; 129 136 } … … 138 145 mutex->GetMutex(); 139 146 xbee_objects.push_back(tmp); 140 mutex->ReleaseMutex();141 }142 143 void VrpnClient_impl::RemoveTrackable(VrpnObject_impl *obj) {144 mutex->GetMutex();145 for (vector<xbee_object>::iterator it = xbee_objects.begin();146 it < xbee_objects.end(); it++) {147 if ((*it).vrpnobject == obj) {148 xbee_objects.erase(it);149 break;150 }151 }152 147 mutex->ReleaseMutex(); 153 148 } … … 232 227 mutex->GetMutex(); 233 228 for (unsigned int i = 0; i < trackables.size(); i++) 234 trackables.at(i)-> mainloop();229 trackables.at(i)->tracker->mainloop(); 235 230 mutex->ReleaseMutex(); 236 231 } else { -
trunk/lib/FlairSensorActuator/src/VrpnObject.cpp
r135 r140 45 45 } 46 46 47 VrpnObject::~VrpnObject(void) { delete pimpl_; } 47 VrpnObject::~VrpnObject(void) { 48 delete pimpl_; 49 } 48 50 49 51 cvmatrix *VrpnObject::Output(void) const { return pimpl_->output; } … … 75 77 } 76 78 77 void VrpnObject::mainloop(void) { pimpl_->mainloop(); }78 79 79 } // end namespace sensor 80 80 } // end namespace flair -
trunk/lib/FlairSensorActuator/src/VrpnObject.h
r135 r140 172 172 void UpdateFrom(const core::io_data *data){}; 173 173 174 void mainloop(void);175 174 class VrpnObject_impl *pimpl_; 176 175 }; -
trunk/lib/FlairSensorActuator/src/VrpnObject_impl.cpp
r139 r140 55 55 "identifiant pour la connexion Xbee ignore car pas en mode Xbee\n"); 56 56 } 57 57 58 58 // state 59 59 cvmatrix_descriptor *desc = new cvmatrix_descriptor(7, 1); … … 82 82 z_plot->AddCurve(output->Element(6)); 83 83 84 if(parent->IsRunning()) {85 self->Warn("adding VrpnObject on running VrpnClient can crash\n");86 }87 88 84 if (parent->UseXbee()) { 89 85 tracker = NULL; … … 93 89 tracker->register_change_handler(this, handle_pos); 94 90 tracker->shutup = true; 95 parent->pimpl_->AddTrackable( self);91 parent->pimpl_->AddTrackable(this); 96 92 } 93 97 94 } 98 95 99 96 VrpnObject_impl::~VrpnObject_impl(void) { 100 if (tracker != NULL) // normal 101 { 102 parent->pimpl_->RemoveTrackable(self); 97 parent->pimpl_->RemoveTrackable(this); 98 if (tracker != NULL) {// normal 103 99 tracker->unregister_change_handler(this, handle_pos); 104 100 delete tracker; 105 } else // xbee106 {107 parent->pimpl_->RemoveTrackable(this);108 101 } 109 102 delete plot_tab; 110 }111 112 void VrpnObject_impl::mainloop(void) {113 tracker->mainloop();114 103 } 115 104 -
trunk/lib/FlairSensorActuator/src/unexported/VrpnClient_impl.h
r136 r140 51 51 flair::core::SerialPort *serialport, uint16_t us_period); 52 52 ~VrpnClient_impl(); 53 void AddTrackable(flair::sensor::VrpnObject *obj); // normal 54 void RemoveTrackable(flair::sensor::VrpnObject *obj); // normal 53 void AddTrackable(VrpnObject_impl *obj); // normal 55 54 void AddTrackable(VrpnObject_impl *obj, uint8_t id); // xbee 56 void RemoveTrackable(VrpnObject_impl *obj); // xbee55 void RemoveTrackable(VrpnObject_impl *obj); // normal+xbee 57 56 void ComputeRotations(flair::core::Vector3D &point); 58 57 void ComputeRotations(flair::core::Quaternion &quat); … … 67 66 flair::core::Mutex *mutex; 68 67 uint16_t us_period; 69 std::vector< flair::sensor::VrpnObject*> trackables;68 std::vector<VrpnObject_impl *> trackables; 70 69 typedef struct xbee_object { 71 70 VrpnObject_impl *vrpnobject; -
trunk/lib/FlairSensorActuator/src/unexported/VrpnObject_impl.h
r135 r140 50 50 ~VrpnObject_impl(void); 51 51 52 void mainloop(void);53 52 void GetQuaternion(flair::core::Quaternion &quaternion); 54 53 void GetPosition(flair::core::Vector3D &point);
Note:
See TracChangeset
for help on using the changeset viewer.