Package joy :: Module plans :: Class FunctionCyclePlan
[hide private]
[frames] | no frames]

Class FunctionCyclePlan

source code


Concrete class FunctionCyclePlan implements a plan that cycles
'phase' at an adjustable frequency through the interval [0..1],
calling a user specified function every time the phase crosses 
a knot point.

Additional features:
(1) An upper limit on allowed frequency
(2) Knots points may be specified at construction or equally spaced
(3) Function calls may be decimated so that a minimal time interval 
    elapses between calls.
    
Typical usage is to write a function mapping phase to some kinematic
state of a robot gait. In that case, one typically sets knots to 
be either uniform, or preferentially represent the high-curvature
parts of the gait data. The interval limit is set to a realistic 
closed loop delay value, ensuring that commands to the motors are
not sent faster than they can be processed.

Instance Methods [hide private]
 
__init__(self, app, atPhiFun, N=None, knots=None, maxFreq=10.0, interval=0, *arg, **kw)
INPUTS: app -- JoyApp -- owner atPhiFun -- callable -- function that will be called with a phase in the range [0..1].
source code
 
_action(self, arg) source code

Inherited from CyclePlan: behavior, getFrequency, getPeriod, moveToPhase, onCycles, resetPhase, setFrequency, setPeriod

Inherited from CyclePlan (private): _doActions

Inherited from Plan: forDuration, isRunning, onEvent, onStart, onStop, push, start, step, stop, untilTime

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]

Inherited from CyclePlan: bsearch

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, app, atPhiFun, N=None, knots=None, maxFreq=10.0, interval=0, *arg, **kw)
(Constructor)

source code 
INPUTS:
  app -- JoyApp -- owner
  atPhiFun -- callable -- function that will be called with a 
        phase in the range [0..1].
  N -- integer (optional) -- number of knot points, for regularly
        spaced knot points.
  knots -- sequence -- sorted sequence of values in the range 
        [0..1], designating phases at which atPhiFun is called
  maxFreq -- float -- maximal frequency for cycling (Hz)
  interval -- float -- minimal time elapsed between calls    

Overrides: object.__init__