|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ridgesoft.robotics.sensors.CMUcam.CMUcamBase
com.ridgesoft.robotics.sensors.CMUcam.CMUcam
public class CMUcam
Class to interface with the CMUcam.
This class manages communications with the camera, alleviating the need for to be concerned with the camera's communication protocol.
The documentation for this class describes the programming interface to this class. It does not describe how to use the camera. The camera user guide should be consulted to gain insight into how to use the camera and the purpose of each function provided by the camera.
The class provides for two methods of monitoring tracking data. The simplest method is by putting the camera into a tracking mode, then polling this class as needed to retrieve the latest tracking data and color statistics using the getTrackingData and getStatisticData methods. The second method of monitoring tracking data is to register a listener class using the addCameraListener method. This class will then forward tracking data and statistic data to the listener as it is received from the camera. This method uses an additional thread to interface with the listener. If data arrives from the camera faster than it can be processed by the listener, some data will not be forwarded to the listener.
The open method must be called before calling methods that issue commands to the camera.
The following procedure may be used to receive camera tracking data:
This class creates two threads, one to receive data from the camera and the other to interface with the listener. The listener thread isn't started if the addCameraListener method isn't called.
By default, the camera receive thread runs at (Thread.NORM_PRIORITY + 2) and the listener thread runs at (Thread.NORM_PRIORITY + 1). These priorities may be changed by using the getListenerThread and getReceiveThread methods to get to the Thread objects.
Field Summary | |
---|---|
static int |
FPS_4
Clock register setting for 4 frames per second. |
Fields inherited from class com.ridgesoft.robotics.sensors.CMUcam.CMUcamBase |
---|
FPS_11, FPS_13, FPS_17, FPS_5, FPS_6, FPS_7, FPS_8, FPS_9, LED_OFF, LED_ON, LED_TRACK |
Constructor Summary | |
---|---|
CMUcam(SerialPort serialPort,
int baudRate)
Constructs a CMUcam object. |
Method Summary | |
---|---|
void |
defaultWindow()
Sets the default camera window (1, 1, 80, 143). |
protected void |
processMessage(byte[] message)
Camera version specific message processing method for the original CMUcam. |
void |
setMiddleMassMode(boolean enabled)
Enables or disables middle mass mode. |
void |
setNoiseFilter(boolean noiseFilter)
Enables or disables the noise filter. |
void |
setServoPosition(int position)
Issues a set servo position command to the camera. |
void |
setServoTracking(boolean servoTracking,
boolean reverseDirection,
boolean reportPosition)
Enables or disables servo tracking. |
void |
setSwitchingMode(boolean enabled)
Enables or disables switching mode. |
void |
setTrackingLed(int mode)
Sets the state of the tracking LED. |
void |
setWindow(int x,
int y,
int x2,
int y2)
Sets the window bounds of the camera. |
Methods inherited from class com.ridgesoft.robotics.sensors.CMUcam.CMUcamBase |
---|
addCameraListener, close, getHistogramData, getListenerThread, getMean, getReceiveThread, getRxErrors, getStatisticData, getTrackingData, isTracking, open, removeCameraListener, reset, sendBooleanCommand, sendCommand, sendCommand, setAutoExposure, setBrightness, setCameraRegister, setContrast, setDebug, setFrameRate, setIsTracking, setRGBMode, setTFrameSize, setTrackingLed, setWhiteBalance, stop, trackBlue, trackColor, trackColor, trackGreen, trackRed, trackWindow, updateHistogramData, updateStatisticData, updateTrackingData |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait |
Field Detail |
---|
public static final int FPS_4
Constructor Detail |
---|
public CMUcam(SerialPort serialPort, int baudRate)
serialPort
- serial port object for the port the camera attaches tobaudRate
- baud rate to use to communicate with the cameraMethod Detail |
---|
public void defaultWindow() throws IOException
IOException
protected void processMessage(byte[] message)
processMessage
in class CMUcamBase
message
- message to processpublic void setMiddleMassMode(boolean enabled) throws IOException
In middle mass mode the camera provides coordinates of the middle of the tracked color mass. This is useful when tracking a single point rather than a region is desirable.
Disabling middle mass mode also disables servo tracking.
When in middle mass mode (default), the TrackingData will will be type 'M' or 'N' and will contain mx and my values generated by the camera. When not in middle mass mode, the TrackingData will be type 'C' and the mx, my, and servoPosition values will be 0.
Note: The M, N, and C types correspond to frame types generated by the camera.
See the camera documentation for more detailed information.
enabled
- true (default) enables middle mass mode without servo tracking
false disables middle mass mode and servo tracking.
IOException
public void setNoiseFilter(boolean noiseFilter) throws IOException
noiseFilter
- true (default) enables the noise filter false disables the
noise filter
IOException
public void setServoPosition(int position) throws IOException
The camera must be in tracking mode or get mean data mode for the command to be carried out
The servo output can also be used as a digital output.
position
- desired position of the servo
IOException
public void setServoTracking(boolean servoTracking, boolean reverseDirection, boolean reportPosition) throws IOException
When servo tracking is enabled, the camera is put into middle mass mode.
servoTracking
- true enables servo tracking false disables servo tracking and
puts the camera into middle mass mode. Use
setMiddleMassMode(false) to disable servo tracking and middle
mass mode.reverseDirection
- reverses the sense of direction for servo commands the camera
issues to its servo portreportPosition
- true enables servoPostion reporting via type 'N' tracking data
if servo tracking is enabled. When enabled, the servoPostion
field in the TrackingData will contain data reported by the
camera, otherwise the servoPosition is zero. false disables
servoPosition reporting
IOException
public void setSwitchingMode(boolean enabled) throws IOException
In switching mode the camera sends StatisticData as well as TrackingData.
enabled
- true enables switching mode, false (default) disables
switching mode
IOException
public void setTrackingLed(int mode) throws IOException
mode
- LED mode
IOException
public void setWindow(int x, int y, int x2, int y2) throws IOException
The parameters must be within the range supported by the camera, 1 <= x <= 80, 1 <= y <= 143.
x
- x coordinate of upper left corner of desired windowy
- y coordinate of upper left corner of desired windowx2
- x coordinate of lower right corner of desired windowy2
- y coordinate of lower right corner of desired window
IOException
|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |