Trees | Indices | Help |
---|
|
StickFilter Plans are event processors designed to simplify the problem of processing joystick and midi readings into continuous-time values. The problem arises because pygame joystick events appear only when joystick values change -- even if they are far from 'zero'. This means that triggering actions directly from joystick events can lead to rather erratic responses. StickFilter solves this problem by simulating the behavior of a regularly sampled time-series for each incoming event type. All these time series have the same sample interval (self.dt), but a different linear transfer function can be associated with the values in each channel. In particular, StickFilter provides methods to lowpass filter joystick readings or to integrate them. The former is used to limit the "jerkiness" of controller requests, whereas the latter is used to control velocity with the joystick instead of position. Channel Names ------------- Currently, StickFilter supports the channel name schemata listed below. Any given channel will only be instantiated if a filter is set for it and the related events are .push()-ed into the StickFilter plan. The schemata: joy<joystick-number>ball<ball-number> joy<joystick-number>hat<hat-number> joy<joystick-number>axis<axis-number>, e.g. joy0axis1, for joystick events Nx<node-id-2-HEX-digits>, e.g. Nx3C, for CKBOTPOSITION events midi<dev-number>sc<scene><kind><index-number> MIDI input device
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from Inherited from |
|
|||
|
|
|||
Inherited from |
|
Initialize a StickFilter
|
Process evt events with a first-order lowpass with time constant tau. Uses an approximation to the Butterworth construction |
Process evt events with a (leaky) integrator first-order lowpass with time constant tau. By default, integrator is not leaky. |
Specify a filter for an event channel. The filter equation is given by: A[0]*y[n] = B[0]*x[n] + B[1]*B[n-1] + ... + B[nb]*x[n-nb] - A[1]*y[n-1] - ... - A[na]*y[n-na] or, in terms of transfer functions: nb B[0] + B[1] z + ... + B[nb] z Y = ------------------------------------ X na A[0] + A[1] z + ... + A[na] z INPUTS: evt -- event object from channel, or its name as string t0 -- float -- initial time to start channel, or None to use self.app.now A,B -- sequences of floats -- transfer function x0 -- sequence of len(B) floats -- initial state of x values (default 0-s) y0 -- sequence of len(A) floats -- initial state of y values (default 0-s) lower -- number -- lower limit on filter values (saturation value) upper -- number -- upper limit on filter values (saturation value) func -- callable -- input mapping applied to channel values before filtering |
Feed an event into the StickFilter. Retrieves value and puts it on input queue for filter INPUT: evt -- EventType object |
Set a specific filter to zero Sets all previous state variables (X, Y) to zero INPUT: evt -- EventType object or string name of event channel |
(private) run filter off input in its queue until time t INPUT: flt -- a filter state t -- float -- time |
(final) Handle incoming events. Timer events allow the filters to update state; other events are pushed into the filters with .feed() and do not require the behavior() to run (hence return False).
|
(final) Runs periodically every dt time units. Evolves states of all filters up to the current time.
|
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Jan 4 16:46:17 2018 | http://epydoc.sourceforge.net |