jAER project on SourceForge

ch.unizh.ini.jaer.projects.tobi.goalie
Class Goalie

java.lang.Object
  extended by net.sf.jaer.eventprocessing.EventFilter
      extended by net.sf.jaer.eventprocessing.EventFilter2D
          extended by ch.unizh.ini.jaer.projects.tobi.goalie.Goalie
All Implemented Interfaces:
java.util.Observer, FrameAnnotater
Direct Known Subclasses:
LaserGoalie

public class Goalie
extends EventFilter2D
implements FrameAnnotater, java.util.Observer

Controls a servo motor that swings an arm in the way of a ball rolling towards a goal box. Calibrates itself as well.

Author:
tGoalielbruck/manuel lang

Nested Class Summary
protected  class Goalie.GoalieState
           
static class Goalie.State
          possible states, ACTIVE meaning blocking ball we can see, RELAXED is between blocks.
 
Field Summary
protected  RectangularClusterTracker.Cluster ball
           
protected  ServoArm servoArm
           
 
Fields inherited from class net.sf.jaer.eventprocessing.EventFilter2D
enclosedFilter, out
 
Fields inherited from class net.sf.jaer.eventprocessing.EventFilter
annotationEnabled, chip, enclosedFilterChain, filterEnabled, log, perf, propertyTooltipMap, support
 
Constructor Summary
Goalie(AEChip chip)
          Creates a Goaliestance of Goalie
 
Method Summary
 void annotate(float[][][] frame)
          not used
 void annotate(javax.media.opengl.GLAutoDrawable drawable)
          Each annotator enters annotate with graphics context current, in coordinates with pixel 0,0 in LL corner (note opposite from Java2D) and pixel spacing 1 unit after the scaling transform (which is already active).
 void annotate(java.awt.Graphics2D g)
          not used
 void doLearn()
           
 void doRelax()
           
 void doResetLearning()
           
 EventPacket<?> filterPacket(EventPacket<?> in)
          Subclasses implement this method to define custom processing.
protected  void finalize()
           
 int getArmRows()
           
static java.lang.String getDescription()
           
 java.lang.Object getFilterState()
          should return the filter state in some useful form
 int getLearnDelayMS()
           
 int getMaxPlayingTimeBeforeRestSec()
           
 int getMaxYToUseVelocity()
           
 int getMinPathPointsToUseVelocity()
           
 int getPixelsToTipOfArm()
           
 int getRangeOutsideViewToBlockPixels()
           
 int getRelaxationDelayMs()
           
 int getRestIntervalSec()
           
 int getSleepDelaySec()
           
 java.lang.Enum getState()
           
 int getTopRowsToIgnore()
           
 RectangularClusterTracker getTracker()
          Returns the ball tracker
 float getWakeupBallDistance()
           
 XYTypeFilter getXYFilter()
           
 void initFilter()
          initializes arm lowpass filter
 boolean isLogGoalieEnabled()
           
 boolean isUseSoonest()
           
 boolean isUseVelocityForGoalie()
           
 void resetFilter()
          should reset the filter to initial state
 void setArmRows(int armRows)
          Defines the number of retina rows from bottom of image to tip of goalie arm to define tracking region for arm.
 void setFilterEnabled(boolean yes)
          Resets the filter
 void setLearnDelayMS(int learnDelayMS)
           
 void setLogGoalieEnabled(boolean logGoalieEnabled)
           
 void setMaxPlayingTimeBeforeRestSec(int maxPlayingTimeBeforeRestSec)
           
 void setMaxYToUseVelocity(int maxYToUseVelocity)
           
 void setMinPathPointsToUseVelocity(int minPathPointsToUseVelocity)
           
 void setPixelsToTipOfArm(int pixelsToTipOfArm)
          Defines the distance in image rows to the tip of the goalie arm.
 void setRangeOutsideViewToBlockPixels(int rangeOutsideViewToBlockPixels)
           
 void setRelaxationDelayMs(int relaxationDelayMs)
          sets the delay after all targets disappear that the goalie relaxes
 void setRestIntervalSec(int restIntervalSec)
           
 void setSleepDelaySec(int sleepDelaySec)
           
 void setState(Goalie.State newState)
          Sets the state.
 void setTopRowsToIgnore(int topRowsToIgnore)
           
 void setUseSoonest(boolean useSoonest)
          If true, then goalie uses ball that will hit soonest.
 void setUseVelocityForGoalie(boolean useVelocityForGoalie)
          Sets whether the goalie uses the ball velocity or just the position
 void setWakeupBallDistance(float wakeupBallDistance)
           
 void setXYFilter(XYTypeFilter xYFilter)
           
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class net.sf.jaer.eventprocessing.EventFilter2D
checkOutputPacketEventType, checkOutputPacketEventType, getEnclosedFilter, resetOut, setEnclosedFilter
 
Methods inherited from class net.sf.jaer.eventprocessing.EventFilter
getChip, getEnclosedFilterChain, getEnclosingFilter, getPrefs, getPropertyChangeSupport, getPropertyTooltip, isAnnotationEnabled, isEnclosed, isFilterEnabled, prefsEnabledKey, setAnnotationEnabled, setChip, setEnclosed, setEnclosedFilter, setEnclosedFilterChain, setEnclosingFilter, setPreferredEnabledState, setPrefs, setPropertyTooltip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jaer.graphics.FrameAnnotater
isAnnotationEnabled, setAnnotationEnabled
 

Field Detail

servoArm

protected ServoArm servoArm

ball

protected volatile RectangularClusterTracker.Cluster ball
Constructor Detail

Goalie

public Goalie(AEChip chip)
Creates a Goaliestance of Goalie

Method Detail

getDescription

public static java.lang.String getDescription()

filterPacket

public EventPacket<?> filterPacket(EventPacket<?> in)
Description copied from class: EventFilter2D
Subclasses implement this method to define custom processing.

Specified by:
filterPacket in class EventFilter2D
Parameters:
in - the input packet
Returns:
the output packet

getFilterState

public java.lang.Object getFilterState()
Description copied from class: EventFilter
should return the filter state in some useful form

Specified by:
getFilterState in class EventFilter

resetFilter

public void resetFilter()
Description copied from class: EventFilter
should reset the filter to initial state

Specified by:
resetFilter in class EventFilter

initFilter

public void initFilter()
initializes arm lowpass filter

Specified by:
initFilter in class EventFilter

setFilterEnabled

public void setFilterEnabled(boolean yes)
Description copied from class: EventFilter2D
Resets the filter

Overrides:
setFilterEnabled in class EventFilter2D
Parameters:
yes - true to reset
See Also:
EventFilter.setPreferredEnabledState()

annotate

public void annotate(float[][][] frame)
not used

Specified by:
annotate in interface FrameAnnotater
Parameters:
frame - the RGB pixel information. First dimension is Y, second is X, third is RGB

annotate

public void annotate(java.awt.Graphics2D g)
not used

Specified by:
annotate in interface FrameAnnotater
Parameters:
g - the Graphics2D context

annotate

public void annotate(javax.media.opengl.GLAutoDrawable drawable)
Description copied from interface: FrameAnnotater
Each annotator enters annotate with graphics context current, in coordinates with pixel 0,0 in LL corner (note opposite from Java2D) and pixel spacing 1 unit after the scaling transform (which is already active). The FrameAnnotater then can use JOGL calls to render to the screen by getting the GL context, e.g. the following code, used in the context of an AEChip object, draws a golden lines from LL to UR of the pixel array.
        GL gl = drawable.getGL();
        gl.glBegin(GL.GL_LINES);
        gl.glColor3f(.5f, .5f, 0);
        gl.glVertex2f(0, 0);
        gl.glVertex2f(getSizeX() - 1, getSizeY() - 1);
        gl.glEnd();
 

Specified by:
annotate in interface FrameAnnotater
Parameters:
drawable - the OpenGL drawable components, e.g., GLCanvas

isUseVelocityForGoalie

public boolean isUseVelocityForGoalie()

setUseVelocityForGoalie

public void setUseVelocityForGoalie(boolean useVelocityForGoalie)
Sets whether the goalie uses the ball velocity or just the position

Parameters:
useVelocityForGoalie - true to use ball velocity

getRelaxationDelayMs

public int getRelaxationDelayMs()

setRelaxationDelayMs

public void setRelaxationDelayMs(int relaxationDelayMs)
sets the delay after all targets disappear that the goalie relaxes

Parameters:
relaxationDelayMs - delay in ms

isUseSoonest

public boolean isUseSoonest()

setUseSoonest

public void setUseSoonest(boolean useSoonest)
If true, then goalie uses ball that will hit soonest. If false, goalie uses ball that is closest to goal.

Parameters:
useSoonest - true to use soonest threat, false to use closest threat
See Also:
setUseVelocityForGoalie(boolean)

getTopRowsToIgnore

public int getTopRowsToIgnore()

setTopRowsToIgnore

public void setTopRowsToIgnore(int topRowsToIgnore)

getArmRows

public int getArmRows()

setArmRows

public void setArmRows(int armRows)
Defines the number of retina rows from bottom of image to tip of goalie arm to define tracking region for arm. If this is too small then the arm will be tracked as balls, greatly confusing things. Constrained to range 0-chip.getSizeY()/2.

Parameters:
armRows - the number of rows of pixels

getLearnDelayMS

public int getLearnDelayMS()
Returns:
the delay before learning starts

setLearnDelayMS

public void setLearnDelayMS(int learnDelayMS)

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

doResetLearning

public void doResetLearning()

doLearn

public void doLearn()

doRelax

public void doRelax()

getPixelsToTipOfArm

public int getPixelsToTipOfArm()

setPixelsToTipOfArm

public void setPixelsToTipOfArm(int pixelsToTipOfArm)
Defines the distance in image rows to the tip of the goalie arm. This number is slightly different than the armRows parameter because of perspective.

Parameters:
pixelsToTipOfArm - the number of image rows to the tip

getTracker

public RectangularClusterTracker getTracker()
Returns the ball tracker


getWakeupBallDistance

public float getWakeupBallDistance()

setWakeupBallDistance

public void setWakeupBallDistance(float wakeupBallDistance)

getSleepDelaySec

public int getSleepDelaySec()

setSleepDelaySec

public void setSleepDelaySec(int sleepDelaySec)

getXYFilter

public XYTypeFilter getXYFilter()

setXYFilter

public void setXYFilter(XYTypeFilter xYFilter)

getRangeOutsideViewToBlockPixels

public int getRangeOutsideViewToBlockPixels()

setRangeOutsideViewToBlockPixels

public void setRangeOutsideViewToBlockPixels(int rangeOutsideViewToBlockPixels)

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getMinPathPointsToUseVelocity

public int getMinPathPointsToUseVelocity()

setMinPathPointsToUseVelocity

public void setMinPathPointsToUseVelocity(int minPathPointsToUseVelocity)

getMaxYToUseVelocity

public int getMaxYToUseVelocity()

setMaxYToUseVelocity

public void setMaxYToUseVelocity(int maxYToUseVelocity)

getState

public java.lang.Enum getState()

setState

public void setState(Goalie.State newState)
Sets the state. On transition to ACTIVE the tracker is reset


isLogGoalieEnabled

public boolean isLogGoalieEnabled()

setLogGoalieEnabled

public void setLogGoalieEnabled(boolean logGoalieEnabled)

getMaxPlayingTimeBeforeRestSec

public int getMaxPlayingTimeBeforeRestSec()

setMaxPlayingTimeBeforeRestSec

public void setMaxPlayingTimeBeforeRestSec(int maxPlayingTimeBeforeRestSec)

getRestIntervalSec

public int getRestIntervalSec()

setRestIntervalSec

public void setRestIntervalSec(int restIntervalSec)

jAER project on SourceForge