Class TrcPixyCam1

java.lang.Object
trclib.archive.TrcPixyCam1
Direct Known Subclasses:
FrcPixyCam1

public abstract class TrcPixyCam1 extends Object
This class implements a platform independent pixy camera 1. 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 object block from the pixy camera 1. It also provides access to the last detected objects reported by the pixy camera asynchronously.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    This class implements the pixy camera object block communication protocol.
    static enum 
    This is used identify the request type.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TrcPixyCam1(String instanceName, boolean msbFirst)
    Constructor: Create an instance of the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    asyncReadData(TrcPixyCam1.RequestId requestId, int length)
    This method issues an asynchronous read of the specified number of bytes from the device.
    void
    asyncWriteBytes(byte[] data)
    This method writes the data to the device one byte at a time.
    abstract void
    asyncWriteData(TrcPixyCam1.RequestId requestId, byte[] data)
    This method writes the data buffer to the device asynchronously.
    void
    end()
    This method sets the pixy camera to end state so it will start properly next time.
    This method returns an array of detected object blocks.
    protected void
    This method is called when the read request is completed.
    void
    setBrightness(byte brightness)
    This method sets the camera brightness.
    void
    setLED(byte red, byte green, byte blue)
    This method sets the LED to the specified color.
    void
    setPanTilt(int pan, int tilt)
    This method sets the pan and tilt servo positions.
    void
    This method starts the pixy camera by queuing the initial read request if not already.
    This method returns the instance name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • instanceName

      protected final String instanceName
  • Constructor Details

    • TrcPixyCam1

      public TrcPixyCam1(String instanceName, boolean msbFirst)
      Constructor: Create an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      msbFirst - specifies true if a word has MSB first.
  • Method Details

    • asyncReadData

      public abstract void asyncReadData(TrcPixyCam1.RequestId requestId, int length)
      This method issues an asynchronous read of the specified number of bytes from the device.
      Parameters:
      requestId - specifies the ID to identify the request for the request handler. Can be null if none was provided.
      length - specifies the number of bytes to read.
    • asyncWriteData

      public abstract void asyncWriteData(TrcPixyCam1.RequestId requestId, byte[] data)
      This method writes the data buffer to the device asynchronously.
      Parameters:
      requestId - specifies the ID to identify the request for the request handler. Can be null if none was provided.
      data - specifies the data buffer.
    • toString

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      instance name.
    • start

      public void start()
      This method starts the pixy camera by queuing the initial read request if not already.
    • end

      public void end()
      This method sets the pixy camera to end state so it will start properly next time.
    • asyncWriteBytes

      public void asyncWriteBytes(byte[] data)
      This method writes the data to the device one byte at a time.
      Parameters:
      data - specifies the buffer containing the data to be written to the device.
    • setLED

      public void setLED(byte red, byte green, byte blue)
      This method sets the LED to the specified color.
      Parameters:
      red - specifies the red value.
      green - specifies the green value.
      blue - specifies the blue value.
    • setBrightness

      public void setBrightness(byte brightness)
      This method sets the camera brightness.
      Parameters:
      brightness - specifies the brightness value.
    • setPanTilt

      public void setPanTilt(int pan, int tilt)
      This method sets the pan and tilt servo positions.
      Parameters:
      pan - specifies the pan position between 0 and 1000.
      tilt - specifies the tilt position between 0 and 1000.
    • getDetectedObjects

      public TrcPixyCam1.ObjectBlock[] getDetectedObjects()
      This method returns an array of detected object blocks.
      Returns:
      array of detected object blocks, can be null if no object detected or result of the next frame not yet available.
    • requestHandler

      protected void requestHandler(Object context)
      This method is called when the read request is completed.
      Parameters:
      context - specifies the read request.