TCP/IP - Laser Range Finder Bricklet – Tinkerforge

- Getting Started
- Hardware
- Software
- Starter Kits
- Embedded Boards
- Specifications

# 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 TCP/IP protocol for the Laser Range Finder Bricklet. General information and technical specifications for the Laser Range Finder Bricklet are summarized in its hardware description.

## API

A general description of the TCP/IP protocol structure can be found here.

### Basic Functions

`BrickletLaserRangeFinder.``get_distance`

  Function ID: | 1
  Request: | 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 `set_mode`. Also the laser has to be enabled, see `enable_laser`.

  If you want to get the distance periodically, it is recommended to use the callback `CALLBACK_DISTANCE` and set the period with `set_distance_callback_period`.

`BrickletLaserRangeFinder.``get_velocity`

  Function ID: | 2
  Request: | 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 `set_mode`. Also the laser has to be enabled, see `enable_laser`.

  If you want to get the velocity periodically, it is recommended to use the callback `CALLBACK_VELOCITY` and set the period with `set_velocity_callback_period`.

`BrickletLaserRangeFinder.``set_mode`

  Function ID: | 15

  Request:

  - mode -- uint8

  Response: | 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).

`BrickletLaserRangeFinder.``get_mode`

  Function ID: | 16
  Request: | empty payload

  Response:

  - mode -- uint8

  Returns the mode as set by `set_mode`.

`BrickletLaserRangeFinder.``enable_laser`

  Function ID: | 17
  Request: | empty payload
  Response: | no response

  Activates the laser of the LIDAR.

  We recommend that you wait 250ms after enabling the laser before the first call of `get_distance` to ensure stable measurements.

`BrickletLaserRangeFinder.``disable_laser`

  Function ID: | 18
  Request: | empty payload
  Response: | no response

  Deactivates the laser of the LIDAR.

`BrickletLaserRangeFinder.``is_laser_enabled`

  Function ID: | 19
  Request: | empty payload

  Response:

  - laser_enabled -- bool

  Returns true if the laser is enabled, false otherwise.

### Advanced Functions

`BrickletLaserRangeFinder.``set_moving_average`

  Function ID: | 13

  Request:

  - distance_average_length -- uint8
  - velocity_average_length -- uint8

  Response: | no response

  Sets the length of a moving averaging 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.

`BrickletLaserRangeFinder.``get_moving_average`

  Function ID: | 14
  Request: | empty payload

  Response:

  - distance_average_length -- uint8
  - velocity_average_length -- uint8

  Returns the length moving average as set by `set_moving_average`.

`BrickletLaserRangeFinder.``get_identity`

  Function ID: | 255
  Request: | empty payload

  Response:

  - uid -- char[8]
  - connected_uid -- char[8]
  - position -- char
  - hardware_version -- uint8[3]
  - firmware_version -- uint8[3]
  - 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 here.

### Callback Configuration Functions

`BrickletLaserRangeFinder.``set_distance_callback_period`

  Function ID: | 3

  Request:

  - period -- uint32

  Response: | no response

  Sets the period in ms with which the `CALLBACK_DISTANCE` callback is triggered periodically. A value of 0 turns the callback off.

  `CALLBACK_DISTANCE` is only triggered if the distance value has changed since the last triggering.

  The default value is 0.

`BrickletLaserRangeFinder.``get_distance_callback_period`

  Function ID: | 4
  Request: | empty payload

  Response:

  - period -- uint32

  Returns the period as set by `set_distance_callback_period`.

`BrickletLaserRangeFinder.``set_velocity_callback_period`

  Function ID: | 5

  Request:

  - period -- uint32

  Response: | no response

  Sets the period in ms with which the `CALLBACK_VELOCITY` callback is triggered periodically. A value of 0 turns the callback off.

  `CALLBACK_VELOCITY` is only triggered if the velocity value has changed since the last triggering.

  The default value is 0.

`BrickletLaserRangeFinder.``get_velocity_callback_period`

  Function ID: | 6
  Request: | empty payload

  Response:

  - period -- uint32

  Returns the period as set by `set_velocity_callback_period`.

`BrickletLaserRangeFinder.``set_distance_callback_threshold`

  Function ID: | 7

  Request:

  - option -- char
  - min -- uint16
  - max -- uint16

  Response: | no response

  Sets the thresholds for the `CALLBACK_DISTANCE_REACHED` callback.

  The following options are possible:

  Option | Description
  --- | ---
  '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).

`BrickletLaserRangeFinder.``get_distance_callback_threshold`

  Function ID: | 8
  Request: | empty payload

  Response:

  - option -- char
  - min -- uint16
  - max -- uint16

  Returns the threshold as set by `set_distance_callback_threshold`.

`BrickletLaserRangeFinder.``set_velocity_callback_threshold`

  Function ID: | 9

  Request:

  - option -- char
  - min -- int16
  - max -- int16

  Response: | no response

  Sets the thresholds for the `CALLBACK_VELOCITY_REACHED` callback.

  The following options are possible:

  Option | Description
  --- | ---
  '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).

`BrickletLaserRangeFinder.``get_velocity_callback_threshold`

  Function ID: | 10
  Request: | empty payload

  Response:

  - option -- char
  - min -- int16
  - max -- int16

  Returns the threshold as set by `set_velocity_callback_threshold`.

`BrickletLaserRangeFinder.``set_debounce_period`

  Function ID: | 11

  Request:

  - debounce -- uint32

  Response: | no response

  Sets the period in ms with which the threshold callbacks

  - `CALLBACK_DISTANCE_REACHED`,
  - `CALLBACK_VELOCITY_REACHED`,

  are triggered, if the thresholds

  - `set_distance_callback_threshold`,
  - `set_velocity_callback_threshold`,

  keep being reached.

  The default value is 100.

`BrickletLaserRangeFinder.``get_debounce_period`

  Function ID: | 12
  Request: | empty payload

  Response:

  - debounce -- uint32

  Returns the debounce period as set by `set_debounce_period`.

### Callbacks

`BrickletLaserRangeFinder.``CALLBACK_DISTANCE`

  Function ID: | 20

  Response:

  - distance -- uint16

  This callback is triggered periodically with the period that is set by `set_distance_callback_period`. The response value is the distance value of the sensor.

  `CALLBACK_DISTANCE` is only triggered if the distance value has changed since the last triggering.

`BrickletLaserRangeFinder.``CALLBACK_VELOCITY`

  Function ID: | 21

  Response:

  - velocity -- int16

  This callback is triggered periodically with the period that is set by `set_velocity_callback_period`. The response value is the velocity value of the sensor.

  `CALLBACK_VELOCITY` is only triggered if the velocity has changed since the last triggering.

`BrickletLaserRangeFinder.``CALLBACK_DISTANCE_REACHED`

  Function ID: | 22

  Response:

  - distance -- uint16

  This callback is triggered when the threshold as set by `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 `set_debounce_period`.

`BrickletLaserRangeFinder.``CALLBACK_VELOCITY_REACHED`

  Function ID: | 23

  Response:

  - velocity -- int16

  This callback is triggered when the threshold as set by `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 `set_debounce_period`.

The content of this page is licensed under Creative Commons Attribution 3.0 Unported License.