jAER project on SourceForge

ch.unizh.ini.jaer.projects.rccar
Class Driver

java.lang.Object
  extended by net.sf.jaer.eventprocessing.EventFilter
      extended by net.sf.jaer.eventprocessing.EventFilter2D
          extended by ch.unizh.ini.jaer.projects.rccar.Driver
All Implemented Interfaces:
FrameAnnotater

public class Driver
extends EventFilter2D
implements FrameAnnotater

Drives the RC car using the output from an enclosed line detector filter. The enclosed filter chain is a MultiLineClusterTracker which itself encloses a chain of XYTypeFilter - BackgroundActivityFilter - OnOffProximityFilter - SimpleOrientationFilter.

Preference values for these enclosed filters are stored by keys based on the enclosing Driver filter.

Driver uses the detected line to control steering and speed to drive along the line. The line is parameritized by its normal form (rho, theta), where rho is the angle of the normal to the line from the center of the chip image and theta is the length of the normal vector (closest passge to the origin at the chip image center). The angle rho is 0 or 180 for a vertical line and is 90 or 270 for a horizontal line.

(rho,theta) control the steering

Fires PropertyChangeEvent for the following

Author:
tobi

Nested Class Summary
 class Driver.DriverPreFilter
          This filter chain is a common preprocessor for Driver line detectors
 
Field Summary
static float MAX_SPEED
          Maximum constant speed of car under automatic driving via Driver property.
 
Fields inherited from class net.sf.jaer.eventprocessing.EventFilter2D
enclosedFilter, out
 
Fields inherited from class net.sf.jaer.eventprocessing.EventFilter
annotationEnabled, chip, enclosedFilterChain, filterEnabled, perf, propertyTooltipMap, support
 
Constructor Summary
Driver(AEChip chip)
          Creates a new instance of Driver
 
Method Summary
 void annotate(float[][][] frame)
          annotate the RGB frame somehow by color pixels in the rendered pixel frame data.
 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)
          each annotator is called by the relevant class (e.g.
 EventPacket<?> filterPacket(EventPacket<?> in)
          Applies the enclosed LineDetector filter to extract the lowpassed dominant line feature in the scene, then computes steering and speed based on the filter output.
 float getAngleGain()
           
 float getDefaultSpeed()
           
 java.lang.Object getFilterState()
          should return the filter state in some useful form
 float getOffsetGain()
           
 float getSteerCommand()
          Gets the actual steering command based on flipSteering
 float getTauDynMs()
           
 void initFilter()
          this should allocate and initialize memory: it may be called when the chip e.g.
 boolean isFlipSteering()
           
 boolean isLoggingEnabled()
           
 boolean isSendControlToBlenderEnabled()
           
 boolean isShowAccelerometerGUI()
           
 boolean isUseMultiLineTracker()
           
 void resetFilter()
          should reset the filter to initial state
 void setAngleGain(float angleGain)
          Sets steering angleGain
 void setDefaultSpeed(float defaultSpeed)
           
 void setFlipSteering(boolean flipSteering)
          If set true, then drive towards events (road is textured), if false, drive away from events (side is textured).
 void setLoggingEnabled(boolean loggingEnabled)
           
 void setOffsetGain(float offsetGain)
          Sets steering offsetGain
 void setSendControlToBlenderEnabled(boolean sendControlToBlenderEnabled)
           
 void setShowAccelerometerGUI(boolean showAccelerometerGUI)
           
 void setTauDynMs(float tauDynMs)
           
 void setUseMultiLineTracker(boolean useMultiLineTracker)
           
 
Methods inherited from class net.sf.jaer.eventprocessing.EventFilter2D
checkOutputPacketEventType, checkOutputPacketEventType, getEnclosedFilter, resetOut, setEnclosedFilter, setFilterEnabled
 
Methods inherited from class net.sf.jaer.eventprocessing.EventFilter
getChip, getDescription, 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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jaer.graphics.FrameAnnotater
isAnnotationEnabled, setAnnotationEnabled
 

Field Detail

MAX_SPEED

public static final float MAX_SPEED
Maximum constant speed of car under automatic driving via Driver property. Limited for safety.

See Also:
Constant Field Values
Constructor Detail

Driver

public Driver(AEChip chip)
Creates a new instance of Driver

Method Detail

filterPacket

public EventPacket<?> filterPacket(EventPacket<?> in)
Applies the enclosed LineDetector filter to extract the lowpassed dominant line feature in the scene, then computes steering and speed based on the filter output. The driver only controls the car speed via the throttle control, but the speed is reduced automatically by the controller according to the controller steering command (more steer = lower speed). The instantaneous steering command is based on the horizontal position of the line in the scene; if the line is to the right, steer left, and vice versa. In addition, the instantaneous steering command is lowpass filtered to produce the actual steering command.

Specified by:
filterPacket in class EventFilter2D
Parameters:
in - the input packet
Returns:
the output packet, which is the output of the enclosed filter chain.

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()
Description copied from class: EventFilter
this should allocate and initialize memory: it may be called when the chip e.g. size parameters are changed after creation of the filter

Specified by:
initFilter in class EventFilter

annotate

public void annotate(float[][][] frame)
Description copied from interface: FrameAnnotater
annotate the RGB frame somehow by color pixels in the rendered pixel frame data.

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)
Description copied from interface: FrameAnnotater
each annotator is called by the relevant class (e.g. EyeTracker) and enters annotate with graphics context current, in coordinates with pixel 0,0 in UL corner and pixel spacing 1 unit before scaling transform (which is already active).

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

getOffsetGain

public float getOffsetGain()

setOffsetGain

public void setOffsetGain(float offsetGain)
Sets steering offsetGain


getAngleGain

public float getAngleGain()

setAngleGain

public void setAngleGain(float angleGain)
Sets steering angleGain


isFlipSteering

public boolean isFlipSteering()

setFlipSteering

public void setFlipSteering(boolean flipSteering)
If set true, then drive towards events (road is textured), if false, drive away from events (side is textured).


getSteerCommand

public float getSteerCommand()
Gets the actual steering command based on flipSteering


isUseMultiLineTracker

public boolean isUseMultiLineTracker()

setUseMultiLineTracker

public void setUseMultiLineTracker(boolean useMultiLineTracker)

getTauDynMs

public float getTauDynMs()

setTauDynMs

public void setTauDynMs(float tauDynMs)

getDefaultSpeed

public float getDefaultSpeed()

setDefaultSpeed

public void setDefaultSpeed(float defaultSpeed)

isSendControlToBlenderEnabled

public boolean isSendControlToBlenderEnabled()

setSendControlToBlenderEnabled

public void setSendControlToBlenderEnabled(boolean sendControlToBlenderEnabled)

isLoggingEnabled

public boolean isLoggingEnabled()

setLoggingEnabled

public void setLoggingEnabled(boolean loggingEnabled)

isShowAccelerometerGUI

public boolean isShowAccelerometerGUI()

setShowAccelerometerGUI

public void setShowAccelerometerGUI(boolean showAccelerometerGUI)

jAER project on SourceForge