Package trclib.archive
Class TrcPixyCam2
java.lang.Object
trclib.archive.TrcPixyCam2
- Direct Known Subclasses:
FtcPixyCam2
This class implements a platform independent pixy camera 2. This class is intended to be extended by a platform
dependent pixy class which provides the abstract methods required by this class. This class provides the parser
to read and parse the response packets from the pixy camera 2. It also implements pixy camera APIs for all the
pixy requests.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
class
This class implements the detected object block.class
class
class
class
class
class
class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte
private int
private int
protected final String
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
static final byte
private static final short
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
static final byte
private static final short
private int
private int
protected final TrcDbgTrace
-
Constructor Summary
ConstructorsConstructorDescriptionTrcPixyCam2
(String instanceName) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiongetAllFeatures
(byte featuresMap) getBlocks
(byte sigMap, byte maxBlocks) This method sends a request to get the detected object blocks.getFeatures
(byte requestType, byte featuresMap) This method sends a request to get the detected features.byte
This method returns the firmware type info.int
This method returns the firmware version info.int
getFPS()
This method sends a request to get the camera frame rate.int
This method returns the hardware version info.getMainFeatures
(byte featuresMap) private void
This method sends a GET_RESOLUTION request if it hasn't already.int
This method returns the resolution height of the device.int
This method returns the resolution width of the device.int
getRGB
(int x, int y, byte satFlag) private void
This method sends a GET_VERSION request to the device if it hasn't already.int
private int
sendDataRequest
(byte requestType, byte[] data) This method builds a request that will reply with a standard PIXY2_RES_RESULT response packet.private byte[]
sendRequest
(byte requestType, byte[] data, byte expectedResponseType) This method builds the request packet, writes it to the device, reads the response packet, check the checksum and returns the response packet if it's valid.int
setCameraBrightness
(byte brightness) This method sends a request to set the camera brightness.int
setDefaultTurn
(short angle) This method sends a request to set the default turn angle.int
setLamp
(boolean upper, boolean lower) This method sends a request to turn on/off the lamp LEDs.int
setLED
(byte red, byte green, byte blue) This method sends a request to set the LED color.int
setMode
(byte mode) This method sends a request to set the camera mode.int
setNextTurn
(short angle) This method sends a request to set the next turn angle.int
setServos
(int panValue, int tiltValue) This method sends a request to set the pan and tilt value of the gimbal servos.int
setVector
(byte index) abstract byte[]
This method issues a synchronous read of the request response.abstract void
syncWriteRequest
(byte[] data) This method writes the request data to the device synchronously.toString()
This method returns the instance name.private boolean
validateChecksum
(byte[] data) This method checks if the checksum of the response packet is correct.
-
Field Details
-
PIXY2_SEND_SYNC
private static final short PIXY2_SEND_SYNC- See Also:
-
PIXY2_RECV_SYNC
private static final short PIXY2_RECV_SYNC- See Also:
-
PIXY2_REQ_GET_RESOLUTION
private static final byte PIXY2_REQ_GET_RESOLUTION- See Also:
-
PIXY2_REQ_GET_VERSION
private static final byte PIXY2_REQ_GET_VERSION- See Also:
-
PIXY2_REQ_SET_CAMERA_BRIGHTNESS
private static final byte PIXY2_REQ_SET_CAMERA_BRIGHTNESS- See Also:
-
PIXY2_REQ_SET_SERVOS
private static final byte PIXY2_REQ_SET_SERVOS- See Also:
-
PIXY2_REQ_SET_LED
private static final byte PIXY2_REQ_SET_LED- See Also:
-
PIXY2_REQ_SET_LAMP
private static final byte PIXY2_REQ_SET_LAMP- See Also:
-
PIXY2_REQ_GET_FPS
private static final byte PIXY2_REQ_GET_FPS- See Also:
-
PIXY2_REQ_GET_BLOCKS
private static final byte PIXY2_REQ_GET_BLOCKS- See Also:
-
PIXY2_REQ_GET_MAIN_FEATURES
private static final byte PIXY2_REQ_GET_MAIN_FEATURES- See Also:
-
PIXY2_REQ_SET_MODE
private static final byte PIXY2_REQ_SET_MODE- See Also:
-
PIXY2_REQ_SET_VECTOR
private static final byte PIXY2_REQ_SET_VECTOR- See Also:
-
PIXY2_REQ_SET_NEXT_TURN
private static final byte PIXY2_REQ_SET_NEXT_TURN- See Also:
-
PIXY2_REQ_SET_DEFAULT_TURN
private static final byte PIXY2_REQ_SET_DEFAULT_TURN- See Also:
-
PIXY2_REQ_REVERSE_VECTOR
private static final byte PIXY2_REQ_REVERSE_VECTOR- See Also:
-
PIXY2_REQ_GET_RGB
private static final byte PIXY2_REQ_GET_RGB- See Also:
-
PIXY2_RES_RESULT
private static final byte PIXY2_RES_RESULT- See Also:
-
PIXY2_RES_RESOLUTION
private static final byte PIXY2_RES_RESOLUTION- See Also:
-
PIXY2_RES_VERSION
private static final byte PIXY2_RES_VERSION- See Also:
-
PIXY2_RES_BLOCKS
private static final byte PIXY2_RES_BLOCKS- See Also:
-
PIXY2_RES_MAIN_FEATURES
private static final byte PIXY2_RES_MAIN_FEATURES- See Also:
-
PIXY2_FEATURE_TYPE_MAIN
public static final byte PIXY2_FEATURE_TYPE_MAIN- See Also:
-
PIXY2_FEATURE_TYPE_ALL
public static final byte PIXY2_FEATURE_TYPE_ALL- See Also:
-
PIXY2_FEATURES_VECTOR
public static final byte PIXY2_FEATURES_VECTOR- See Also:
-
PIXY2_FEATURES_INTERSECTION
public static final byte PIXY2_FEATURES_INTERSECTION- See Also:
-
PIXY2_FEATURES_BARCODE
public static final byte PIXY2_FEATURES_BARCODE- See Also:
-
PIXY2_FEATURES_ALL
public static final byte PIXY2_FEATURES_ALL- See Also:
-
PIXY2_BLOCKS_SIG_1
public static final byte PIXY2_BLOCKS_SIG_1- See Also:
-
PIXY2_BLOCKS_SIG_2
public static final byte PIXY2_BLOCKS_SIG_2- See Also:
-
PIXY2_BLOCKS_SIG_3
public static final byte PIXY2_BLOCKS_SIG_3- See Also:
-
PIXY2_BLOCKS_SIG_4
public static final byte PIXY2_BLOCKS_SIG_4- See Also:
-
PIXY2_BLOCKS_SIG_5
public static final byte PIXY2_BLOCKS_SIG_5- See Also:
-
PIXY2_BLOCKS_SIG_6
public static final byte PIXY2_BLOCKS_SIG_6- See Also:
-
PIXY2_BLOCKS_SIG_7
public static final byte PIXY2_BLOCKS_SIG_7- See Also:
-
PIXY2_BLOCKS_SIG_8
public static final byte PIXY2_BLOCKS_SIG_8- See Also:
-
PIXY2_BLOCKS_ALL_SIG
public static final byte PIXY2_BLOCKS_ALL_SIG- See Also:
-
PIXY2_MAX_BLOCKS_ALL
public static final byte PIXY2_MAX_BLOCKS_ALL- See Also:
-
PIXY2_LINE_FLAG_INVALID
public static final byte PIXY2_LINE_FLAG_INVALID- See Also:
-
PIXY2_LINE_FLAG_INTERSECTION_PRESENT
public static final byte PIXY2_LINE_FLAG_INTERSECTION_PRESENT- See Also:
-
PIXY2_SAT_FLAG_SATURATE
public static final byte PIXY2_SAT_FLAG_SATURATE- See Also:
-
tracer
-
instanceName
-
hardwareVersion
private int hardwareVersion -
firmwareVersion
private int firmwareVersion -
firmwareType
private byte firmwareType -
resolutionWidth
private int resolutionWidth -
resolutionHeight
private int resolutionHeight
-
-
Constructor Details
-
TrcPixyCam2
Constructor: Create an instance of the object.- Parameters:
instanceName
- specifies the instance name.
-
-
Method Details
-
syncWriteRequest
public abstract void syncWriteRequest(byte[] data) This method writes the request data to the device synchronously.- Parameters:
data
- specifies the request data.
-
syncReadResponse
public abstract byte[] syncReadResponse()This method issues a synchronous read of the request response. -
toString
This method returns the instance name. -
validateChecksum
private boolean validateChecksum(byte[] data) This method checks if the checksum of the response packet is correct.- Parameters:
data
- specifies the response packet.- Returns:
- true if the checksum is correct, false otherwise.
-
sendRequest
private byte[] sendRequest(byte requestType, byte[] data, byte expectedResponseType) This method builds the request packet, writes it to the device, reads the response packet, check the checksum and returns the response packet if it's valid.- Parameters:
requestType
- specifies the request type.data
- specifies the request data if any, null if none.expectedResponseType
- specifies the expected response type.- Returns:
- response packet if it's valid, null if invalid.
-
sendDataRequest
private int sendDataRequest(byte requestType, byte[] data) This method builds a request that will reply with a standard PIXY2_RES_RESULT response packet. It will then returned the result code from the response packet.- Parameters:
requestType
- specifies the request type.data
- specifies the request data if any, null if none.- Returns:
- result code from the response packet.
-
getVersion
private void getVersion()This method sends a GET_VERSION request to the device if it hasn't already. It updates the device version info. -
getHardwareVersion
public int getHardwareVersion()This method returns the hardware version info.- Returns:
- hardware version info.
-
getFirmwareVersion
public int getFirmwareVersion()This method returns the firmware version info.- Returns:
- firmware version info.
-
getFirmwareType
public byte getFirmwareType()This method returns the firmware type info.- Returns:
- firmware type info.
-
getResolution
private void getResolution()This method sends a GET_RESOLUTION request if it hasn't already. It updates the device resolution info. -
getResolutionWidth
public int getResolutionWidth()This method returns the resolution width of the device.- Returns:
- resolution width.
-
getResolutionHeight
public int getResolutionHeight()This method returns the resolution height of the device.- Returns:
- resolution height.
-
setCameraBrightness
public int setCameraBrightness(byte brightness) This method sends a request to set the camera brightness.- Parameters:
brightness
- specifies the brightness value (0-255).- Returns:
- the result code.
-
setServos
public int setServos(int panValue, int tiltValue) This method sends a request to set the pan and tilt value of the gimbal servos.- Parameters:
panValue
- specifies the pan servo value (0-511)tiltValue
- specifies the tilt servo value (0-511).- Returns:
- the result code.
-
setLED
public int setLED(byte red, byte green, byte blue) This method sends a request to set the LED color.- Parameters:
red
- specifies the red value.green
- specifies the green value.blue
- specifies the blue value.- Returns:
- the result code.
-
setLamp
public int setLamp(boolean upper, boolean lower) This method sends a request to turn on/off the lamp LEDs.- Parameters:
upper
- specifies true to turn on the two white LEDs on the top edge, false to turn off.lower
- specifies true to turn on the lower RGB LED, false to turn off.- Returns:
- the result code.
-
getFPS
public int getFPS()This method sends a request to get the camera frame rate.- Returns:
- the camera frame rate in frames per second.
-
getBlocks
This method sends a request to get the detected object blocks.- Parameters:
sigMap
- specifies the bitmap of the signatures (i.e. bit 1 set for signature 1, bit 2 set for signature 2 etc).maxBlocks
- specifies the maximum number of blocks to retrieve.- Returns:
- an array of detected blocks.
-
getFeatures
This method sends a request to get the detected features.- Parameters:
requestType
- specifies 0 for the main features and 1 for all features.featuresMap
- specifies the features bitmap (i.e. 1 for vectors, 2 for intersections and 4 for barcodes).- Returns:
- an array of detected features.
-
getMainFeatures
-
getAllFeatures
-
setMode
public int setMode(byte mode) This method sends a request to set the camera mode.- Parameters:
mode
- specifies the camera mode.- Returns:
- the result code.
-
setNextTurn
public int setNextTurn(short angle) This method sends a request to set the next turn angle.- Parameters:
angle
- specifies the turn angle.- Returns:
- the result code.
-
setDefaultTurn
public int setDefaultTurn(short angle) This method sends a request to set the default turn angle.- Parameters:
angle
- specifies the default turn angle.- Returns:
- the result code.
-
setVector
public int setVector(byte index) -
reverseVector
public int reverseVector() -
getRGB
public int getRGB(int x, int y, byte satFlag)
-