..
 #############################################################
 # 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 - IMU Brick 2.0

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

.. _imu_v2_brick_tcpip:

TCP/IP - IMU Brick 2.0
======================

.. note::
 This Brick 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:`IMU Brick 2.0 <imu_v2_brick>`. General information and technical
specifications for the IMU Brick 2.0 are summarized in its :ref:`hardware description
<imu_v2_brick_description>`.

.. _imu_v2_brick_tcpip_api:

API
---

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




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



.. tcpip:function:: BrickIMUV2.get_all_data

 :functionid: 9
 :emptyrequest: empty payload

 :response acceleration: int16[3]
 :response magnetic_field: int16[3]
 :response angular_velocity: int16[3]
 :response euler_angle: int16[3]
 :response quaternion: int16[4]
 :response linear_acceleration: int16[3]
 :response gravity_vector: int16[3]
 :response temperature: int8
 :response calibration_status: uint8

 Return all of the available data of the IMU Brick.
 
 * acceleration in 1/100 m/s² (see :tcpip:func:`get_acceleration <BrickIMUV2.get_acceleration>`)
 * magnetic field in 1/16 µT (see :tcpip:func:`get_magnetic_field <BrickIMUV2.get_magnetic_field>`)
 * angular velocity in 1/16 °/s (see :tcpip:func:`get_angular_velocity <BrickIMUV2.get_angular_velocity>`)
 * Euler angles in 1/16 ° (see :tcpip:func:`get_orientation <BrickIMUV2.get_orientation>`)
 * quaternion 1/16383 (see :tcpip:func:`get_quaternion <BrickIMUV2.get_quaternion>`)
 * linear acceleration 1/100 m/s² (see :tcpip:func:`get_linear_acceleration <BrickIMUV2.get_linear_acceleration>`)
 * gravity vector 1/100 m/s² (see :tcpip:func:`get_gravity_vector <BrickIMUV2.get_gravity_vector>`)
 * temperature in 1 °C (see :tcpip:func:`get_temperature <BrickIMUV2.get_temperature>`)
 * calibration status (see below)
 
 The calibration status consists of four pairs of two bits. Each pair
 of bits represents the status of the current calibration.
 
 * bit 0-1: Magnetometer
 * bit 2-3: Accelerometer
 * bit 4-5: Gyroscope
 * bit 6-7: System
 
 A value of 0 means for "not calibrated" and a value of 3 means
 "fully calibrated". In your program you should always be able to
 ignore the calibration status, it is used by the calibration
 window of the Brick Viewer and it can be ignored after the first
 calibration. See the documentation in the calibration window for
 more information regarding the calibration of the IMU Brick.
 
 If you want to get the data periodically, it is recommended 
 to use the callback :tcpip:func:`CALLBACK_ALL_DATA <BrickIMUV2.CALLBACK_ALL_DATA>` and set the period with 
 :tcpip:func:`set_all_data_period <BrickIMUV2.set_all_data_period>`.
 
.. tcpip:function:: BrickIMUV2.leds_on

 :functionid: 10
 :emptyrequest: empty payload

 :noresponse: no response

 Turns the orientation and direction LEDs of the IMU Brick on.
 
.. tcpip:function:: BrickIMUV2.leds_off

 :functionid: 11
 :emptyrequest: empty payload

 :noresponse: no response

 Turns the orientation and direction LEDs of the IMU Brick off.
 
.. tcpip:function:: BrickIMUV2.are_leds_on

 :functionid: 12
 :emptyrequest: empty payload

 :response leds: bool

 Returns *true* if the orientation and direction LEDs of the IMU Brick
 are on, *false* otherwise.
 


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

.. tcpip:function:: BrickIMUV2.get_acceleration

 :functionid: 1
 :emptyrequest: empty payload

 :response x: int16
 :response y: int16
 :response z: int16
 
 Returns the calibrated acceleration from the accelerometer for the 
 x, y and z axis in 1/100 m/s².
 
 If you want to get the acceleration periodically, it is recommended 
 to use the callback :tcpip:func:`CALLBACK_ACCELERATION <BrickIMUV2.CALLBACK_ACCELERATION>` and set the period with 
 :tcpip:func:`set_acceleration_period <BrickIMUV2.set_acceleration_period>`.
 
.. tcpip:function:: BrickIMUV2.get_magnetic_field

 :functionid: 2
 :emptyrequest: empty payload

 :response x: int16
 :response y: int16
 :response z: int16

 Returns the calibrated magnetic field from the magnetometer for the 
 x, y and z axis in 1/16 µT (Microtesla).
 
 If you want to get the magnetic field periodically, it is recommended 
 to use the callback :tcpip:func:`CALLBACK_MAGNETIC_FIELD <BrickIMUV2.CALLBACK_MAGNETIC_FIELD>` and set the period with 
 :tcpip:func:`set_magnetic_field_period <BrickIMUV2.set_magnetic_field_period>`.
 
.. tcpip:function:: BrickIMUV2.get_angular_velocity

 :functionid: 3
 :emptyrequest: empty payload

 :response x: int16
 :response y: int16
 :response z: int16

 Returns the calibrated angular velocity from the gyroscope for the 
 x, y and z axis in 1/16 °/s.
 
 If you want to get the angular velocity periodically, it is recommended 
 to use the callback :tcpip:func:`CALLBACK_ANGULAR_VELOCITY <BrickIMUV2.CALLBACK_ANGULAR_VELOCITY>` and set the period with 
 :tcpip:func:`set_angular_velocity_period <BrickIMUV2.set_angular_velocity_period>`.
 
.. tcpip:function:: BrickIMUV2.get_temperature

 :functionid: 4
 :emptyrequest: empty payload

 :response temperature: int8

 Returns the temperature of the IMU Brick. The temperature is given in 
 °C. The temperature is measured in the core of the BNO055 IC, it is not the
 ambient temperature
 
.. tcpip:function:: BrickIMUV2.get_orientation

 :functionid: 5
 :emptyrequest: empty payload

 :response heading: int16
 :response roll: int16
 :response pitch: int16

 Returns the current orientation (heading, roll, pitch) of the IMU Brick as Euler
 angles in 1/16 degree. Note that Euler angles always experience a
 `gimbal lock <http://en.wikipedia.org/wiki/Gimbal_lock>`__.
 
 We recommend that you use quaternions instead.
 
 The rotation angle has the following ranges:
 
 * heading: 0° to 360°
 * roll: -90° to +90°
 * pitch: -180° to +180°
 
 If you want to get the orientation periodically, it is recommended 
 to use the callback :tcpip:func:`CALLBACK_ORIENTATION <BrickIMUV2.CALLBACK_ORIENTATION>` and set the period with 
 :tcpip:func:`set_orientation_period <BrickIMUV2.set_orientation_period>`.
 
.. tcpip:function:: BrickIMUV2.get_linear_acceleration

 :functionid: 6
 :emptyrequest: empty payload

 :response x: int16
 :response y: int16
 :response z: int16

 Returns the linear acceleration of the IMU Brick for the
 x, y and z axis in 1/100 m/s².
 
 The linear acceleration is the acceleration in each of the three
 axis of the IMU Brick with the influences of gravity removed.
 
 It is also possible to get the gravity vector with the influence of linear
 acceleration removed, see :tcpip:func:`get_gravity_vector <BrickIMUV2.get_gravity_vector>`.
 
 If you want to get the linear acceleration periodically, it is recommended 
 to use the callback :tcpip:func:`CALLBACK_LINEAR_ACCELERATION <BrickIMUV2.CALLBACK_LINEAR_ACCELERATION>` and set the period with 
 :tcpip:func:`set_linear_acceleration_period <BrickIMUV2.set_linear_acceleration_period>`.
 
.. tcpip:function:: BrickIMUV2.get_gravity_vector

 :functionid: 7
 :emptyrequest: empty payload

 :response x: int16
 :response y: int16
 :response z: int16

 Returns the current gravity vector of the IMU Brick for the
 x, y and z axis in 1/100 m/s².
 
 The gravity vector is the acceleration that occurs due to gravity.
 Influences of additional linear acceleration are removed.
 
 It is also possible to get the linear acceleration with the influence 
 of gravity removed, see :tcpip:func:`get_linear_acceleration <BrickIMUV2.get_linear_acceleration>`.
 
 If you want to get the gravity vector periodically, it is recommended 
 to use the callback :tcpip:func:`CALLBACK_GRAVITY_VECTOR <BrickIMUV2.CALLBACK_GRAVITY_VECTOR>` and set the period with 
 :tcpip:func:`set_gravity_vector_period <BrickIMUV2.set_gravity_vector_period>`.
 
.. tcpip:function:: BrickIMUV2.get_quaternion

 :functionid: 8
 :emptyrequest: empty payload

 :response w: int16
 :response x: int16
 :response y: int16
 :response z: int16

 Returns the current orientation (w, x, y, z) of the IMU Brick as
 `quaternions <http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation>`__.
 
 You have to divide the returns values by 16383 (14 bit) to get
 the usual range of -1.0 to +1.0 for quaternions.
 
 If you want to get the quaternions periodically, it is recommended 
 to use the callback :tcpip:func:`CALLBACK_QUATERNION <BrickIMUV2.CALLBACK_QUATERNION>` and set the period with 
 :tcpip:func:`set_quaternion_period <BrickIMUV2.set_quaternion_period>`.
 
.. tcpip:function:: BrickIMUV2.save_calibration

 :functionid: 13
 :emptyrequest: empty payload

 :response calibration_done: bool

 A call of this function saves the current calibration to be used
 as a starting point for the next restart of continuous calibration
 of the IMU Brick.
 
 A return value of *true* means that the calibration could be used and
 *false* means that it could not be used (this happens if the calibration 
 status is not "fully calibrated").
 
 This function is used by the calibration window of the Brick Viewer, you
 should not need to call it in your program.
 
.. tcpip:function:: BrickIMUV2.enable_status_led

 :functionid: 238
 :emptyrequest: empty payload

 :noresponse: no response

 Enables the status LED.
 
 The status LED is the blue LED next to the USB connector. If enabled is is
 on and it flickers if data is transfered. If disabled it is always off.
 
 The default state is enabled.
 
.. tcpip:function:: BrickIMUV2.disable_status_led

 :functionid: 239
 :emptyrequest: empty payload

 :noresponse: no response

 Disables the status LED.
 
 The status LED is the blue LED next to the USB connector. If enabled is is
 on and it flickers if data is transfered. If disabled it is always off.
 
 The default state is enabled.
 
.. tcpip:function:: BrickIMUV2.is_status_led_enabled

 :functionid: 240
 :emptyrequest: empty payload

 :response enabled: bool

 Returns *true* if the status LED is enabled, *false* otherwise.
 
.. tcpip:function:: BrickIMUV2.get_protocol1_bricklet_name

 :functionid: 241
 :request port: char

 :response protocol_version: uint8
 :response firmware_version: uint8[3]
 :response name: char[40]

 Returns the firmware and protocol version and the name of the Bricklet for a
 given port.
 
 This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet
 plugins.
 
.. tcpip:function:: BrickIMUV2.get_chip_temperature

 :functionid: 242
 :emptyrequest: empty payload

 :response temperature: int16

 Returns the temperature in °C/10 as measured inside the microcontroller. The
 value returned is not the ambient temperature!
 
 The temperature is only proportional to the real temperature and it has an
 accuracy of +-15%. Practically it is only useful as an indicator for
 temperature changes.
 
.. tcpip:function:: BrickIMUV2.reset

 :functionid: 243
 :emptyrequest: empty payload

 :noresponse: no response

 Calling this function will reset the Brick. Calling this function
 on a Brick inside of a stack will reset the whole stack.
 
 After a reset you have to create new device objects,
 calling functions on the existing ones will result in
 undefined behavior!
 
.. tcpip:function:: BrickIMUV2.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 Brick is connected to, 
 the position, the hardware and firmware version as well as the
 device identifier.
 
 The position can be '0'-'8' (stack position).
 
 The device identifier numbers can be found :ref:`here <device_identifier>`.
 |device_identifier_constant|
 


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



.. tcpip:function:: BrickIMUV2.set_acceleration_period

 :functionid: 14
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_ACCELERATION <BrickIMUV2.CALLBACK_ACCELERATION>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 The default value is 0.
 
.. tcpip:function:: BrickIMUV2.get_acceleration_period

 :functionid: 15
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_acceleration_period <BrickIMUV2.set_acceleration_period>`.
 
.. tcpip:function:: BrickIMUV2.set_magnetic_field_period

 :functionid: 16
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_MAGNETIC_FIELD <BrickIMUV2.CALLBACK_MAGNETIC_FIELD>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
.. tcpip:function:: BrickIMUV2.get_magnetic_field_period

 :functionid: 17
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_magnetic_field_period <BrickIMUV2.set_magnetic_field_period>`.
 
.. tcpip:function:: BrickIMUV2.set_angular_velocity_period

 :functionid: 18
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_ANGULAR_VELOCITY <BrickIMUV2.CALLBACK_ANGULAR_VELOCITY>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
.. tcpip:function:: BrickIMUV2.get_angular_velocity_period

 :functionid: 19
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_angular_velocity_period <BrickIMUV2.set_angular_velocity_period>`.
 
.. tcpip:function:: BrickIMUV2.set_temperature_period

 :functionid: 20
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_TEMPERATURE <BrickIMUV2.CALLBACK_TEMPERATURE>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
.. tcpip:function:: BrickIMUV2.get_temperature_period

 :functionid: 21
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_temperature_period <BrickIMUV2.set_temperature_period>`.
 
.. tcpip:function:: BrickIMUV2.set_orientation_period

 :functionid: 22
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_ORIENTATION <BrickIMUV2.CALLBACK_ORIENTATION>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
.. tcpip:function:: BrickIMUV2.get_orientation_period

 :functionid: 23
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_orientation_period <BrickIMUV2.set_orientation_period>`.
 
.. tcpip:function:: BrickIMUV2.set_linear_acceleration_period

 :functionid: 24
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_LINEAR_ACCELERATION <BrickIMUV2.CALLBACK_LINEAR_ACCELERATION>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
.. tcpip:function:: BrickIMUV2.get_linear_acceleration_period

 :functionid: 25
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_linear_acceleration_period <BrickIMUV2.set_linear_acceleration_period>`.
 
.. tcpip:function:: BrickIMUV2.set_gravity_vector_period

 :functionid: 26
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_GRAVITY_VECTOR <BrickIMUV2.CALLBACK_GRAVITY_VECTOR>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
.. tcpip:function:: BrickIMUV2.get_gravity_vector_period

 :functionid: 27
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_gravity_vector_period <BrickIMUV2.set_gravity_vector_period>`.
 
.. tcpip:function:: BrickIMUV2.set_quaternion_period

 :functionid: 28
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_QUATERNION <BrickIMUV2.CALLBACK_QUATERNION>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
.. tcpip:function:: BrickIMUV2.get_quaternion_period

 :functionid: 29
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_quaternion_period <BrickIMUV2.set_quaternion_period>`.
 
.. tcpip:function:: BrickIMUV2.set_all_data_period

 :functionid: 30
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_ALL_DATA <BrickIMUV2.CALLBACK_ALL_DATA>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
.. tcpip:function:: BrickIMUV2.get_all_data_period

 :functionid: 31
 :emptyrequest: empty payload

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_all_data_period <BrickIMUV2.set_all_data_period>`.
 


.. _imu_v2_brick_tcpip_callbacks:

Callbacks
^^^^^^^^^

.. tcpip:function:: BrickIMUV2.CALLBACK_ACCELERATION

 :functionid: 32

 :response x: int16
 :response y: int16
 :response z: int16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_acceleration_period <BrickIMUV2.set_acceleration_period>`. The response values are the acceleration
 for the x, y and z axis.
 
.. tcpip:function:: BrickIMUV2.CALLBACK_MAGNETIC_FIELD

 :functionid: 33

 :response x: int16
 :response y: int16
 :response z: int16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_magnetic_field_period <BrickIMUV2.set_magnetic_field_period>`. The response values are the magnetic field
 for the x, y and z axis.
 
.. tcpip:function:: BrickIMUV2.CALLBACK_ANGULAR_VELOCITY

 :functionid: 34

 :response x: int16
 :response y: int16
 :response z: int16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_angular_velocity_period <BrickIMUV2.set_angular_velocity_period>`. The response values are the angular velocity
 for the x, y and z axis.
 
.. tcpip:function:: BrickIMUV2.CALLBACK_TEMPERATURE

 :functionid: 35

 :response temperature: int8


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_temperature_period <BrickIMUV2.set_temperature_period>`. The response value is the temperature.
 
.. tcpip:function:: BrickIMUV2.CALLBACK_LINEAR_ACCELERATION

 :functionid: 36

 :response x: int16
 :response y: int16
 :response z: int16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_linear_acceleration_period <BrickIMUV2.set_linear_acceleration_period>`. The response values are the 
 linear acceleration for the x, y and z axis.
 
.. tcpip:function:: BrickIMUV2.CALLBACK_GRAVITY_VECTOR

 :functionid: 37

 :response x: int16
 :response y: int16
 :response z: int16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_gravity_vector_period <BrickIMUV2.set_gravity_vector_period>`. The response values gravity vector
 for the x, y and z axis.
 
.. tcpip:function:: BrickIMUV2.CALLBACK_ORIENTATION

 :functionid: 38

 :response heading: int16
 :response roll: int16
 :response pitch: int16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_orientation_period <BrickIMUV2.set_orientation_period>`. The response values are the orientation
 (heading (yaw), roll, pitch) of the IMU Brick in Euler angles. See
 :tcpip:func:`get_orientation <BrickIMUV2.get_orientation>` for details.
 
.. tcpip:function:: BrickIMUV2.CALLBACK_QUATERNION

 :functionid: 39

 :response w: int16
 :response x: int16
 :response y: int16
 :response z: int16


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_quaternion_period <BrickIMUV2.set_quaternion_period>`. The response values are the orientation
 (x, y, z, w) of the IMU Brick in quaternions. See :tcpip:func:`get_quaternion <BrickIMUV2.get_quaternion>`
 for details.
 
.. tcpip:function:: BrickIMUV2.CALLBACK_ALL_DATA

 :functionid: 40

 :response acceleration: int16[3]
 :response magnetic_field: int16[3]
 :response angular_velocity: int16[3]
 :response euler_angle: int16[3]
 :response quaternion: int16[4]
 :response linear_acceleration: int16[3]
 :response gravity_vector: int16[3]
 :response temperature: int8
 :response calibration_status: uint8


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_all_data_period <BrickIMUV2.set_all_data_period>`. The response values are as for :tcpip:func:`get_all_data <BrickIMUV2.get_all_data>`.
 


