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.NetworkTableEntrym_foundTargetprotected Tm_lastResultprotected edu.wpi.first.networktables.NetworkTableEntrym_lastResultTimestampprotected edu.wpi.first.networktables.NetworkTablem_tableprotected edu.wpi.first.networktables.NetworkTableEntrym_xAbsprotected edu.wpi.first.networktables.NetworkTableEntrym_xErrorprotected edu.wpi.first.networktables.NetworkTableEntrym_yAbsprotected edu.wpi.first.networktables.NetworkTableEntrym_yError
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractVisionConnector(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 TgetDefaultValue()TgetLastResult()protected abstract voidnext(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 lastResultvoidpublish()publish VisionResult values to corresponding NetworkTable Entries should be overriden and supered by any children of type T extends VisionResultprotected VisionResultretrieve()retrieve a VisionResult from NetworkTable Entries should be overriden and supered by any children of type T extends VisionResultvoidsubscribe()add listener for the lastResultTimestamp entry in NetworkTables process the next result on an updatevoidunsubscribe()remove listener for the lastResultTimestamp entry in NetworkTablesvoidupdateResult(T result)edu.wpi.first.wpilibj.PIDSourcexPID()Get a PID source which tracks the x-coordinate of the target.edu.wpi.first.wpilibj.PIDSourceyPID()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:
subscribein interfaceVisionConnector
-
unsubscribe
public void unsubscribe()
remove listener for the lastResultTimestamp entry in NetworkTables- Specified by:
unsubscribein 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:
publishin 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.
-
-