Changeset 332 in flair-src


Ignore:
Timestamp:
Oct 1, 2019, 5:12:28 PM (2 years ago)
Author:
Sanahuja Guillaume
Message:

modif vrpn lite

Location:
trunk/lib/FlairSensorActuator/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/VrpnClient_impl.cpp

    r331 r332  
    8989
    9090VrpnClient_impl::~VrpnClient_impl() {
    91   if (connectionType==VrpnClient::Vrpn) {
     91  if (connectionType==VrpnClient::Vrpn|| connectionType==VrpnClient::VrpnLite) {
    9292    // on fait une copie car le delete touche a trackables_copy via
    9393    // RemoveTrackable
     
    9696      delete trackables_copy.at(i)->self;
    9797    // trackables.clear();
    98   } else if(connectionType==VrpnClient::Xbee || connectionType==VrpnClient::VrpnLite) {
     98  } else if(connectionType==VrpnClient::Xbee ) {
    9999    // on fait une copie car le delete touche a xbee_objects_copy via
    100100    // 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;
    104104  }
    105105
     
    128128    mutex->ReleaseMutex();
    129129  } 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();
    134132      mutex->GetMutex();
    135       liteObjects.push_back(tmp);
     133      trackables.push_back(obj);
    136134      mutex->ReleaseMutex();
    137135      //Printf("%i %s\n",tmp.id,obj->self->ObjectName().c_str());
     
    151149
    152150void 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;
    155153    tmp.vrpnobject = obj;
    156154    tmp.id = id;
    157155    mutex->GetMutex();
    158     liteObjects.push_back(tmp);
     156    xbeeObjects.push_back(tmp);
    159157    mutex->ReleaseMutex();
    160158  } else {
     
    165163void VrpnClient_impl::RemoveTrackable(VrpnObject_impl *obj) {
    166164  mutex->GetMutex();
    167   if (connectionType==VrpnClient::Vrpn) {
     165  if (connectionType==VrpnClient::Vrpn || connectionType==VrpnClient::VrpnLite) {
    168166    for (vector<VrpnObject_impl *>::iterator it = trackables.begin();it < trackables.end(); it++) {
    169167      if (*it == obj) {
     
    173171    }
    174172  }
    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++) {
    177175      if ((*it).vrpnobject == obj) {
    178         liteObjects.erase(it);
     176        xbeeObjects.erase(it);
    179177        break;
    180178      }
     
    219217
    220218          mutex->GetMutex();
    221           if (id < liteObjects.size()) {
     219          if (id < xbeeObjects.size()) {
    222220            memcpy(pos, &response[9], sizeof(pos));
    223221            memcpy(quat, &response[9] + sizeof(pos), sizeof(quat));
     
    231229              // self->Printf("%i %f %f %f
    232230              // %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);
    234232            }
    235233          }
     
    270268      int16_t quat[4];
    271269      Time time;
    272       char datas[liteObjects.size()*(sizeof(pos)+sizeof(quat))+ sizeof(time)];
     270      char datas[trackables.size()*(sizeof(pos)+sizeof(quat))+ sizeof(time)];
    273271      char *datasPtr=datas;
    274272     
     
    283281      dataSocket->NetworkToHost((char*)(&time),sizeof(time));
    284282     
    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++) {
    286284        memcpy(pos, datasPtr, sizeof(pos));
    287285        datasPtr+=sizeof(pos);
     
    303301        t.msg_time.tv_usec=(time%((Time)1000000000))/((Time)1000);
    304302        //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);
    306304      }
    307305     
  • trunk/lib/FlairSensorActuator/src/unexported/VrpnClient_impl.h

    r330 r332  
    7272  uint16_t us_period;
    7373  std::vector<VrpnObject_impl *> trackables;
    74   typedef struct liteObject_t {
     74  typedef struct xbeeObject_t {
    7575    VrpnObject_impl *vrpnobject;
    7676    uint8_t id;
    77   } liteObject_t;
     77  } xbeeObject_t;
    7878
    79   std::vector<liteObject_t> liteObjects;
     79  std::vector<xbeeObject_t> xbeeObjects;
    8080  flair::gui::Tab *main_tab;
    8181  flair::core::OneAxisRotation *rotation_1, *rotation_2;
Note: See TracChangeset for help on using the changeset viewer.