public class VuforiaTrackableDefaultListener extends java.lang.Object implements VuforiaTrackable.Listener
VuforiaTrackableDefaultListener
is the default listener used for VuforiaTrackable
implementations. This listener facilitates polling for results of the tracking. (Advanced:) Alternate
listeners could make use of event-driven results by taking actions in the VuforiaTrackable.Listener
methods.VuforiaTrackable
,
VuforiaTrackable.getListener()
Modifier and Type | Class and Description |
---|---|
protected static class |
VuforiaTrackableDefaultListener.PoseAndCamera |
Constructor and Description |
---|
VuforiaTrackableDefaultListener() |
VuforiaTrackableDefaultListener(VuforiaTrackable trackable)
If a null
VuforiaTrackable is provided, then addTrackable(VuforiaTrackable)
must be called later, before tracking actually begins. |
Modifier and Type | Method and Description |
---|---|
void |
addTrackable(VuforiaTrackable trackable)
Adds a trackable on which this
VuforiaTrackable.Listener is listening. |
VuforiaLocalizer.CameraDirection |
getCameraDirection()
Deprecated.
This is of little use if a non-builtin camera is in use.
|
OpenGLMatrix |
getCameraLocationOnRobot(CameraName cameraName)
Returns information previously set in
setCameraLocationOnRobot(CameraName, OpenGLMatrix) |
CameraName |
getCameraName()
Returns the name of the camera most recently tracked, or null if tracking has never occurred.
|
protected OpenGLMatrix |
getFtcCameraFromRobot(CameraName cameraName) |
OpenGLMatrix |
getFtcCameraFromTarget()
Returns the pose of the trackable if it is currently visible.
|
OpenGLMatrix |
getFtcFieldFromRobot()
Returns the
OpenGLMatrix transform that represents the location of the robot
on in the FTC Field Coordinate System, or null if that cannot be computed. |
OpenGLMatrix |
getLastTrackedPoseVuforiaCamera()
Returns the pose associated with the last known tracked location of this trackable, if any.
|
OpenGLMatrix |
getLastTrackedRawPose()
Deprecated.
use
getLastTrackedPoseVuforiaCamera() instead |
protected OpenGLMatrix |
getPhoneFromVuforiaCamera(VuforiaLocalizer.CameraDirection direction)
|
OpenGLMatrix |
getPhoneLocationOnRobot()
Deprecated.
Using
getCameraLocationOnRobot(CameraName) is a better choice. |
OpenGLMatrix |
getPose()
A synonym for
getPosePhone() , the latter being more descriptive of the
coordinate system of the value returned. |
OpenGLMatrix |
getPoseCorrectionMatrix(VuforiaLocalizer.CameraDirection direction)
Deprecated.
These phone-based matrices are no longer of much relevance, as the
correct values, when of interest, are fixed and known.
|
OpenGLMatrix |
getPosePhone()
Returns the pose of the trackable if it is currently visible.
|
OpenGLMatrix |
getRawPose()
Deprecated.
use
getVuforiaCameraFromTarget() instead |
OpenGLMatrix |
getRawUpdatedPose()
Deprecated.
use
getUpdatedVuforiaCameraFromTarget() instead |
OpenGLMatrix |
getRobotLocation()
Synonym for
getFtcFieldFromRobot() |
OpenGLMatrix |
getUpdatedRobotLocation()
Returns the location of the robot, but only if a new location has been detected since
the last call to
getUpdatedRobotLocation() . |
OpenGLMatrix |
getUpdatedVuforiaCameraFromTarget()
Returns the raw pose of the trackable, but only if a new pose is available since the last call
to
getUpdatedVuforiaCameraFromTarget() . |
OpenGLMatrix |
getVuforiaCameraFromTarget()
Returns the raw pose of the trackable as reported by Vuforia.
|
VuMarkInstanceId |
getVuMarkInstanceId()
Returns the instance id of the currently visible VuMark associated with this
VuMark template, if any presently exists.
|
boolean |
isVisible()
Answers whether the associated trackable is currently visible or not
|
void |
onNotTracked()
Called by the system to inform the trackable that it is no longer visible.
|
void |
onTracked(TrackableResult trackableResult,
CameraName cameraName,
Camera camera,
VuforiaTrackable child)
onTracked(TrackableResult, CameraName, Camera, org.firstinspires.ftc.robotcore.external.navigation.VuforiaTrackable) is called by the system to notify the listener that its associated trackable is currently visible. |
void |
setCameraLocationOnRobot(CameraName cameraName,
OpenGLMatrix robotFromFtcCamera)
Informs the
VuforiaTrackableDefaultListener of the location of a particular camera
on the robot. |
void |
setPhoneInformation(OpenGLMatrix robotFromPhone,
VuforiaLocalizer.CameraDirection cameraDirection)
Informs the listener of the location of the phone on the robot and the identity of
the camera being used.
|
void |
setPoseCorrectionMatrix(VuforiaLocalizer.CameraDirection direction,
OpenGLMatrix matrix)
Deprecated.
|
public static final java.lang.String TAG
protected final java.lang.Object lock
protected VuforiaTrackable trackable
protected boolean newPoseAvailable
protected boolean newLocationAvailable
protected VuforiaTrackableDefaultListener.PoseAndCamera currentPoseAndCamera
protected VuforiaTrackableDefaultListener.PoseAndCamera lastTrackedPoseAndCamera
protected VuMarkInstanceId vuMarkInstanceId
protected final OpenGLMatrix phoneFromVuforiaCameraFront
protected final OpenGLMatrix phoneFromVuforiaCameraBack
protected final OpenGLMatrix vuforiaCameraFrontFromVuforiaCameraBack
protected final OpenGLMatrix ftcCameraFromVuforiaCamera
protected final OpenGLMatrix vuforiaCameraFromFtcCamera
protected final OpenGLMatrix phoneFromFtcCameraFront
protected final OpenGLMatrix phoneFromFtcCameraBack
protected final OpenGLMatrix ftcCameraFrontFromPhone
protected final OpenGLMatrix ftcCameraBackFromPhone
protected final java.util.Map<CameraName,OpenGLMatrix> ftcCameraFromRobotCoords
protected final java.util.Map<CameraName,OpenGLMatrix> robotFromFtcCameraCoords
protected final CameraName cameraNameFront
protected final CameraName cameraNameBack
public VuforiaTrackableDefaultListener()
public VuforiaTrackableDefaultListener(VuforiaTrackable trackable)
VuforiaTrackable
is provided, then addTrackable(VuforiaTrackable)
must be called later, before tracking actually begins.public void setPhoneInformation(OpenGLMatrix robotFromPhone, VuforiaLocalizer.CameraDirection cameraDirection)
robotFromPhone
- the location of the phone on the robot. Maps phone coordinates to robot coordinates.cameraDirection
- which camera on the phone is in usepublic void setCameraLocationOnRobot(CameraName cameraName, OpenGLMatrix robotFromFtcCamera)
VuforiaTrackableDefaultListener
of the location of a particular camera
on the robot.cameraName
- the name of the camera in questionrobotFromFtcCamera
- the location of that camera; it transforms FTC camera coordiantes
to robot coordinates@Deprecated public OpenGLMatrix getPhoneLocationOnRobot()
getCameraLocationOnRobot(CameraName)
is a better choice.public OpenGLMatrix getCameraLocationOnRobot(CameraName cameraName)
setCameraLocationOnRobot(CameraName, OpenGLMatrix)
cameraName
- the camera whose location is soughtprotected OpenGLMatrix getFtcCameraFromRobot(CameraName cameraName)
@Deprecated public VuforiaLocalizer.CameraDirection getCameraDirection()
public CameraName getCameraName()
public OpenGLMatrix getFtcFieldFromRobot()
Returns the OpenGLMatrix
transform that represents the location of the robot
on in the FTC Field Coordinate System, or null if that cannot be computed. The returned
transformation will map coordinates in the Robot Coordinate System to coordinates in the
FTC Field Coordinate System.
The pose will be null if the trackable is not currently visible. The location of the trackable
will be null if a location wasn't previously provided with VuforiaTrackable.setLocation(OpenGLMatrix)
.
The camera location on the robot will be null if setCameraLocationOnRobot(CameraName, org.firstinspires.ftc.robotcore.external.matrices.OpenGLMatrix)
has not been called. All three must be non-null for the location to be computable.
getUpdatedRobotLocation()
,
getPosePhone()
,
setPhoneInformation(OpenGLMatrix, VuforiaLocalizer.CameraDirection)
,
VuforiaTrackable.setLocation(OpenGLMatrix)
,
getRobotLocation()
public OpenGLMatrix getRobotLocation()
getFtcFieldFromRobot()
@Deprecated public OpenGLMatrix getPoseCorrectionMatrix(VuforiaLocalizer.CameraDirection direction)
protected OpenGLMatrix getPhoneFromVuforiaCamera(VuforiaLocalizer.CameraDirection direction)
@Deprecated public void setPoseCorrectionMatrix(VuforiaLocalizer.CameraDirection direction, OpenGLMatrix matrix)
public OpenGLMatrix getUpdatedRobotLocation()
getUpdatedRobotLocation()
.getRobotLocation()
public OpenGLMatrix getPosePhone()
getFtcCameraFromTarget()
for a better choice.
Note that whether a trackable is visible or not is constantly dynamically changing in the background as the phone is moved about. Thus, just because one call to getPose() returns a non-null matrix doesn't a second call a short time later will return the same result.
getPhoneFromVuforiaCamera(VuforiaLocalizer.CameraDirection)
,
getVuforiaCameraFromTarget()
,
isVisible()
,
getPose()
public OpenGLMatrix getPose()
getPosePhone()
, the latter being more descriptive of the
coordinate system of the value returned. Note that this function is of little use
if a webcam is used instead of a builtin phone camera.public OpenGLMatrix getFtcCameraFromTarget()
getPosePhone()
public OpenGLMatrix getVuforiaCameraFromTarget()
getPosePhone()
because of the differing coordinate systems
used by Vuforia and FTCgetPhoneFromVuforiaCamera(VuforiaLocalizer.CameraDirection)
,
getRawPose()
@Deprecated public OpenGLMatrix getRawPose()
getVuforiaCameraFromTarget()
insteadpublic OpenGLMatrix getUpdatedVuforiaCameraFromTarget()
getUpdatedVuforiaCameraFromTarget()
.getVuforiaCameraFromTarget()
,
getRawUpdatedPose()
@Deprecated public OpenGLMatrix getRawUpdatedPose()
getUpdatedVuforiaCameraFromTarget()
insteadpublic boolean isVisible()
getVuforiaCameraFromTarget()
public OpenGLMatrix getLastTrackedPoseVuforiaCamera()
getVuforiaCameraFromTarget()
@Deprecated public OpenGLMatrix getLastTrackedRawPose()
getLastTrackedPoseVuforiaCamera()
insteadpublic VuMarkInstanceId getVuMarkInstanceId()
public void onTracked(TrackableResult trackableResult, CameraName cameraName, Camera camera, VuforiaTrackable child)
onTracked(TrackableResult, CameraName, Camera, org.firstinspires.ftc.robotcore.external.navigation.VuforiaTrackable)
is called by the system to notify the listener that its associated trackable is currently visible.onTracked
in interface VuforiaTrackable.Listener
trackableResult
- the Vuforia trackable result object in which we were locatedcameraName
- the name of the camera used by Vuforia to track this objectcamera
- the Camera
instance used in the tracking. Will be null if
a built-in camera is usedpublic void onNotTracked()
onNotTracked
in interface VuforiaTrackable.Listener
public void addTrackable(VuforiaTrackable trackable)
VuforiaTrackable.Listener
VuforiaTrackable.Listener
is listening. May not be
called once tracking has begun. If the VuforiaTrackable.Listener
is already listening
to this trackable, then the call has no effect.addTrackable
in interface VuforiaTrackable.Listener