orca-robotics INTRODUCTION Overview Download and Install Quick Start Documentation Publications REPOSITORY Interfaces Components Libraries Utilities Software Map DEVELOPER Tutorials Examples Dev Guide Dashboard Wiki login/pass: orca/orca PEOPLE Contributors Users Project Download Mailing lists
|
replayclock.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This copy of Orca is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef REPLAY_CLOCK_H 00012 #define REPLAY_CLOCK_H 00013 00014 #include <IceUtil/Time.h> 00015 00016 namespace logplayer 00017 { 00018 00019 // 00020 // ReplayClock is used to make sure the log gets played with the correct timing 00021 // (possibly not real-time). 00022 // 00023 // The timing could also be controlled by just looking at time deltas between items, 00024 // but that would drift. This provides some kind of absolute reference. 00025 // 00026 // We keep track of two things: 00027 // 1. real time since the start of continuous playback, and 00028 // 2. log time since the start of continuous playback. 00029 // 00030 class ReplayClock 00031 { 00032 public: 00033 // Throws an error string if replayRate is set to zero. 00034 ReplayClock( double replayRate=1.0 ); 00035 00036 void setReplayRate( double replayRate ); 00037 00038 // When we start continuous replay, use this call to tell the clock the 00039 // time (in log-space) of the first item. 00040 void setContinuousReplayStartTime( const IceUtil::Time &timeFirstLogItem ); 00041 00042 // Give it the time in log-land till the next item, it returns the 00043 // time we should wait in the real world. 00044 // Note: setContinuousReplayStartTime should have been called already. 00045 IceUtil::Time realTimeTillNextItem( const IceUtil::Time &logTimeTillNextItem ); 00046 00047 private: 00048 00049 double replayRate_; 00050 IceUtil::Time logStartTime_; 00051 IceUtil::Time replayStartTime_; 00052 }; 00053 00054 } // namespace 00055 00056 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)