public final class TangoPositionOrientationProvider extends PositionOrientationProvider
By using data from external sensors the local Tango coordiante system can be placed and oriented in
relation to a global (geographic) coordinate system. For an initial determination of the position
and orientation parameters data from the devices compass and GPS may be added
through the handleRotationVectorObservation(float[])
and
handleLocationObservation(Location)
methods.
For further refinement manual observations may be added by pointing in a map or using the Tango point cloud sensor for matching against a terrain model
Created by runaas on 20.04.2017.
Modifier and Type | Class and Description |
---|---|
private class |
TangoPositionOrientationProvider.PrivPredictionMatrixUpdater |
private class |
TangoPositionOrientationProvider.TransformWorker
Worker run in the background, recomputing the transform parameters when new data is present
|
Modifier and Type | Field and Description |
---|---|
private float |
compass_az |
private float |
compass_dir |
private float |
declination |
(package private) static double |
EarthRadius |
private double |
geoidH_0 |
private org.ejml.data.DMatrixRMaj |
H_tango |
private KalmanFilter |
kalmanFilter
Simple Kalman filter for smoothing Tango position information and computing
speed, travel direction and predicted positions
|
private android.location.Location |
lastLocation |
private static int |
numParameters |
private java.util.concurrent.CopyOnWriteArrayList<Transform.Observation> |
observations
List of observations used in determining the transformation between TAngo and external coordiantes
|
private OriginData |
origin |
private TangoPositionOrientationProvider.PrivPredictionMatrixUpdater |
predictionMatrixUpdater |
private long |
prevCompTime
Timestamp of previous kalman filter prediction
|
private org.ejml.data.DMatrixRMaj |
R_tango |
(package private) static java.lang.String |
TAG |
private float |
tango_dir |
private double |
tangoVariance
Apriori variance of Tango device position
|
private float[] |
tmpRotA |
private float[] |
tmpRotMatrix |
private float[] |
transformMatrix |
private TangoPositionOrientationProvider.TransformWorker |
transformWorker |
private java.lang.Thread |
transformWorkerThread |
private Transform |
xform |
private boolean |
xformOk |
private org.ejml.data.DMatrixRMaj |
z_tango |
originUpdateListeners
Constructor and Description |
---|
TangoPositionOrientationProvider()
Create and initialize
|
Modifier and Type | Method and Description |
---|---|
android.location.Location |
getLocation()
Get the current position of the device
|
OriginData |
getOrigin() |
float[] |
getTransformationMatrix()
Get the current rotation of the device in the rotation matrix format
|
Transform.Observation |
handleLatLngHObservation(double latitude,
double longitude,
double height,
float horizontal_accuracy,
float vertical_accuracy)
Handle an observation of the current 3D device position.
|
Transform.Observation |
handleLatLngObservation(double latitude,
double longitude,
float accuracy)
Handle an observation of the current 2D device position.
|
Transform.Observation |
handleLocationObservation(android.location.Location location)
Create a
Transform.PositionObservation3D
object from a GPS (or similar observation). |
java.util.ArrayList<Transform.Observation> |
handlePointCloudObservation(int numPoints,
java.nio.FloatBuffer points,
DTMGrid grid,
float cloud_accuracy)
Create a set of
Transform.PointInTerrainObservation from
a point cloud observation and a gridded terrain model. |
void |
handlePoseObservation(com.google.atap.tangoservice.TangoPoseData pose)
Update the provider with the most recent pose (position and orientation) in the Tango coordinate system
Typically called from
Tango.TangoUpdateCallback.onPoseAvailable(TangoPoseData) |
Transform.Observation |
handleRotationVectorObservation(float[] rotationVector)
Create a
Transform.OrientationObservation
from a rotationVector as given from a Rotation Vector Sensor . |
void |
onDestroy() |
boolean |
removeObservation(Transform.Observation obs)
Remove an observation and initialize recompute of parameters
|
boolean |
removeObservations(java.util.Collection<Transform.Observation> obs_set)
Remove a set of observations and initialize recompute of parameters
|
void |
reset()
Initialize everything (when Tango initializes with a new origin)
|
addOriginUpdateListener, callOriginUpdateListeners, removeOriginUpdateListener
static final java.lang.String TAG
static final double EarthRadius
private volatile float[] transformMatrix
private static final int numParameters
private double tangoVariance
private long prevCompTime
private OriginData origin
private double geoidH_0
private org.ejml.data.DMatrixRMaj z_tango
private org.ejml.data.DMatrixRMaj R_tango
private org.ejml.data.DMatrixRMaj H_tango
private KalmanFilter kalmanFilter
private java.util.concurrent.CopyOnWriteArrayList<Transform.Observation> observations
private float declination
private float compass_dir
private float tango_dir
private float compass_az
private Transform xform
private volatile boolean xformOk
private volatile android.location.Location lastLocation
private TangoPositionOrientationProvider.PrivPredictionMatrixUpdater predictionMatrixUpdater
private java.lang.Thread transformWorkerThread
private TangoPositionOrientationProvider.TransformWorker transformWorker
private final float[] tmpRotA
private final float[] tmpRotMatrix
public TangoPositionOrientationProvider()
public void onDestroy()
public void reset()
PositionOrientationProvider
reset
in class PositionOrientationProvider
public float[] getTransformationMatrix()
PositionOrientationProvider
getTransformationMatrix
in class PositionOrientationProvider
public android.location.Location getLocation()
PositionOrientationProvider
getLocation
in class PositionOrientationProvider
public OriginData getOrigin()
public Transform.Observation handleLocationObservation(android.location.Location location)
Transform.PositionObservation3D
object from a GPS (or similar observation). This method is
typically called from a LocationListener
registred to a
LocationManager
.location
- location data from GPS or similar location servicesTransform.PositionObservation3D
objectpublic Transform.Observation handleLatLngObservation(double latitude, double longitude, float accuracy)
handleLocationObservation(Location)
. Can be used for manually adding a position from maplatitude
- latitude of geograpic position, in degreeslongitude
- longitude of geograpic position, in degreesaccuracy
- apriori standard deviation of position, in metersTransform.PositionObservation2D
objectpublic Transform.Observation handleLatLngHObservation(double latitude, double longitude, double height, float horizontal_accuracy, float vertical_accuracy)
handleLocationObservation(Location)
. Can be used for manually adding a position
from map, combined with an elevation observation from terrain model.latitude
- latitude of geograpic position, in degreeslongitude
- longitude of geograpic position, in degreesheight
- height of geograpic position, in metershorizontal_accuracy
- apriori standard deviation of horizontal position, in metersvertical_accuracy
- apriori standard deviation of height, in metersTransform.PositionObservation3D
objectpublic Transform.Observation handleRotationVectorObservation(float[] rotationVector)
Transform.OrientationObservation
from a rotationVector as given from a Rotation Vector Sensor
.
This method is typically called from a SensorEventListener
,
where the rotationVector is read from a SensorEvent
.rotationVector
- value from a SensorEvent
Transform.OrientationObservation
objectpublic void handlePoseObservation(com.google.atap.tangoservice.TangoPoseData pose)
Typically called from Tango.TangoUpdateCallback.onPoseAvailable(TangoPoseData)
pose
- the position orientation structure given from Tangopublic java.util.ArrayList<Transform.Observation> handlePointCloudObservation(int numPoints, java.nio.FloatBuffer points, DTMGrid grid, float cloud_accuracy)
Transform.PointInTerrainObservation
from
a point cloud observation and a gridded terrain model.
Typically called from Tango.TangoUpdateCallback.onPointCloudAvailable(com.google.atap.tangoservice.TangoPointCloudData)
numPoints
- the number of pointspoints
- a FloatBuffer of point data, with stride 4 as points are stored in the buffer as
x1, y1, z1, w1, x2, y2, z2, w2.... where w is a "reliability" measure (not used here)grid
- A gridded terrain modelcloud_accuracy
- apriori standard deviation of a point to terrain model distance observationpublic boolean removeObservation(Transform.Observation obs)
obs
- the observation to removepublic boolean removeObservations(java.util.Collection<Transform.Observation> obs_set)
obs_set
- the list of observations to remove