// Sample data.
bool MotionStar::sample()
{
   bool retval;
   std::vector< gadget::PositionData > cur_samples(mMotionStar.getNumSensors());

   retval = false;

   if ( isActive() == false )
   {
      vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
         << clrSetNORM(clrRED) << "MotionStar ("
         << getAddressName() << ") NOT ACTIVE IN SAMPLE\n"
         << clrRESET << vprDEBUG_FLUSH;
   }
   else
   {
      try
      {
         mMotionStar.sample();

         // get an initial timestamp for this entire sample. we'll copy it into
         // each PositionData for this sample.
         if ( ! cur_samples.empty() )
         {
            cur_samples[0].setTime();

            // For each bird
            for ( unsigned int i = 0; i < mMotionStar.getNumSensors(); ++i )
            {
               // Get the index to the current read buffer
               cur_samples[i].setTime( cur_samples[0].getTime() );
               cur_samples[i].mPosData = mMotionStar.getDeviceData(i);
            }
         }

         // Add the current data as a sample
         addPositionSample(cur_samples);

         retval = true;
      }
      catch (...)
      {
         vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << clrOutNORM(clrRED, "gadget::MotionStar::sample() caught unknown exception")
            << std::endl << vprDEBUG_FLUSH;
         retval = false;
      }
   }

   return retval;
}
Beispiel #2
0
bool Flock::sample()
{
    std::vector<gadget::PositionData> cur_samples(mFlockOfBirds.getNumSensors());

    if ( !isActive() )
    {
        return false;
    }

    mFlockOfBirds.sample();

    // get an initial timestamp for this entire sample. we'll copy it into
    // each PositionData for this sample.
    if (!cur_samples.empty())
    {
        cur_samples[0].setTime();
    }

    vpr::Thread::yield();

    // For each bird
    for (unsigned i=0; i < mFlockOfBirds.getNumSensors(); ++i)
    {
        // Transforms between the cord frames
        gmtl::Matrix44f transmitter_T_reciever = mFlockOfBirds.getSensorPosition(i);

        // Set timestamp & Store the corrected xform back into buffer.
        cur_samples[i].mPosData = transmitter_T_reciever;
        cur_samples[i].setTime (cur_samples[0].getTime());
    }

    // Add data sample
    addPositionSample(cur_samples);

    return true;
}