A base class to implement saccade controllers. More...
#include <Neuro/SaccadeController.H>
Public Member Functions | |
SaccadeController (OptionManager &mgr, const std::string &descrName, const std::string &tagName, const SaccadeBodyPart bodypart, const int percept_qlen, const int decision_qlen) | |
Constructor. | |
virtual | ~SaccadeController () |
Destructor (virtual to ensure that derived classes correctly destroyed). | |
void | evolve (SimEventQueue &q) |
evolve one time step (called, e.g., by Brain::evolve()) | |
virtual void | setPercept (const WTAwinner &fix, SimEventQueue &q) |
Receive a new percept (e.g., winner from saliency map). | |
virtual void | resetPos (const Point2D< int > &p, SimEventQueue &q) |
Reset to an externally-given position. | |
virtual Point2D< int > | getDecision (SimEventQueue &q, const bool dopoststatus=false) |
Get the fixation decided by the controller. | |
WTAwinner | getPreviousPercept (const unsigned int index=0) const |
Get a previous percept. | |
bool | havePercepts () const |
Do we already have any percepts queued up? | |
int | getPqlen () const |
Returns length of percept queue. | |
void | resetPqlen (const int len) |
Reset length of percept queue (contents will be lost). | |
void | killPercepts () |
Kill all previous percepts (empty the percept queue). | |
Point2DT | getPreviousDecision (const unsigned int index=0) const |
Get a previous decision. | |
bool | haveDecisions () const |
Do we already have any decisions queued up? | |
int | getDqlen () const |
Returns length of decision queue. | |
void | resetDqlen (const int len) |
Reset length of decision queue (contents will be lost). | |
void | killDecisions () |
Kill all previous decisions (empty the decision queue). | |
SaccadeBodyPart | bodyPart () const |
get our body part | |
void | dumpQueues () const |
Show contents of the queues, for debugging. | |
Protected Member Functions | |
virtual void | reset1 () |
Reset SaccadeController. | |
virtual void | doEvolve (SimEventQueue &q)=0 |
Called from within evolve(). | |
virtual void | computeWhenNewPercept (SimEventQueue &q)=0 |
This method is called each time a new percept has arrived. | |
virtual void | computeWhenResetPos (SimEventQueue &q)=0 |
This method is called each time a reset() occurs. | |
virtual Point2D< int > | computeWhenNewDecision (SaccadeState &sacstate, bool &blinkstate, SimEventQueue &q)=0 |
This method is called each time a new decision is requested. | |
SaccadeState | getState () const |
Helper for derived classes to get our internal saccade/fix/smooth state. | |
bool | getBlinkState () const |
Helper for derived classes to get our internal blink state. | |
Protected Attributes | |
OModelParam< Point2D< int > > | itsInitialPosition |
start position |
A base class to implement saccade controllers.
This base class handles the basic queuing of percepts and fixations. Typically, new percepts (e.g., winner-take-all winners over the saliency map) should be passed to the saccade controller using setPercept(). During normal evolution of a simulation, evolve() should be called at every time step, in a manner similar to that of Brain, WTA and SM. In order to obtain coordinates of saccade targets computed by this class, getDecision() should be called. It will return (-1, -1) if no new saccade target is decided (either because it cannot be decided, or because it is the same as the last valid returned one). So, saccading to and fixating a new target will yield one initial valid set of returned coordinates, followed by subsequent returns of (-1, -1) as long as fixation is to be held stationary. Derived classes should overload computeWhenNewPercept(), called each time a new percept has arrived, and computeWhenNewDecision(), called each time a new decision is requested. In addition, derived classes should usually overload doEvolve(), typically called at each time step during a simulation. See SaccadeControllers.H for examples of derived classes which actually implement saccadic control strategies.
Definition at line 72 of file SaccadeController.H.
SaccadeController::SaccadeController | ( | OptionManager & | mgr, | |
const std::string & | descrName, | |||
const std::string & | tagName, | |||
const SaccadeBodyPart | bodypart, | |||
const int | percept_qlen, | |||
const int | decision_qlen | |||
) |
Constructor.
bodypart | should be SaccadeBodyPartEye or SaccadeBodyPartHead | |
percept_qlen | length of the queue of accumulated percepts | |
decision_qlen | length of the queue of generated decisions |
Definition at line 47 of file SaccadeController.C.
SaccadeController::~SaccadeController | ( | ) | [virtual] |
Destructor (virtual to ensure that derived classes correctly destroyed).
Definition at line 69 of file SaccadeController.C.
SaccadeBodyPart SaccadeController::bodyPart | ( | ) | const |
get our body part
Definition at line 276 of file SaccadeController.C.
virtual Point2D<int> SaccadeController::computeWhenNewDecision | ( | SaccadeState & | sacstate, | |
bool & | blinkstate, | |||
SimEventQueue & | q | |||
) | [protected, pure virtual] |
This method is called each time a new decision is requested.
The latest percept is at the front of the percept queue, and the latest previous decision at the front of the decision queue. The method should return the decision to be taken given the time passed as argument. This method should return the current decision for fixation, as well as current saccade and blink states. The wrapping getDecision() call will take care of eliminating decisions that are the same as the previous ones. Derived classes must provide some implementation for this method, as it is called from within getDecision().
Implemented in StubSaccadeController, TrivialSaccadeController, FixedSaccadeController, FrictionSaccadeController, ThresholdSaccadeController, ThresholdFrictionSaccadeController, and MonkeySaccadeController.
Referenced by getDecision().
virtual void SaccadeController::computeWhenNewPercept | ( | SimEventQueue & | q | ) | [protected, pure virtual] |
This method is called each time a new percept has arrived.
The latest percept is at the front of the percept queue. Derived classes must provide some implementation for this method, as it is called from within setPercept().
Implemented in StubSaccadeController, TrivialSaccadeController, FixedSaccadeController, FrictionSaccadeController, ThresholdSaccadeController, ThresholdFrictionSaccadeController, and MonkeySaccadeController.
Referenced by setPercept().
virtual void SaccadeController::computeWhenResetPos | ( | SimEventQueue & | q | ) | [protected, pure virtual] |
This method is called each time a reset() occurs.
The reset location/time is at the front of the percept queue. Derived classes must provide some implementation for this method, as it is called from within resetPos(). NOTE: a resetPos(), even if it is to a location far away from the current one, should not create a saccade, because it is a way to break a simulation and reset it, not a way to drive saccades externally. Saccades should arise internally in computeWhenNewDecision(). You should not change the state here as resetPos() itself will change if to fixation or unknown anyway.
Implemented in StubSaccadeController, TrivialSaccadeController, FixedSaccadeController, FrictionSaccadeController, ThresholdSaccadeController, ThresholdFrictionSaccadeController, and MonkeySaccadeController.
Referenced by resetPos().
virtual void SaccadeController::doEvolve | ( | SimEventQueue & | q | ) | [protected, pure virtual] |
Called from within evolve().
Classes deriving from SaccadeController should implement this.
Implemented in StubSaccadeController, TrivialSaccadeController, FixedSaccadeController, FrictionSaccadeController, ThresholdSaccadeController, ThresholdFrictionSaccadeController, and MonkeySaccadeController.
Referenced by evolve().
void SaccadeController::dumpQueues | ( | ) | const |
Show contents of the queues, for debugging.
Definition at line 211 of file SaccadeController.C.
References Point2D< T >::i, SimTime::msecs(), Point2DT::p, WTAwinner::p, sformat(), WTAwinner::sv, Point2DT::t, and WTAwinner::t.
void SaccadeController::evolve | ( | SimEventQueue & | q | ) |
evolve one time step (called, e.g., by Brain::evolve())
evolve() should be invoked by external callers to allow the internals of the controller to evolve as time passes by but no new percept is available. Derived classes should not override this function, but should instead override doEvolve(), which is called from inside evolve().
Definition at line 280 of file SaccadeController.C.
References doEvolve().
bool SaccadeController::getBlinkState | ( | ) | const [protected] |
Helper for derived classes to get our internal blink state.
Definition at line 295 of file SaccadeController.C.
Point2D< int > SaccadeController::getDecision | ( | SimEventQueue & | q, | |
const bool | dopoststatus = false | |||
) | [virtual] |
Get the fixation decided by the controller.
t | should be the current time (in seconds) and should be greater than or equal to the time of the last percept passed to setPercept(). The coordinates of the decided fixation are returned (or (-1, -1) of no decision has been made). If a decision is made but is the same as the previous one, the behavior here is to return (-1, -1), and the caller has the responsibility of holding fixation until a new, valid decision can be reached. Do not overload this method, overload computeWhenNewDecision() instead if you need to do some computation before returning a fixation. If dopoststatus is true, we will post a SimEventStatus[Eye|Head] with our current status to the SimEventQueue. |
Definition at line 125 of file SaccadeController.C.
References SimEventQueue::check(), computeWhenNewDecision(), getPreviousDecision(), OModelParam< T >::getVal(), Point2D< T >::i, Point2D< T >::isValid(), itsInitialPosition, SimTime::msecs(), SimEventQueue::now(), SimEventQueue::post(), resetPos(), saccadeBodyPartName(), saccadeStateName(), SEQ_ANY, and SimTime::ZERO().
int SaccadeController::getDqlen | ( | ) | const |
Returns length of decision queue.
Note that the queue may not be full to that length yet
Definition at line 264 of file SaccadeController.C.
int SaccadeController::getPqlen | ( | ) | const |
Returns length of percept queue.
Note that the queue may not be full to that length yet
Definition at line 240 of file SaccadeController.C.
Point2DT SaccadeController::getPreviousDecision | ( | const unsigned int | index = 0 |
) | const |
Get a previous decision.
This method allows one to access a previous valid decision. It will not attempt to determine whether a new decision can be made now, like getDecision() does. It will simply return the result of what was previously decided (or (-1, -1) if no valid previous decision exists).
index | indicates which previous decision; a value of zero will return the last decision that was made and returned by getDecision(), and increasing values will return increasingly older decisions. if index is more than the queue length, (-1, -1) will be returned. |
Definition at line 252 of file SaccadeController.C.
References SimTime::ZERO().
Referenced by ThresholdFrictionSaccadeController::computeWhenNewDecision(), MonkeySaccadeController::computeWhenNewDecision(), ThresholdSaccadeController::computeWhenNewDecision(), TrivialSaccadeController::computeWhenNewDecision(), and getDecision().
WTAwinner SaccadeController::getPreviousPercept | ( | const unsigned int | index = 0 |
) | const |
Get a previous percept.
This method allows one to access a previous percept passed through setPercept(), or (-1, -1) if no valid previous percept exists.
index | indicates which previous percept; a value of zero will return the last percept that was passed to setPercept(), and increasing values will return increasingly older percepts. If index is more than the queue length, (-1, -1) will be returned. |
Definition at line 228 of file SaccadeController.C.
Referenced by ThresholdSaccadeController::checkPercepts(), TrivialSaccadeController::computeWhenNewDecision(), MonkeySaccadeController::computeWhenNewPercept(), FrictionSaccadeController::computeWhenNewPercept(), ThresholdFrictionSaccadeController::computeWhenNewPercept(), FrictionSaccadeController::computeWhenResetPos(), MonkeySaccadeController::computeWhenResetPos(), ThresholdFrictionSaccadeController::computeWhenResetPos(), FixedSaccadeController::computeWhenResetPos(), ThresholdSaccadeController::computeWhenResetPos(), and FrictionSaccadeController::doEvolve().
SaccadeState SaccadeController::getState | ( | ) | const [protected] |
Helper for derived classes to get our internal saccade/fix/smooth state.
Definition at line 291 of file SaccadeController.C.
bool SaccadeController::haveDecisions | ( | ) | const |
Do we already have any decisions queued up?
Definition at line 260 of file SaccadeController.C.
Referenced by ThresholdFrictionSaccadeController::computeWhenNewDecision(), and ThresholdSaccadeController::computeWhenNewDecision().
bool SaccadeController::havePercepts | ( | ) | const |
Do we already have any percepts queued up?
Definition at line 236 of file SaccadeController.C.
Referenced by FrictionSaccadeController::computeWhenNewDecision(), ThresholdSaccadeController::computeWhenNewDecision(), and FrictionSaccadeController::doEvolve().
void SaccadeController::killDecisions | ( | ) |
Kill all previous decisions (empty the decision queue).
Definition at line 272 of file SaccadeController.C.
void SaccadeController::killPercepts | ( | ) |
Kill all previous percepts (empty the percept queue).
Definition at line 248 of file SaccadeController.C.
void SaccadeController::reset1 | ( | ) | [protected, virtual] |
Reset SaccadeController.
Reimplemented from ModelComponent.
Reimplemented in ThresholdSaccadeController.
Definition at line 73 of file SaccadeController.C.
References SACSTATE_UNK.
void SaccadeController::resetDqlen | ( | const int | len | ) |
Reset length of decision queue (contents will be lost).
Definition at line 268 of file SaccadeController.C.
void SaccadeController::resetPos | ( | const Point2D< int > & | p, | |
SimEventQueue & | q | |||
) | [virtual] |
Reset to an externally-given position.
This will force the current position to the position given as argument, disregarding any internal physical model. So this may be used to externally drive the SaccadeController to given locations. A percept will be queued up, which will be built from the passed position/time plus default values for the WTAwinner fields. Do not overload this method, overload computeWhenReset() instead. NOTE: this will abort any current blink and will reset our internal state to fixation (if p is valid) or unknown (if p is invalid).
Definition at line 98 of file SaccadeController.C.
References computeWhenResetPos(), Point2D< T >::i, Point2D< T >::isValid(), SimTime::msecs(), SimEventQueue::now(), saccadeStateName(), SACSTATE_FIX, and SACSTATE_UNK.
Referenced by getDecision().
void SaccadeController::resetPqlen | ( | const int | len | ) |
Reset length of percept queue (contents will be lost).
Definition at line 244 of file SaccadeController.C.
Referenced by ThresholdSaccadeController::start1().
void SaccadeController::setPercept | ( | const WTAwinner & | fix, | |
SimEventQueue & | q | |||
) | [virtual] |
Receive a new percept (e.g., winner from saliency map).
This method should be invoked by external callers each time a new percept is available. Do not overload this method, overload computeWhenNewPercept() instead if you need to perform some computation for each new percept.
Definition at line 85 of file SaccadeController.C.
References computeWhenNewPercept().
OModelParam<Point2D<int> > SaccadeController::itsInitialPosition [protected] |