Package org.hyperonline.hyperlib.vision
Class AbstractVisionConnector<T extends VisionResult>
- java.lang.Object
-
- org.hyperonline.hyperlib.vision.AbstractVisionConnector<T>
-
- Type Parameters:
T
- VisionResult type of this AbstractVisionConnector
- All Implemented Interfaces:
VisionConnector
- Direct Known Subclasses:
BasicVisionConnector
,SkewVisionConnector
,TargetWithHeightConnector
public abstract class AbstractVisionConnector<T extends VisionResult> extends java.lang.Object implements VisionConnector
Base class with common functionality used by VisionConnectors. In particular, this provides methods to store, publish, and subscribe to a result, and access it via PID sources.
-
-
Field Summary
Fields Modifier and Type Field Description protected edu.wpi.first.networktables.NetworkTableEntry
m_foundTarget
protected T
m_lastResult
protected edu.wpi.first.networktables.NetworkTableEntry
m_lastResultTimestamp
protected edu.wpi.first.networktables.NetworkTable
m_table
protected edu.wpi.first.networktables.NetworkTableEntry
m_xAbs
protected edu.wpi.first.networktables.NetworkTableEntry
m_xError
protected edu.wpi.first.networktables.NetworkTableEntry
m_yAbs
protected edu.wpi.first.networktables.NetworkTableEntry
m_yError
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractVisionConnector(java.lang.String subTableName, edu.wpi.first.networktables.NetworkTableInstance inst)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract T
getDefaultValue()
T
getLastResult()
protected abstract void
next(edu.wpi.first.networktables.NetworkTable table, java.lang.String key, edu.wpi.first.networktables.NetworkTableEntry entry, edu.wpi.first.networktables.NetworkTableValue value, int flags)
evaluate and process the results in NetworkTables to my lastResultvoid
publish()
publish VisionResult values to corresponding NetworkTable Entries should be overriden and supered by any children of type T extends VisionResultprotected VisionResult
retrieve()
retrieve a VisionResult from NetworkTable Entries should be overriden and supered by any children of type T extends VisionResultvoid
subscribe()
add listener for the lastResultTimestamp entry in NetworkTables process the next result on an updatevoid
unsubscribe()
remove listener for the lastResultTimestamp entry in NetworkTablesvoid
updateResult(T result)
edu.wpi.first.wpilibj.PIDSource
xPID()
Get a PID source which tracks the x-coordinate of the target.edu.wpi.first.wpilibj.PIDSource
yPID()
Get a PID source which tracks the y-coordinate of the target.
-
-
-
Field Detail
-
m_xError
protected final edu.wpi.first.networktables.NetworkTableEntry m_xError
-
m_yError
protected final edu.wpi.first.networktables.NetworkTableEntry m_yError
-
m_xAbs
protected final edu.wpi.first.networktables.NetworkTableEntry m_xAbs
-
m_yAbs
protected final edu.wpi.first.networktables.NetworkTableEntry m_yAbs
-
m_foundTarget
protected final edu.wpi.first.networktables.NetworkTableEntry m_foundTarget
-
m_lastResultTimestamp
protected final edu.wpi.first.networktables.NetworkTableEntry m_lastResultTimestamp
-
m_lastResult
protected T extends VisionResult m_lastResult
-
m_table
protected edu.wpi.first.networktables.NetworkTable m_table
-
-
Method Detail
-
subscribe
public void subscribe()
add listener for the lastResultTimestamp entry in NetworkTables process the next result on an update- Specified by:
subscribe
in interfaceVisionConnector
-
unsubscribe
public void unsubscribe()
remove listener for the lastResultTimestamp entry in NetworkTables- Specified by:
unsubscribe
in interfaceVisionConnector
-
getDefaultValue
public abstract T getDefaultValue()
- Returns:
- {T}
-
updateResult
public void updateResult(T result)
- Parameters:
result
- {T}
-
publish
public void publish()
publish VisionResult values to corresponding NetworkTable Entries should be overriden and supered by any children of type T extends VisionResult- Specified by:
publish
in interfaceVisionConnector
-
retrieve
protected VisionResult retrieve()
retrieve a VisionResult from NetworkTable Entries should be overriden and supered by any children of type T extends VisionResult- Returns:
- {VisionResult}
-
next
protected abstract void next(edu.wpi.first.networktables.NetworkTable table, java.lang.String key, edu.wpi.first.networktables.NetworkTableEntry entry, edu.wpi.first.networktables.NetworkTableValue value, int flags)
evaluate and process the results in NetworkTables to my lastResult- Parameters:
table
- NetworkTable to get values fromkey
- Key of the entry that triggered the Listenerentry
- Entry that was updatedvalue
- the new Valueflags
- Listener flags (created, updated, removed, etc)
-
getLastResult
public T getLastResult()
- Returns:
- {T}
-
xPID
public edu.wpi.first.wpilibj.PIDSource xPID()
Get a PID source which tracks the x-coordinate of the target.- Returns:
- A PID source tracking the x-coordinate of the target.
-
yPID
public edu.wpi.first.wpilibj.PIDSource yPID()
Get a PID source which tracks the y-coordinate of the target.- Returns:
- A PID source tracking the y-coordinate of the target.
-
-