jAER project on SourceForge

ch.unizh.ini.jaer.hardware.pantilt
Class PanTilt

java.lang.Object
  extended by ch.unizh.ini.jaer.hardware.pantilt.PanTilt
All Implemented Interfaces:
LaserOnOffControl, PanTiltInterface

public class PanTilt
extends java.lang.Object
implements PanTiltInterface, LaserOnOffControl

Encapsulates a pan tilt controller based on using SiLabsC8051F320_USBIO_ServoController. Currently assumes that there is only one controller attached and that the pan and tilt servos are tied to the PAN and TILT servo output channels on the board. Port 2 of the ServoUSB board is used to power a laser pointer that can be activated. PanTilt directly controls the servo settings, but does not implement a calbration that maps from visual coordinates to pan tilt settings. To control the pan tilt to aim at a particular visual location in the field of view of a silicon retina, see PanTiltTracker.

Author:
tobi
See Also:
PAN, TILT, PanTiltTracker

Field Summary
 int PAN
          Servo output number on SiLabsC8051F320_USBIO_ServoController, 0 based.
 int TILT
          Servo output number on SiLabsC8051F320_USBIO_ServoController, 0 based.
 
Constructor Summary
PanTilt()
           
PanTilt(ServoInterface servo)
          Constructs instance with previously constructed SiLabsC8051F320_USBIO_ServoController
 
Method Summary
 void acquire()
          A method can set this flag to tell other objects that the servo is "owned"
 float getJitterAmplitude()
          Returns the jitter amplitude
 float getJitterFreqHz()
          Returns the jitter frequency in Hz
 float[] getPanTiltValues()
          Returns the last value set, even if the servo interface is not functional.
 ServoInterface getServoInterface()
           
 boolean isLockOwned()
          A method can check this to see if it can use the servo
 void release()
          Releases the "acquired" flag
 void setJitterAmplitude(float jitterAmplitude)
          Sets the amplitude (1/2 of peak to peak) of circular jitter of pan tilt during jittering
 void setJitterFreqHz(float jitterFreqHz)
          The frequency of the jitter
 void setLaserEnabled(boolean yes)
           
 void setLaserOn(boolean yes)
          Hack to control laser pointer power through pin 2 opendrain pulldown pins (multiple to share laser current of about 200mA
 void setPanTiltValues(float pan, float tilt)
          Simultaneously sets pan and tilt values.
 void setServoInterface(ServoInterface servo)
          Sets the ServoInterface
 void startJitter()
          Starts the servo jittering around its set position at a frequency of 50 Hz with an amplitude of 0.02f
 void stopJitter()
          Stops the jittering
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAN

public final int PAN
Servo output number on SiLabsC8051F320_USBIO_ServoController, 0 based.

See Also:
Constant Field Values

TILT

public final int TILT
Servo output number on SiLabsC8051F320_USBIO_ServoController, 0 based.

See Also:
Constant Field Values
Constructor Detail

PanTilt

public PanTilt()

PanTilt

public PanTilt(ServoInterface servo)
Constructs instance with previously constructed SiLabsC8051F320_USBIO_ServoController

Method Detail

setPanTiltValues

public void setPanTiltValues(float pan,
                             float tilt)
                      throws HardwareInterfaceException
Simultaneously sets pan and tilt values. The directions here depend on the servo polarities, which could vary. These values apply to HiTec digital servos.

Specified by:
setPanTiltValues in interface PanTiltInterface
Parameters:
pan - the pan value from 0 to 1 inclusive, 0.5f is the center position. 1 is full right.
tilt - the tilt value from 0 to 1. 1 is full down.
Throws:
HardwareInterfaceException

acquire

public void acquire()
A method can set this flag to tell other objects that the servo is "owned"

Specified by:
acquire in interface PanTiltInterface

release

public void release()
Releases the "acquired" flag

Specified by:
release in interface PanTiltInterface

isLockOwned

public boolean isLockOwned()
A method can check this to see if it can use the servo

Specified by:
isLockOwned in interface PanTiltInterface

getPanTiltValues

public float[] getPanTiltValues()
Returns the last value set, even if the servo interface is not functional. The servo could still be moving to this location.

Specified by:
getPanTiltValues in interface PanTiltInterface
Returns:
a float[] array with the 0 component being the pan value, and the 1 component being the tilt

getJitterAmplitude

public float getJitterAmplitude()
Description copied from interface: PanTiltInterface
Returns the jitter amplitude

Specified by:
getJitterAmplitude in interface PanTiltInterface

setJitterAmplitude

public void setJitterAmplitude(float jitterAmplitude)
Sets the amplitude (1/2 of peak to peak) of circular jitter of pan tilt during jittering

Specified by:
setJitterAmplitude in interface PanTiltInterface
Parameters:
jitterAmplitude - the amplitude

getJitterFreqHz

public float getJitterFreqHz()
Description copied from interface: PanTiltInterface
Returns the jitter frequency in Hz

Specified by:
getJitterFreqHz in interface PanTiltInterface

setJitterFreqHz

public void setJitterFreqHz(float jitterFreqHz)
The frequency of the jitter

Specified by:
setJitterFreqHz in interface PanTiltInterface
Parameters:
jitterFreqHz - in Hz

startJitter

public void startJitter()
Starts the servo jittering around its set position at a frequency of 50 Hz with an amplitude of 0.02f

Specified by:
startJitter in interface PanTiltInterface
See Also:
setJitterAmplitude(float)

stopJitter

public void stopJitter()
Stops the jittering

Specified by:
stopJitter in interface PanTiltInterface

setLaserOn

public void setLaserOn(boolean yes)
Hack to control laser pointer power through pin 2 opendrain pulldown pins (multiple to share laser current of about 200mA

Parameters:
yes - to turn on laser

setServoInterface

public void setServoInterface(ServoInterface servo)
Description copied from interface: PanTiltInterface
Sets the ServoInterface

Specified by:
setServoInterface in interface PanTiltInterface
Parameters:
servo - the interface

getServoInterface

public ServoInterface getServoInterface()
Specified by:
getServoInterface in interface PanTiltInterface

setLaserEnabled

public void setLaserEnabled(boolean yes)
Specified by:
setLaserEnabled in interface LaserOnOffControl

jAER project on SourceForge