..
 #############################################################
 # This file was automatically generated on 2015-05-08.      #
 #                                                           #
 # If you have a bugfix for this file and want to commit it, #
 # please fix the bug in the generator. You can find a link  #
 # to the generators git repository on tinkerforge.com       #
 #############################################################

:orphan:
:breadcrumbs: <a href="../../index.html">Home</a> / <a href="../../index.html#software-tcpip">Software</a> / TCP/IP - Laser Range Finder Bricklet

.. |device_identifier_constant| unicode:: 0xA0
   :trim:

.. _laser_range_finder_bricklet_tcpip:

TCP/IP - Laser Range Finder Bricklet
====================================

.. note::
 This Bricklet is currently in the prototype stage and the software/hardware
 as well as the documentation is in an incomplete state.


This is the description of the :ref:`TCP/IP protocol <llproto_tcpip>` for the :ref:`Laser Range Finder Bricklet <laser_range_finder_bricklet>`. General information and technical
specifications for the Laser Range Finder Bricklet are summarized in its :ref:`hardware description
<laser_range_finder_bricklet_description>`.

.. _laser_range_finder_bricklet_tcpip_api:

API
---

A general description of the TCP/IP protocol structure can be found
:ref:`here <llproto_tcpip>`.




Basic Functions
^^^^^^^^^^^^^^^



.. tcpip:function:: BrickletLaserRangeFinder.get_distance

 :functionid: 1
 :emptyrequest: empty payload

 :response distance: uint16

 Returns the measured distance. The value has a range of 0 to 4000
 and is given in cm.
 
 The Laser Range Finder Bricklet knows different modes. Distances
 are only measured in the distance measurement mode,
 see :tcpip:func:`set_mode <BrickletLaserRangeFinder.set_mode>`. Also the laser has to be enabled, see
 :tcpip:func:`enable_laser <BrickletLaserRangeFinder.enable_laser>`.
 
 If you want to get the distance periodically, it is recommended to
 use the callback :tcpip:func:`CALLBACK_DISTANCE <BrickletLaserRangeFinder.CALLBACK_DISTANCE>` and set the period with 
 :tcpip:func:`set_distance_callback_period <BrickletLaserRangeFinder.set_distance_callback_period>`.
 
.. tcpip:function:: BrickletLaserRangeFinder.get_velocity

 :functionid: 2
 :emptyrequest: empty payload

 :response velocity: int16

 Returns the measured velocity. The value has a range of 0 to 12700
 and is given in 1/100 m/s.
 
 The Laser Range Finder Bricklet knows different modes. Velocity 
 is only measured in the velocity measurement modes, 
 see :tcpip:func:`set_mode <BrickletLaserRangeFinder.set_mode>`. Also the laser has to be enabled, see
 :tcpip:func:`enable_laser <BrickletLaserRangeFinder.enable_laser>`.
 
 If you want to get the velocity periodically, it is recommended to
 use the callback :tcpip:func:`CALLBACK_VELOCITY <BrickletLaserRangeFinder.CALLBACK_VELOCITY>` and set the period with 
 :tcpip:func:`set_velocity_callback_period <BrickletLaserRangeFinder.set_velocity_callback_period>`.
 
.. tcpip:function:: BrickletLaserRangeFinder.set_mode

 :functionid: 15
 :request mode: uint8

 :noresponse: no response

 The LIDAR has five different modes. One mode is for distance
 measurements and four modes are for velocity measurements with
 different ranges.
 
 The following modes are available:
 
 * 0: Distance is measured with resolution 1.0 cm and range 0-400 cm
 * 1: Velocity is measured with resolution 0.1 m/s and range is 0-12.7 m/s
 * 2: Velocity is measured with resolution 0.25 m/s and range is 0-31.75 m/s
 * 3: Velocity is measured with resolution 0.5 m/s and range is 0-63.5 m/s
 * 4: Velocity is measured with resolution 1.0 m/s and range is 0-127 m/s
 
 The default mode is 0 (distance is measured).
 
.. tcpip:function:: BrickletLaserRangeFinder.get_mode

 :functionid: 16
 :emptyrequest: empty payload

 :response mode: uint8

 Returns the mode as set by :tcpip:func:`set_mode <BrickletLaserRangeFinder.set_mode>`.
 
.. tcpip:function:: BrickletLaserRangeFinder.enable_laser

 :functionid: 17
 :emptyrequest: empty payload

 :noresponse: no response

 Activates the laser of the LIDAR.
 
 We recommend that you wait 250ms after enabling the laser before
 the first call of :tcpip:func:`get_distance <BrickletLaserRangeFinder.get_distance>` to ensure stable measurements.
 
.. tcpip:function:: BrickletLaserRangeFinder.disable_laser

 :functionid: 18
 :emptyrequest: empty payload

 :noresponse: no response

 Deactivates the laser of the LIDAR.
 
.. tcpip:function:: BrickletLaserRangeFinder.is_laser_enabled

 :functionid: 19
 :emptyrequest: empty payload

 :response laser_enabled: bool

 Returns *true* if the laser is enabled, *false* otherwise.
 


Advanced Functions
^^^^^^^^^^^^^^^^^^

.. tcpip:function:: BrickletLaserRangeFinder.set_moving_average

 :functionid: 13
 :request distance_average_length: uint8
 :request velocity_average_length: uint8

 :noresponse: no response

 Sets the length of a `moving averaging <http://en.wikipedia.org/wiki/Moving_average>`__ 
 for the distance and velocity.
 
 Setting the length to 0 will turn the averaging completely off. With less
 averaging, there is more noise on the data.
 
 The range for the averaging is 0-30.
 
 The default value is 10.
 
.. tcpip:function:: BrickletLaserRangeFinder.get_moving_average

 :functionid: 14
 :emptyrequest: empty payload

 :response distance_average_length: uint8
 :response velocity_average_length: uint8

 Returns the length moving average as set by :tcpip:func:`set_moving_average <BrickletLaserRangeFinder.set_moving_average>`.
 
.. tcpip:function:: BrickletLaserRangeFinder.get_identity

 :functionid: 255
 :emptyrequest: empty payload

 :response uid: char[8]
 :response connected_uid: char[8]
 :response position: char
 :response hardware_version: uint8[3]
 :response firmware_version: uint8[3]
 :response device_identifier: uint16

 Returns the UID, the UID where the Bricklet is connected to, 
 the position, the hardware and firmware version as well as the
 device identifier.
 
 The position can be 'a', 'b', 'c' or 'd'.
 
 The device identifier numbers can be found :ref:`here <device_identifier>`.
 |device_identifier_constant|
 


Callback Configuration Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



.. tcpip:function:: BrickletLaserRangeFinder.set_distance_callback_period

 :functionid: 3
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_DISTANCE <BrickletLaserRangeFinder.CALLBACK_DISTANCE>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :tcpip:func:`CALLBACK_DISTANCE <BrickletLaserRangeFinder.CALLBACK_DISTANCE>` is only triggered if the distance value has changed since the
 last triggering.
 
 The default value is 0.
 
.. tcpip:function:: BrickletLaserRangeFinder.get_distance_callback_period

 :functionid: 4
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_distance_callback_period <BrickletLaserRangeFinder.set_distance_callback_period>`.
 
.. tcpip:function:: BrickletLaserRangeFinder.set_velocity_callback_period

 :functionid: 5
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_VELOCITY <BrickletLaserRangeFinder.CALLBACK_VELOCITY>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :tcpip:func:`CALLBACK_VELOCITY <BrickletLaserRangeFinder.CALLBACK_VELOCITY>` is only triggered if the velocity value has changed since the
 last triggering.
 
 The default value is 0.
 
.. tcpip:function:: BrickletLaserRangeFinder.get_velocity_callback_period

 :functionid: 6
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_velocity_callback_period <BrickletLaserRangeFinder.set_velocity_callback_period>`.
 
.. tcpip:function:: BrickletLaserRangeFinder.set_distance_callback_threshold

 :functionid: 7
 :request option: char
 :request min: uint16
 :request max: uint16

 :noresponse: no response

 Sets the thresholds for the :tcpip:func:`CALLBACK_DISTANCE_REACHED <BrickletLaserRangeFinder.CALLBACK_DISTANCE_REACHED>` callback. 
 
 The following options are possible:
 
 .. csv-table::
  :header: "Option", "Description"
  :widths: 10, 100
 
  "'x'",    "Callback is turned off"
  "'o'",    "Callback is triggered when the distance value is *outside* the min and max values"
  "'i'",    "Callback is triggered when the distance value is *inside* the min and max values"
  "'<'",    "Callback is triggered when the distance value is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the distance value is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
.. tcpip:function:: BrickletLaserRangeFinder.get_distance_callback_threshold

 :functionid: 8
 :emptyrequest: empty payload

 :response option: char
 :response min: uint16
 :response max: uint16

 Returns the threshold as set by :tcpip:func:`set_distance_callback_threshold <BrickletLaserRangeFinder.set_distance_callback_threshold>`.
 
.. tcpip:function:: BrickletLaserRangeFinder.set_velocity_callback_threshold

 :functionid: 9
 :request option: char
 :request min: int16
 :request max: int16

 :noresponse: no response

 Sets the thresholds for the :tcpip:func:`CALLBACK_VELOCITY_REACHED <BrickletLaserRangeFinder.CALLBACK_VELOCITY_REACHED>` callback. 
 
 The following options are possible:
 
 .. csv-table::
  :header: "Option", "Description"
  :widths: 10, 100
 
  "'x'",    "Callback is turned off"
  "'o'",    "Callback is triggered when the velocity is *outside* the min and max values"
  "'i'",    "Callback is triggered when the velocity is *inside* the min and max values"
  "'<'",    "Callback is triggered when the velocity is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the velocity is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
.. tcpip:function:: BrickletLaserRangeFinder.get_velocity_callback_threshold

 :functionid: 10
 :emptyrequest: empty payload

 :response option: char
 :response min: int16
 :response max: int16

 Returns the threshold as set by :tcpip:func:`set_velocity_callback_threshold <BrickletLaserRangeFinder.set_velocity_callback_threshold>`.
 
.. tcpip:function:: BrickletLaserRangeFinder.set_debounce_period

 :functionid: 11
 :request debounce: uint32

 :noresponse: no response

 Sets the period in ms with which the threshold callbacks
 
 * :tcpip:func:`CALLBACK_DISTANCE_REACHED <BrickletLaserRangeFinder.CALLBACK_DISTANCE_REACHED>`,
 * :tcpip:func:`CALLBACK_VELOCITY_REACHED <BrickletLaserRangeFinder.CALLBACK_VELOCITY_REACHED>`,
 
 are triggered, if the thresholds
 
 * :tcpip:func:`set_distance_callback_threshold <BrickletLaserRangeFinder.set_distance_callback_threshold>`,
 * :tcpip:func:`set_velocity_callback_threshold <BrickletLaserRangeFinder.set_velocity_callback_threshold>`,
 
 keep being reached.
 
 The default value is 100.
 
.. tcpip:function:: BrickletLaserRangeFinder.get_debounce_period

 :functionid: 12
 :emptyrequest: empty payload

 :response debounce: uint32

 Returns the debounce period as set by :tcpip:func:`set_debounce_period <BrickletLaserRangeFinder.set_debounce_period>`.
 


.. _laser_range_finder_bricklet_tcpip_callbacks:

Callbacks
^^^^^^^^^

.. tcpip:function:: BrickletLaserRangeFinder.CALLBACK_DISTANCE

 :functionid: 20

 :response distance: uint16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_distance_callback_period <BrickletLaserRangeFinder.set_distance_callback_period>`. The response value is the distance value
 of the sensor.
 
 :tcpip:func:`CALLBACK_DISTANCE <BrickletLaserRangeFinder.CALLBACK_DISTANCE>` is only triggered if the distance value has changed since the
 last triggering.
 
.. tcpip:function:: BrickletLaserRangeFinder.CALLBACK_VELOCITY

 :functionid: 21

 :response velocity: int16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_velocity_callback_period <BrickletLaserRangeFinder.set_velocity_callback_period>`. The response value is the velocity value
 of the sensor.
 
 :tcpip:func:`CALLBACK_VELOCITY <BrickletLaserRangeFinder.CALLBACK_VELOCITY>` is only triggered if the velocity has changed since the
 last triggering.
 
.. tcpip:function:: BrickletLaserRangeFinder.CALLBACK_DISTANCE_REACHED

 :functionid: 22

 :response distance: uint16


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_distance_callback_threshold <BrickletLaserRangeFinder.set_distance_callback_threshold>` is reached.
 The response value is the distance value of the sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :tcpip:func:`set_debounce_period <BrickletLaserRangeFinder.set_debounce_period>`.
 
.. tcpip:function:: BrickletLaserRangeFinder.CALLBACK_VELOCITY_REACHED

 :functionid: 23

 :response velocity: int16


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_velocity_callback_threshold <BrickletLaserRangeFinder.set_velocity_callback_threshold>` is reached.
 The response value is the velocity value of the sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :tcpip:func:`set_debounce_period <BrickletLaserRangeFinder.set_debounce_period>`.
 


