GPS
===


**A GPS sensor that returns coordinates .**


A GPS sensor which returns the position either in Blender or Geodetic coordinates.

This sensor always provides perfect data on the levels "raw" and "extended".
To obtain more realistic readings, it is recommended to add modifiers.

- **Noise modifier**: Adds random Gaussian noise to the data

coordinates in Blender: :math:`x` -> east and :math:`y` -> north

The "heading" is Clockwise (mathematically negative).


Conversion of Geodetic coordinates into ECEF-r, LTP into ECEF-r and vice versa
------------------------------------------------------------------------------

Conversion of Geodetic coordinates into ECEF-r
++++++++++++++++++++++++++++++++++++++++++++++

To be able to simulate a GPS-sensor :math:`P` (the Blender origin) must
be defined in the properties in Geodetic coordinates (longitude,
latitude, altitude).  For the transformation [Psas_] the
coordinates must be in decimal degrees (no North, minutes,
etc.). The result is a point :math:`x_0` in the ``ECEF-r`` coordinates.


Conversion of ECEF-r into LTP[Psas_]
++++++++++++++++++++++++++++++++++++

For this conversion :math:`x_0` is the base. A point :math:`x_e` is given
in the ``ECEF-r`` coordinates and the goal is to get :math:`x_t` (:math:`=
x_e` in the ``LTP``-coordinates).

.. image:: ../../../media/conversion_coordinates.png

1. Transform :math:`P` (Blender origin, geodetic coordinates
(stored in the properties)) into :math:`x0` (geocentric (``ECEF-r``)
coordinates)

2. Calculate :math:`R_{te}[1]` with longitude, latitude and altitude;
matrix is the rotation part of the transformation

3. Transform :math:`x_e` into :math:`x_t` with :math:`x_t = R_{te} * (x_e-x_0)`


Conversion of LTP into ECEF-r
+++++++++++++++++++++++++++++

Known: :math:`P` in Geodetic coordinates (→ :math:`x_0` in ``ECEF-r``) and
:math:`x_t` in ``LTP``-coordinates

Goal: :math:`x_e` (:math:`= x_t` in ``ECEF-r`` coordinates)

Based on the transformation described above the transformation is
calculated with the transposed matrix :math:`R_{te}`: :math:`x_e = x_0 +
(R_{te})' * x_t` [Psas_]

Conversion of ECEF-r into Geodetic coordinates
++++++++++++++++++++++++++++++++++++++++++++++

The last transformation is from ``ECEF-r`` coordinates into Geodetic
coordinates.  This transformation is calculated with the Vermeille's method
[FoIz_].  The result is the point :math:`x_e` in "GPS-coordinates" in
radians.

Sources
+++++++

.. _FoIz: 

 "3.4 Vermeille's Method(2002)" in
 "Comparative Analysis of the Performance of Iterative and
 Non-iterative Solutions to the Cartesian to Geodetic Coordinate
 Transformation", Hok Sum Fok and H. Bâki Iz,
 http://www.lsgi.polyu.edu.hk/staff/zl.li/Vol_5_2/09-baki-3.pdf

.. _Psas:

 "Conversion of Geodetic coordinates to the Local Tangent
 Plane", Version 2.01,
 http://psas.pdx.edu/CoordinateSystem/Latitude_to_LocalTangent.pdf


.. cssclass:: properties morse-section

Configuration parameters for gps
--------------------------------


You can set these properties in your scripts with ``<component>.properties(<property1>=..., <property2>=...)``.

- ``longitude`` (double, default: ``0.0``)
	longitude in degree [-180°,180°] or [0°,360°] of the                   Blender origin
- ``latitude`` (double, default: ``0.0``)
	latitude in degree [-90°,90°] of the Blender origin
- ``altitude`` (double, default: ``0.0``)
	altitude in m a.s.l. of the Blender origin


.. cssclass:: levels morse-section

Available functional levels
---------------------------


*Functional levels* are predefined *abstraction* or *realism* levels for the sensor.


- ``simple`` (default level) simple GPS: only current position in Blender is exported
	At this level, the sensor exports these datafields at each simulation step:

	- ``x`` (float, initial value: ``0.0``): x coordinate of the sensor, in world coordinate, in meter
	- ``y`` (float, initial value: ``0.0``): y coordinate of the sensor, in world coordinate, in meter
	- ``z`` (float, initial value: ``0.0``): z coordinate of the sensor, in world coordinate, in meter

	*Interface support:*

	- :tag:`text`  as key = value format with timestamp and index value (:py:mod:`morse.middleware.text_datastream.Publisher`)
	- :tag:`moos`  as db entries (:py:mod:`morse.middleware.moos.gps.GPSNotifier`)
	- :tag:`yarp_json`  as json encoded data in yarp::bottle (:py:mod:`morse.middleware.yarp.yarp_json.YarpJsonPublisher`)
	- :tag:`socket`  as straight JSON serialization (:py:mod:`morse.middleware.socket_datastream.SocketPublisher`)
	- :tag:`yarp`  as yarp::Bottle (:py:mod:`morse.middleware.yarp_datastream.YarpPublisher`)
	- :tag:`ros`  as NavSatFixPublisher (:py:mod:`morse.middleware.ros.gps.NavSatFixPublisher`)
	- :tag:`pocolibs`  as `POM_ME_POS <http://trac.laas.fr/git/pom-genom/tree/pomStruct.h#n180>`_ (:py:mod:`morse.middleware.pocolibs.sensors.pom.PomSensorPoster`) or as `POM_POS <http://trac.laas.fr/git/pom-genom/tree/pomStruct.h#n211>`_ (:py:mod:`morse.middleware.pocolibs.sensors.pom.PomPoster`)



- ``raw`` raw GPS: position in Geodetic coordinates and velocity                       are exported
	At this level, the sensor exports these datafields at each simulation step:

	- ``longitude`` (double, initial value: ``0.0``): longitude in degree [-180°,180] or [0°,360°]
	- ``latitude`` (double, initial value: ``0.0``): latitude in degree [-90°,90°]
	- ``altitude`` (double, initial value: ``0.0``): altitude in m a.s.l.
	- ``velocity`` (vec3<float>, initial value: ``[0.0, 0.0, 0.0]``): Instantaneous speed in X, Y, Z, in meter sec^-1

	*Interface support:*

	- :tag:`text`  as key = value format with timestamp and index value (:py:mod:`morse.middleware.text_datastream.Publisher`)
	- :tag:`yarp_json`  as json encoded data in yarp::bottle (:py:mod:`morse.middleware.yarp.yarp_json.YarpJsonPublisher`)
	- :tag:`socket`  as straight JSON serialization (:py:mod:`morse.middleware.socket_datastream.SocketPublisher`)
	- :tag:`yarp`  as yarp::Bottle (:py:mod:`morse.middleware.yarp_datastream.YarpPublisher`)



- ``extended`` extended GPS: adding information to fit a standard                       GPS-sentence
	At this level, the sensor exports these datafields at each simulation step:

	- ``longitude`` (double, initial value: ``0.0``): longitude in degree [-180°,180] or [0°,360°]
	- ``latitude`` (double, initial value: ``0.0``): latitude in degree [-90°,90°]
	- ``altitude`` (double, initial value: ``0.0``): altitude in m a.s.l.
	- ``velocity`` (vec3<float>, initial value: ``[0.0, 0.0, 0.0]``): Instantaneous speed in X, Y, Z, in meter sec^-1
	- ``date`` (DDMMYY, initial value: ``0``): current date in DDMMYY-format
	- ``time`` (HHMMSS, initial value: ``0``): current time in HHMMSS-format
	- ``heading`` (float, initial value: ``0``): heading in degrees [0°,360°] to geographic north

	*Interface support:*

	- :tag:`text`  as key = value format with timestamp and index value (:py:mod:`morse.middleware.text_datastream.Publisher`)
	- :tag:`yarp_json`  as json encoded data in yarp::bottle (:py:mod:`morse.middleware.yarp.yarp_json.YarpJsonPublisher`)
	- :tag:`socket`  as straight JSON serialization (:py:mod:`morse.middleware.socket_datastream.SocketPublisher`)
	- :tag:`yarp`  as yarp::Bottle (:py:mod:`morse.middleware.yarp_datastream.YarpPublisher`)




.. cssclass:: services morse-section

Services for GPS
----------------

- ``get_properties()`` (blocking)
    Returns the properties of a component.
    
    
  - Return value

    a dictionary of the current component's properties  

- ``get_configurations()`` (blocking)
    Returns the configurations of a component (parsed from the properties).
    
    
  - Return value

    a dictionary of the current component's configurations  

- ``get_local_data()`` (blocking)
    Returns the current data stored in the sensor.
    
    
  - Return value

    a dictionary of the current sensor's data 



.. cssclass:: examples morse-section

Examples
--------


The following examples show how to use this component in a *Builder* script:

.. code-block:: python


    from morse.builder import *
    
    robot = ATRV()
    
    # creates a new instance of the sensor
    gps = GPS()

    # place your component at the correct location
    gps.translate(<x>, <y>, <z>)
    gps.rotate(<rx>, <ry>, <rz>)
    
    # select a specific abstraction level (cf below), or skip it to use default level
    gps.level(<level>)
    
    robot.append(gps)
    
    # define one or several communication interface, like 'socket'
    gps.add_interface(<interface>)

    env = Environment('empty')
    

.. cssclass:: files morse-section

Other sources of examples
+++++++++++++++++++++++++

- `Source code <../../_modules/morse/sensors/gps.html>`_
- `Unit-test <../../_modules/base/gps_testing.html>`_




*(This page has been auto-generated from MORSE module morse.sensors.gps.)*
