コード例 #1
0
long long int getDataOffset(hokuyo::Laser &laser, int cycles)
{
  int ckreps = 1;
  int scanreps = 1;
  long long int pre = getClockOffset(laser, ckreps);
  std::vector<long long int> samples(cycles);
  for (int i = 0; i < cycles; i++)
  {                                                 
    long long int scan = getScanOffset(laser, ckreps);
    long long int post = getClockOffset(laser, scanreps);
    samples[i] = scan - (post+pre)/2;
//    printf("%lli %lli %lli %lli\n", samples[i], post, pre, scan);
//    fflush(stdout);
    pre = post;
  }

  printf("%lli\n", median(samples));
  return median(samples);
}
コード例 #2
0
void Opponent::updateOpponentPositionFromNetworkUpdate(OpponentUpdate* update) {
    
    // Calculate the estimated temporal delay between this opponent and our own internal game clock (used in our interpolation calculations)
    float temporalDelay = GameClock::getInstance()->getClock() - update->getTimeStamp() + getClockOffset();
    b2Vec2 networkUpdateVelocity = b2Vec2(update->getLinearVelocityX(), update->getLinearVelocityY());
    b2Vec2 worldPosition = b2Vec2(update->getWorldPositionX(), update->getWorldPositionY());
    _interpolator->updateSpritePositionFromNetworkUpdate(temporalDelay, worldPosition, networkUpdateVelocity, update->getIsStuck());
}