Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Simulator Class Reference

#include <Simulator.h>

Inheritance diagram for Simulator:

List of all members.


Detailed Description

Definition at line 19 of file Simulator.h.


Public Member Functions

 Simulator ()
 constructor
 ~Simulator ()
virtual void DoStart ()
virtual void DoStop ()
virtual void run ()
virtual void plistValueChanged (const plist::PrimitiveBase &pl)
virtual void plistCollectionEntryAdded (plist::Collection &col, plist::ObjectBase &primitive)
virtual void plistCollectionEntryRemoved (plist::Collection &col, plist::ObjectBase &primitive)
virtual void plistCollectionEntriesChanged (plist::Collection &col)
virtual void messagesRead (MessageQueueBase &mq, unsigned int n)

Static Public Member Functions

static const char * getClassName ()
static ProcessID::ProcessID_t getID ()
static const char * getCameraQueueID ()
static const char * getSensorQueueID ()
static const char * getTimerWakeupID ()
static const char * getMotionWakeupID ()
static const char * getStatusRequestID ()
static const char * getCommandQueueID ()
static void sendCommand (const std::string &cmd)
static void registerMotionHook (MotionHook &h)
 Registers the MotionHook to have its motionCheck() called following each motion update.
static void deregisterMotionHook (MotionHook &h)
 Removes the MotionHook from the list, no longer receives any notifications.
static void clearMotionHooks ()
static void setMotionStarting ()
static void setMotionStopping ()
static void updateMotion (const float outputs[][NumOutputs])
static void setMotionLeavingRealtime (bool isFullSpeed)
static void setMotionEnteringRealtime ()

Protected Types

enum  step_t {
  STEP_NONE, STEP_CAMERA, STEP_SENSOR, STEP_TIMER,
  STEP_MOTION
}
typedef MessageQueue< 10 > CommandQueue_t

Protected Member Functions

void incrementTime ()
void sendTimerWakeup ()
unsigned int getNextFrame ()
void resetSpeedMode ()
void processRunlevel (SharedGlobals::runlevel_t curRunLevel)
bool processCommand (const std::string &line, bool addToHistory)
 process an individual command
void cmdQuit (const std::vector< std::string > &args)
void cmdLoad (const std::vector< std::string > &args)
void cmdSave (const std::vector< std::string > &args)
void cmdRunlevel (const std::vector< std::string > &args)
bool cmdSet (const std::vector< std::string > &args)
void cmdRun (const std::vector< std::string > &args, bool isRelative)
void cmdRun (const std::vector< std::string > &args)
void cmdPause (const std::vector< std::string > &args)
void cmdHelp (const std::vector< std::string > &args)
void cmdStep (const std::vector< std::string > &args)
void cmdStatus (const std::vector< std::string > &args)
void cmdAdvance (const std::vector< std::string > &args)
void cmdFreeze (bool v, const std::vector< std::string > &args)
void cmdReset (const std::vector< std::string > &args)
void cmdNew (const std::vector< std::string > &args)
void cmdDelete (const std::vector< std::string > &args)

Static Protected Member Functions

static void replaceEntry (const std::string &name, plist::Dictionary &d, const std::string &comment)
static bool gotCommand (RCRegion *msg)
 for commands coming from other processes via commandQueue and commandrecv
static bool gotMotion (RCRegion *msg)
 when running in multi-process mode, receives output value updates from motion process

Protected Attributes

Simulator::FrameCounter frameCounter
Simulator::CommandThread cmdThread
SharedObject< sim::CameraQueue_tcameraQueue
SharedObject< sim::SensorQueue_tsensorQueue
SharedObject< sim::TimerWakeup_ttimerWakeup
SharedObject< sim::MotionWakeup_tmotionWakeup
SharedObject
< sim::StatusRequest_t
statusRequest
SharedObject< sim::EventQueue_tevents
SharedObject< sim::MotionOutput_tmotionout
SharedObject< CommandQueue_tcommandQueue
MessageQueueStatusThread cameraStatus
MessageQueueStatusThread sensorStatus
MessageQueueStatusThread timerStatus
MessageQueueStatusThread motionStatus
MessageQueueStatusThread eventsStatus
MessageReceivercommandrecv
MessageReceivermotionrecv
LoadDataThread vision
LoadDataThread sensors
std::set< unsigned int > frameTimes
float runSpeed
float lastTimeScale
step_t step
unsigned int waitingSteps
SharedGlobals::runlevel_t curLevel
TimeET fullspeedWallStart
 "real" wall-clock time that full-speed mode was entered
unsigned int fullspeedSimStart
 simulator time at which full-speed mode was entered
TimeET lastFrameWallStart
 "real" wall-clock time that processing started on last frame (only valid in full-speed mode)
float avgWallTime
 running average of frame processing time
float avgSimTime
 running average of frame increments
ThreadNS::Lock simLock

Static Protected Attributes

static SimulatortheSim = NULL
static std::set< MotionHook * > motionHooks
static const float avgSpeedupGamma = .99
 gamma parameter for calculating running average in avgWallTime and avgSimTime

Private Member Functions

 Simulator (const Simulator &)
 don't call (copy constructor)
Simulatoroperator= (const Simulator &)
 don't call (assignment operator)

Classes

class  CommandThread
class  FrameCounter
 subscribed by Simulator to message queue's send; ensures that SharedGlobals::MotionSimConfig::frameNumber stays in sync with the message serial number More...

Member Typedef Documentation

typedef MessageQueue<10> CommandQueue_t [protected]

Definition at line 143 of file Simulator.h.


Member Enumeration Documentation

enum step_t [protected]

Enumerator:
STEP_NONE 
STEP_CAMERA 
STEP_SENSOR 
STEP_TIMER 
STEP_MOTION 

Definition at line 101 of file Simulator.h.


Constructor & Destructor Documentation

Simulator (  ) 

constructor

Definition at line 32 of file Simulator.cc.

~Simulator (  ) 

Definition at line 119 of file Simulator.cc.

Simulator ( const Simulator  )  [private]

don't call (copy constructor)


Member Function Documentation

void DoStart (  )  [virtual]

Reimplemented from Process.

Definition at line 129 of file Simulator.cc.

void DoStop (  )  [virtual]

Reimplemented from Process.

Definition at line 332 of file Simulator.cc.

void run (  )  [virtual]

Reimplemented from Process.

Definition at line 141 of file Simulator.cc.

Referenced by DoStart().

static const char* getClassName (  )  [inline, static]

Definition at line 30 of file Simulator.h.

static ProcessID::ProcessID_t getID (  )  [inline, static]

Definition at line 31 of file Simulator.h.

static const char* getCameraQueueID (  )  [inline, static]

Definition at line 33 of file Simulator.h.

static const char* getSensorQueueID (  )  [inline, static]

Definition at line 34 of file Simulator.h.

static const char* getTimerWakeupID (  )  [inline, static]

Definition at line 35 of file Simulator.h.

static const char* getMotionWakeupID (  )  [inline, static]

Definition at line 36 of file Simulator.h.

static const char* getStatusRequestID (  )  [inline, static]

Definition at line 37 of file Simulator.h.

static const char* getCommandQueueID (  )  [inline, static]

Definition at line 38 of file Simulator.h.

Referenced by sendCommand().

void plistValueChanged ( const plist::PrimitiveBase pl  )  [virtual]

Implements PrimitiveListener.

Definition at line 191 of file Simulator.cc.

void plistCollectionEntryAdded ( plist::Collection col,
plist::ObjectBase primitive 
) [virtual]

Reimplemented from CollectionListener.

Definition at line 207 of file Simulator.cc.

void plistCollectionEntryRemoved ( plist::Collection col,
plist::ObjectBase primitive 
) [virtual]

Reimplemented from CollectionListener.

Definition at line 227 of file Simulator.cc.

void plistCollectionEntriesChanged ( plist::Collection col  )  [virtual]

Reimplemented from CollectionListener.

Definition at line 239 of file Simulator.cc.

void messagesRead ( MessageQueueBase mq,
unsigned int  n 
) [virtual]

Implements MessageQueueStatusThread::StatusListener.

Definition at line 264 of file Simulator.cc.

void sendCommand ( const std::string &  cmd  )  [static]

Definition at line 293 of file Simulator.cc.

Referenced by SharedGlobals::get_time(), and sim::sim().

static void registerMotionHook ( MotionHook h  )  [inline, static]

Registers the MotionHook to have its motionCheck() called following each motion update.

Responsibility for memory (de)allocation is NOT assumed by registration.

Definition at line 51 of file Simulator.h.

Referenced by Motion::DoStart().

static void deregisterMotionHook ( MotionHook h  )  [inline, static]

Removes the MotionHook from the list, no longer receives any notifications.

Responsibility for memory (de)allocation is NOT assumed by registration, so this doesn't affect h directly.

Definition at line 58 of file Simulator.h.

Referenced by Motion::DoStop().

static void clearMotionHooks (  )  [inline, static]

Definition at line 63 of file Simulator.h.

void setMotionStarting (  )  [static]

Definition at line 303 of file Simulator.cc.

Referenced by DoStart(), and Motion::DoStart().

void setMotionStopping (  )  [static]

Definition at line 309 of file Simulator.cc.

Referenced by DoStop(), and Motion::DoStop().

void updateMotion ( const float  outputs[][NumOutputs]  )  [static]

Definition at line 315 of file Simulator.cc.

Referenced by gotMotion(), and MotionExecThread::poll().

void setMotionLeavingRealtime ( bool  isFullSpeed  )  [static]

Definition at line 320 of file Simulator.cc.

Referenced by Motion::DoStop(), Motion::gotWakeup(), and resetSpeedMode().

void setMotionEnteringRealtime (  )  [static]

Definition at line 325 of file Simulator.cc.

Referenced by Motion::DoStart(), Motion::gotWakeup(), and resetSpeedMode().

void replaceEntry ( const std::string &  name,
plist::Dictionary d,
const std::string &  comment 
) [static, protected]

Definition at line 445 of file Simulator.cc.

Referenced by Simulator().

void incrementTime (  )  [protected]

Definition at line 456 of file Simulator.cc.

Referenced by messagesRead(), plistValueChanged(), and run().

void sendTimerWakeup (  )  [protected]

unsigned int getNextFrame (  )  [protected]

Definition at line 486 of file Simulator.cc.

Referenced by incrementTime().

void resetSpeedMode (  )  [protected]

Definition at line 397 of file Simulator.cc.

Referenced by plistValueChanged(), and run().

void processRunlevel ( SharedGlobals::runlevel_t  curRunLevel  )  [protected]

Definition at line 520 of file Simulator.cc.

Referenced by DoStart(), DoStop(), Simulator(), and ~Simulator().

bool processCommand ( const std::string &  line,
bool  addToHistory 
) [protected]

process an individual command

Definition at line 529 of file Simulator.cc.

Referenced by gotCommand(), Simulator::CommandThread::run(), and Simulator().

bool gotCommand ( RCRegion msg  )  [static, protected]

for commands coming from other processes via commandQueue and commandrecv

Definition at line 619 of file Simulator.cc.

Referenced by DoStart().

bool gotMotion ( RCRegion msg  )  [static, protected]

when running in multi-process mode, receives output value updates from motion process

Definition at line 626 of file Simulator.cc.

Referenced by run().

void cmdQuit ( const std::vector< std::string > &  args  )  [protected]

Definition at line 635 of file Simulator.cc.

Referenced by processCommand(), and Simulator::CommandThread::run().

void cmdLoad ( const std::vector< std::string > &  args  )  [protected]

Definition at line 640 of file Simulator.cc.

Referenced by processCommand().

void cmdSave ( const std::vector< std::string > &  args  )  [protected]

Definition at line 653 of file Simulator.cc.

Referenced by processCommand().

void cmdRunlevel ( const std::vector< std::string > &  args  )  [protected]

Definition at line 663 of file Simulator.cc.

Referenced by processCommand().

bool cmdSet ( const std::vector< std::string > &  args  )  [protected]

Definition at line 695 of file Simulator.cc.

Referenced by processCommand(), and Simulator().

void cmdRun ( const std::vector< std::string > &  args,
bool  isRelative 
) [protected]

Definition at line 738 of file Simulator.cc.

Referenced by processCommand().

void cmdRun ( const std::vector< std::string > &  args  )  [protected]

Definition at line 750 of file Simulator.cc.

void cmdPause ( const std::vector< std::string > &  args  )  [protected]

Definition at line 764 of file Simulator.cc.

Referenced by processCommand().

void cmdHelp ( const std::vector< std::string > &  args  )  [protected]

Definition at line 773 of file Simulator.cc.

Referenced by processCommand().

void cmdStep ( const std::vector< std::string > &  args  )  [protected]

Definition at line 891 of file Simulator.cc.

Referenced by processCommand().

void cmdStatus ( const std::vector< std::string > &  args  )  [protected]

Definition at line 932 of file Simulator.cc.

Referenced by processCommand().

void cmdAdvance ( const std::vector< std::string > &  args  )  [protected]

Definition at line 1002 of file Simulator.cc.

Referenced by processCommand().

void cmdFreeze ( bool  v,
const std::vector< std::string > &  args 
) [protected]

Definition at line 1060 of file Simulator.cc.

Referenced by processCommand().

void cmdReset ( const std::vector< std::string > &  args  )  [protected]

Definition at line 1092 of file Simulator.cc.

Referenced by processCommand().

void cmdNew ( const std::vector< std::string > &  args  )  [protected]

Definition at line 1111 of file Simulator.cc.

Referenced by processCommand().

void cmdDelete ( const std::vector< std::string > &  args  )  [protected]

Definition at line 1161 of file Simulator.cc.

Referenced by processCommand().

Simulator& operator= ( const Simulator  )  [private]

don't call (assignment operator)


Member Data Documentation

Referenced by Simulator().

Definition at line 136 of file Simulator.h.

Referenced by messagesRead(), resetSpeedMode(), and Simulator().

Definition at line 137 of file Simulator.h.

Referenced by messagesRead(), resetSpeedMode(), and Simulator().

Definition at line 140 of file Simulator.h.

Referenced by Simulator().

Definition at line 141 of file Simulator.h.

Referenced by DoStart(), and messagesRead().

Definition at line 142 of file Simulator.h.

Referenced by run().

Definition at line 144 of file Simulator.h.

Referenced by DoStart(), and Simulator().

Definition at line 146 of file Simulator.h.

Referenced by resetSpeedMode(), and run().

Definition at line 147 of file Simulator.h.

Referenced by resetSpeedMode(), and run().

Definition at line 148 of file Simulator.h.

Referenced by resetSpeedMode(), and run().

Definition at line 149 of file Simulator.h.

Referenced by resetSpeedMode(), and run().

Definition at line 150 of file Simulator.h.

Referenced by DoStart(), and resetSpeedMode().

Definition at line 152 of file Simulator.h.

Referenced by DoStart(), and DoStop().

Definition at line 153 of file Simulator.h.

Referenced by DoStop(), and run().

LoadDataThread vision [protected]

Definition at line 156 of file Simulator.h.

Referenced by DoStop(), getNextFrame(), incrementTime(), resetSpeedMode(), run(), and Simulator().

LoadDataThread sensors [protected]

Definition at line 157 of file Simulator.h.

Referenced by DoStop(), getNextFrame(), incrementTime(), resetSpeedMode(), run(), and Simulator().

std::set<unsigned int> frameTimes [protected]

Definition at line 159 of file Simulator.h.

Referenced by getNextFrame(), and incrementTime().

float runSpeed [protected]

Definition at line 160 of file Simulator.h.

Referenced by run().

float lastTimeScale [protected]

Definition at line 161 of file Simulator.h.

Referenced by resetSpeedMode().

step_t step [protected]

Definition at line 162 of file Simulator.h.

Referenced by incrementTime().

unsigned int waitingSteps [protected]

Definition at line 163 of file Simulator.h.

Referenced by incrementTime(), and messagesRead().

"real" wall-clock time that full-speed mode was entered

Definition at line 168 of file Simulator.h.

Referenced by resetSpeedMode().

unsigned int fullspeedSimStart [protected]

simulator time at which full-speed mode was entered

Definition at line 169 of file Simulator.h.

Referenced by resetSpeedMode().

"real" wall-clock time that processing started on last frame (only valid in full-speed mode)

Definition at line 170 of file Simulator.h.

Referenced by incrementTime(), and resetSpeedMode().

float avgWallTime [protected]

running average of frame processing time

Definition at line 171 of file Simulator.h.

Referenced by incrementTime(), and resetSpeedMode().

float avgSimTime [protected]

running average of frame increments

Definition at line 172 of file Simulator.h.

Referenced by incrementTime(), and resetSpeedMode().

const float avgSpeedupGamma = .99 [static, protected]

gamma parameter for calculating running average in avgWallTime and avgSimTime

Definition at line 173 of file Simulator.h.

Referenced by incrementTime().


The documentation for this class was generated from the following files:

Tekkotsu Hardware Abstraction Layer 4.0
Generated Thu Nov 22 01:01:24 2007 by Doxygen 1.5.4