Class: Tinkerforge::BrickIMUV2
- Defined in:
- lib/tinkerforge/brick_imu_v2.rb
Overview
Full fledged AHRS with 9 degrees of freedom
Constant Summary collapse
- DEVICE_IDENTIFIER =
:nodoc:
18- DEVICE_DISPLAY_NAME =
:nodoc:
'IMU Brick 2.0'- CALLBACK_ACCELERATION =
This callback is triggered periodically with the period that is set by BrickIMUV2#set_acceleration_period. The parameters are the acceleration for the x, y and z axis.
32- CALLBACK_MAGNETIC_FIELD =
This callback is triggered periodically with the period that is set by BrickIMUV2#set_magnetic_field_period. The parameters are the magnetic field for the x, y and z axis.
33- CALLBACK_ANGULAR_VELOCITY =
This callback is triggered periodically with the period that is set by BrickIMUV2#set_angular_velocity_period. The parameters are the angular velocity for the x, y and z axis.
34- CALLBACK_TEMPERATURE =
This callback is triggered periodically with the period that is set by BrickIMUV2#set_temperature_period. The parameter is the temperature.
35- CALLBACK_LINEAR_ACCELERATION =
This callback is triggered periodically with the period that is set by BrickIMUV2#set_linear_acceleration_period. The parameters are the linear acceleration for the x, y and z axis.
36- CALLBACK_GRAVITY_VECTOR =
This callback is triggered periodically with the period that is set by BrickIMUV2#set_gravity_vector_period. The parameters gravity vector for the x, y and z axis.
37- CALLBACK_ORIENTATION =
This callback is triggered periodically with the period that is set by BrickIMUV2#set_orientation_period. The parameters are the orientation (heading (yaw), roll, pitch) of the IMU Brick in Euler angles. See BrickIMUV2#get_orientation for details.
38- CALLBACK_QUATERNION =
This callback is triggered periodically with the period that is set by BrickIMUV2#set_quaternion_period. The parameters are the orientation (x, y, z, w) of the IMU Brick in quaternions. See BrickIMUV2#get_quaternion for details.
39- CALLBACK_ALL_DATA =
This callback is triggered periodically with the period that is set by BrickIMUV2#set_all_data_period. The parameters are as for BrickIMUV2#get_all_data.
40- FUNCTION_GET_ACCELERATION =
:nodoc:
1- FUNCTION_GET_MAGNETIC_FIELD =
:nodoc:
2- FUNCTION_GET_ANGULAR_VELOCITY =
:nodoc:
3- FUNCTION_GET_TEMPERATURE =
:nodoc:
4- FUNCTION_GET_ORIENTATION =
:nodoc:
5- FUNCTION_GET_LINEAR_ACCELERATION =
:nodoc:
6- FUNCTION_GET_GRAVITY_VECTOR =
:nodoc:
7- FUNCTION_GET_QUATERNION =
:nodoc:
8- FUNCTION_GET_ALL_DATA =
:nodoc:
9- FUNCTION_LEDS_ON =
:nodoc:
10- FUNCTION_LEDS_OFF =
:nodoc:
11- FUNCTION_ARE_LEDS_ON =
:nodoc:
12- FUNCTION_SAVE_CALIBRATION =
:nodoc:
13- FUNCTION_SET_ACCELERATION_PERIOD =
:nodoc:
14- FUNCTION_GET_ACCELERATION_PERIOD =
:nodoc:
15- FUNCTION_SET_MAGNETIC_FIELD_PERIOD =
:nodoc:
16- FUNCTION_GET_MAGNETIC_FIELD_PERIOD =
:nodoc:
17- FUNCTION_SET_ANGULAR_VELOCITY_PERIOD =
:nodoc:
18- FUNCTION_GET_ANGULAR_VELOCITY_PERIOD =
:nodoc:
19- FUNCTION_SET_TEMPERATURE_PERIOD =
:nodoc:
20- FUNCTION_GET_TEMPERATURE_PERIOD =
:nodoc:
21- FUNCTION_SET_ORIENTATION_PERIOD =
:nodoc:
22- FUNCTION_GET_ORIENTATION_PERIOD =
:nodoc:
23- FUNCTION_SET_LINEAR_ACCELERATION_PERIOD =
:nodoc:
24- FUNCTION_GET_LINEAR_ACCELERATION_PERIOD =
:nodoc:
25- FUNCTION_SET_GRAVITY_VECTOR_PERIOD =
:nodoc:
26- FUNCTION_GET_GRAVITY_VECTOR_PERIOD =
:nodoc:
27- FUNCTION_SET_QUATERNION_PERIOD =
:nodoc:
28- FUNCTION_GET_QUATERNION_PERIOD =
:nodoc:
29- FUNCTION_SET_ALL_DATA_PERIOD =
:nodoc:
30- FUNCTION_GET_ALL_DATA_PERIOD =
:nodoc:
31- FUNCTION_ENABLE_STATUS_LED =
:nodoc:
238- FUNCTION_DISABLE_STATUS_LED =
:nodoc:
239- FUNCTION_IS_STATUS_LED_ENABLED =
:nodoc:
240- FUNCTION_GET_PROTOCOL1_BRICKLET_NAME =
:nodoc:
241- FUNCTION_GET_CHIP_TEMPERATURE =
:nodoc:
242- FUNCTION_RESET =
:nodoc:
243- FUNCTION_GET_IDENTITY =
:nodoc:
255
Constants inherited from Device
Device::RESPONSE_EXPECTED_ALWAYS_FALSE, Device::RESPONSE_EXPECTED_ALWAYS_TRUE, Device::RESPONSE_EXPECTED_FALSE, Device::RESPONSE_EXPECTED_INVALID_FUNCTION_ID, Device::RESPONSE_EXPECTED_TRUE
Instance Attribute Summary
Attributes inherited from Device
#callback_formats, #expected_response_function_id, #expected_response_sequence_number, #registered_callbacks, #uid
Instance Method Summary collapse
-
#are_leds_on ⇒ Object
Returns true if the orientation and direction LEDs of the IMU Brick are on, false otherwise.
-
#disable_status_led ⇒ Object
Disables the status LED.
-
#enable_status_led ⇒ Object
Enables the status LED.
-
#get_acceleration ⇒ Object
Returns the calibrated acceleration from the accelerometer for the x, y and z axis in 1/100 m/s².
-
#get_acceleration_period ⇒ Object
Returns the period as set by BrickIMUV2#set_acceleration_period.
-
#get_all_data ⇒ Object
Return all of the available data of the IMU Brick.
-
#get_all_data_period ⇒ Object
Returns the period as set by BrickIMUV2#set_all_data_period.
-
#get_angular_velocity ⇒ Object
Returns the calibrated angular velocity from the gyroscope for the x, y and z axis in 1/16 °/s.
-
#get_angular_velocity_period ⇒ Object
Returns the period as set by BrickIMUV2#set_angular_velocity_period.
-
#get_chip_temperature ⇒ Object
Returns the temperature in °C/10 as measured inside the microcontroller.
-
#get_gravity_vector ⇒ Object
Returns the current gravity vector of the IMU Brick for the x, y and z axis in 1/100 m/s².
-
#get_gravity_vector_period ⇒ Object
Returns the period as set by BrickIMUV2#set_gravity_vector_period.
-
#get_identity ⇒ Object
Returns the UID, the UID where the Brick is connected to, the position, the hardware and firmware version as well as the device identifier.
-
#get_linear_acceleration ⇒ Object
Returns the linear acceleration of the IMU Brick for the x, y and z axis in 1/100 m/s².
-
#get_linear_acceleration_period ⇒ Object
Returns the period as set by BrickIMUV2#set_linear_acceleration_period.
-
#get_magnetic_field ⇒ Object
Returns the calibrated magnetic field from the magnetometer for the x, y and z axis in 1/16 µT (Microtesla).
-
#get_magnetic_field_period ⇒ Object
Returns the period as set by BrickIMUV2#set_magnetic_field_period.
-
#get_orientation ⇒ Object
Returns the current orientation (heading, roll, pitch) of the IMU Brick as independent Euler angles in 1/16 degree.
-
#get_orientation_period ⇒ Object
Returns the period as set by BrickIMUV2#set_orientation_period.
-
#get_protocol1_bricklet_name(port) ⇒ Object
Returns the firmware and protocol version and the name of the Bricklet for a given port.
-
#get_quaternion ⇒ Object
Returns the current orientation (w, x, y, z) of the IMU Brick as ‘quaternions <en.wikipedia.org/wiki/Quaternions_and_spatial_rotation>`__.
-
#get_quaternion_period ⇒ Object
Returns the period as set by BrickIMUV2#set_quaternion_period.
-
#get_temperature ⇒ Object
Returns the temperature of the IMU Brick.
-
#get_temperature_period ⇒ Object
Returns the period as set by BrickIMUV2#set_temperature_period.
-
#initialize(uid, ipcon) ⇒ BrickIMUV2
constructor
Creates an object with the unique device ID
uidand adds it to the IP Connectionipcon. -
#is_status_led_enabled ⇒ Object
Returns true if the status LED is enabled, false otherwise.
-
#leds_off ⇒ Object
Turns the orientation and direction LEDs of the IMU Brick off.
-
#leds_on ⇒ Object
Turns the orientation and direction LEDs of the IMU Brick on.
-
#register_callback(id, &block) ⇒ Object
Registers a callback with ID
idto the blockblock. -
#reset ⇒ Object
Calling this function will reset the Brick.
-
#save_calibration ⇒ Object
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.
-
#set_acceleration_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_ACCELERATION callback is triggered periodically.
-
#set_all_data_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_ALL_DATA callback is triggered periodically.
-
#set_angular_velocity_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_ANGULAR_VELOCITY callback is triggered periodically.
-
#set_gravity_vector_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_GRAVITY_VECTOR callback is triggered periodically.
-
#set_linear_acceleration_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_LINEAR_ACCELERATION callback is triggered periodically.
-
#set_magnetic_field_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_MAGNETIC_FIELD callback is triggered periodically.
-
#set_orientation_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_ORIENTATION callback is triggered periodically.
-
#set_quaternion_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_QUATERNION callback is triggered periodically.
-
#set_temperature_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_TEMPERATURE callback is triggered periodically.
Methods inherited from Device
#dequeue_response, #enqueue_response, #get_api_version, #get_response_expected, #send_request, #set_response_expected, #set_response_expected_all
Constructor Details
#initialize(uid, ipcon) ⇒ BrickIMUV2
Creates an object with the unique device ID uid and adds it to the IP Connection ipcon.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 105 def initialize(uid, ipcon) super uid, ipcon @api_version = [2, 0, 0] @response_expected[FUNCTION_GET_ACCELERATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_MAGNETIC_FIELD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_ANGULAR_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_ORIENTATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_LINEAR_ACCELERATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_GRAVITY_VECTOR] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_QUATERNION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_ALL_DATA] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_LEDS_ON] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_LEDS_OFF] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_ARE_LEDS_ON] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SAVE_CALIBRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_ACCELERATION_PERIOD] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_ACCELERATION_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_MAGNETIC_FIELD_PERIOD] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_MAGNETIC_FIELD_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_ANGULAR_VELOCITY_PERIOD] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_ANGULAR_VELOCITY_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_TEMPERATURE_PERIOD] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_TEMPERATURE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_ORIENTATION_PERIOD] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_ORIENTATION_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_LINEAR_ACCELERATION_PERIOD] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_LINEAR_ACCELERATION_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_GRAVITY_VECTOR_PERIOD] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_GRAVITY_VECTOR_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_QUATERNION_PERIOD] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_QUATERNION_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_ALL_DATA_PERIOD] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_ALL_DATA_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[CALLBACK_ACCELERATION] = RESPONSE_EXPECTED_ALWAYS_FALSE @response_expected[CALLBACK_MAGNETIC_FIELD] = RESPONSE_EXPECTED_ALWAYS_FALSE @response_expected[CALLBACK_ANGULAR_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_FALSE @response_expected[CALLBACK_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_FALSE @response_expected[CALLBACK_LINEAR_ACCELERATION] = RESPONSE_EXPECTED_ALWAYS_FALSE @response_expected[CALLBACK_GRAVITY_VECTOR] = RESPONSE_EXPECTED_ALWAYS_FALSE @response_expected[CALLBACK_ORIENTATION] = RESPONSE_EXPECTED_ALWAYS_FALSE @response_expected[CALLBACK_QUATERNION] = RESPONSE_EXPECTED_ALWAYS_FALSE @response_expected[CALLBACK_ALL_DATA] = RESPONSE_EXPECTED_ALWAYS_FALSE @response_expected[FUNCTION_ENABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_DISABLE_STATUS_LED] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_IS_STATUS_LED_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE @callback_formats[CALLBACK_ACCELERATION] = 's s s' @callback_formats[CALLBACK_MAGNETIC_FIELD] = 's s s' @callback_formats[CALLBACK_ANGULAR_VELOCITY] = 's s s' @callback_formats[CALLBACK_TEMPERATURE] = 'c' @callback_formats[CALLBACK_LINEAR_ACCELERATION] = 's s s' @callback_formats[CALLBACK_GRAVITY_VECTOR] = 's s s' @callback_formats[CALLBACK_ORIENTATION] = 's s s' @callback_formats[CALLBACK_QUATERNION] = 's s s s' @callback_formats[CALLBACK_ALL_DATA] = 's3 s3 s3 s3 s4 s3 s3 c C' end |
Instance Method Details
#are_leds_on ⇒ Object
Returns true if the orientation and direction LEDs of the IMU Brick are on, false otherwise.
315 316 317 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 315 def are_leds_on send_request(FUNCTION_ARE_LEDS_ON, [], '', 1, '?') end |
#disable_status_led ⇒ Object
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.
450 451 452 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 450 def disable_status_led send_request(FUNCTION_DISABLE_STATUS_LED, [], '', 0, '') end |
#enable_status_led ⇒ Object
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.
440 441 442 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 440 def enable_status_led send_request(FUNCTION_ENABLE_STATUS_LED, [], '', 0, '') end |
#get_acceleration ⇒ Object
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 CALLBACK_ACCELERATION and set the period with BrickIMUV2#set_acceleration_period.
175 176 177 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 175 def get_acceleration send_request(FUNCTION_GET_ACCELERATION, [], '', 6, 's s s') end |
#get_acceleration_period ⇒ Object
Returns the period as set by BrickIMUV2#set_acceleration_period.
342 343 344 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 342 def get_acceleration_period send_request(FUNCTION_GET_ACCELERATION_PERIOD, [], '', 4, 'L') end |
#get_all_data ⇒ Object
Return all of the available data of the IMU Brick.
-
acceleration in 1/100 m/s² (see BrickIMUV2#get_acceleration)
-
magnetic field in 1/16 µT (see BrickIMUV2#get_magnetic_field)
-
angular velocity in 1/16 °/s (see BrickIMUV2#get_angular_velocity)
-
Euler angles in 1/16 ° (see BrickIMUV2#get_orientation)
-
quaternion 1/16383 (see BrickIMUV2#get_quaternion)
-
linear acceleration 1/100 m/s² (see BrickIMUV2#get_linear_acceleration)
-
gravity vector 1/100 m/s² (see BrickIMUV2#get_gravity_vector)
-
temperature in 1 °C (see 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 CALLBACK_ALL_DATA and set the period with BrickIMUV2#set_all_data_period.
299 300 301 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 299 def get_all_data send_request(FUNCTION_GET_ALL_DATA, [], '', 46, 's3 s3 s3 s3 s4 s3 s3 c C') end |
#get_all_data_period ⇒ Object
Returns the period as set by BrickIMUV2#set_all_data_period.
430 431 432 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 430 def get_all_data_period send_request(FUNCTION_GET_ALL_DATA_PERIOD, [], '', 4, 'L') end |
#get_angular_velocity ⇒ Object
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 CALLBACK_ANGULAR_VELOCITY and set the period with BrickIMUV2#set_angular_velocity_period.
195 196 197 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 195 def get_angular_velocity send_request(FUNCTION_GET_ANGULAR_VELOCITY, [], '', 6, 's s s') end |
#get_angular_velocity_period ⇒ Object
Returns the period as set by BrickIMUV2#set_angular_velocity_period.
364 365 366 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 364 def get_angular_velocity_period send_request(FUNCTION_GET_ANGULAR_VELOCITY_PERIOD, [], '', 4, 'L') end |
#get_chip_temperature ⇒ Object
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.
474 475 476 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 474 def get_chip_temperature send_request(FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's') end |
#get_gravity_vector ⇒ Object
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 BrickIMUV2#get_linear_acceleration.
If you want to get the gravity vector periodically, it is recommended to use the callback CALLBACK_GRAVITY_VECTOR and set the period with BrickIMUV2#set_gravity_vector_period.
252 253 254 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 252 def get_gravity_vector send_request(FUNCTION_GET_GRAVITY_VECTOR, [], '', 6, 's s s') end |
#get_gravity_vector_period ⇒ Object
Returns the period as set by BrickIMUV2#set_gravity_vector_period.
408 409 410 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 408 def get_gravity_vector_period send_request(FUNCTION_GET_GRAVITY_VECTOR_PERIOD, [], '', 4, 'L') end |
#get_identity ⇒ Object
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|
496 497 498 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 496 def get_identity send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S') end |
#get_linear_acceleration ⇒ Object
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 BrickIMUV2#get_gravity_vector.
If you want to get the linear acceleration periodically, it is recommended to use the callback CALLBACK_LINEAR_ACCELERATION and set the period with BrickIMUV2#set_linear_acceleration_period.
236 237 238 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 236 def get_linear_acceleration send_request(FUNCTION_GET_LINEAR_ACCELERATION, [], '', 6, 's s s') end |
#get_linear_acceleration_period ⇒ Object
Returns the period as set by BrickIMUV2#set_linear_acceleration_period.
397 398 399 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 397 def get_linear_acceleration_period send_request(FUNCTION_GET_LINEAR_ACCELERATION_PERIOD, [], '', 4, 'L') end |
#get_magnetic_field ⇒ Object
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 CALLBACK_MAGNETIC_FIELD and set the period with BrickIMUV2#set_magnetic_field_period.
185 186 187 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 185 def get_magnetic_field send_request(FUNCTION_GET_MAGNETIC_FIELD, [], '', 6, 's s s') end |
#get_magnetic_field_period ⇒ Object
Returns the period as set by BrickIMUV2#set_magnetic_field_period.
353 354 355 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 353 def get_magnetic_field_period send_request(FUNCTION_GET_MAGNETIC_FIELD_PERIOD, [], '', 4, 'L') end |
#get_orientation ⇒ Object
Returns the current orientation (heading, roll, pitch) of the IMU Brick as independent Euler angles in 1/16 degree. Note that Euler angles always experience a ‘gimbal lock <en.wikipedia.org/wiki/Gimbal_lock>`__. We recommend that you use quaternions instead, if you need the absolute orientation.
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 CALLBACK_ORIENTATION and set the period with BrickIMUV2#set_orientation_period.
220 221 222 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 220 def get_orientation send_request(FUNCTION_GET_ORIENTATION, [], '', 6, 's s s') end |
#get_orientation_period ⇒ Object
Returns the period as set by BrickIMUV2#set_orientation_period.
386 387 388 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 386 def get_orientation_period send_request(FUNCTION_GET_ORIENTATION_PERIOD, [], '', 4, 'L') end |
#get_protocol1_bricklet_name(port) ⇒ Object
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.
464 465 466 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 464 def get_protocol1_bricklet_name(port) send_request(FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 44, 'C C3 Z40') end |
#get_quaternion ⇒ Object
Returns the current orientation (w, x, y, z) of the IMU Brick as ‘quaternions <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 CALLBACK_QUATERNION and set the period with BrickIMUV2#set_quaternion_period.
265 266 267 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 265 def get_quaternion send_request(FUNCTION_GET_QUATERNION, [], '', 8, 's s s s') end |
#get_quaternion_period ⇒ Object
Returns the period as set by BrickIMUV2#set_quaternion_period.
419 420 421 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 419 def get_quaternion_period send_request(FUNCTION_GET_QUATERNION_PERIOD, [], '', 4, 'L') end |
#get_temperature ⇒ Object
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
202 203 204 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 202 def get_temperature send_request(FUNCTION_GET_TEMPERATURE, [], '', 1, 'c') end |
#get_temperature_period ⇒ Object
Returns the period as set by BrickIMUV2#set_temperature_period.
375 376 377 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 375 def get_temperature_period send_request(FUNCTION_GET_TEMPERATURE_PERIOD, [], '', 4, 'L') end |
#is_status_led_enabled ⇒ Object
Returns true if the status LED is enabled, false otherwise.
455 456 457 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 455 def is_status_led_enabled send_request(FUNCTION_IS_STATUS_LED_ENABLED, [], '', 1, '?') end |
#leds_off ⇒ Object
Turns the orientation and direction LEDs of the IMU Brick off.
309 310 311 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 309 def leds_off send_request(FUNCTION_LEDS_OFF, [], '', 0, '') end |
#leds_on ⇒ Object
Turns the orientation and direction LEDs of the IMU Brick on.
304 305 306 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 304 def leds_on send_request(FUNCTION_LEDS_ON, [], '', 0, '') end |
#register_callback(id, &block) ⇒ Object
Registers a callback with ID id to the block block.
501 502 503 504 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 501 def register_callback(id, &block) callback = block @registered_callbacks[id] = callback end |
#reset ⇒ Object
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!
484 485 486 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 484 def reset send_request(FUNCTION_RESET, [], '', 0, '') end |
#save_calibration ⇒ Object
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.
329 330 331 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 329 def save_calibration send_request(FUNCTION_SAVE_CALIBRATION, [], '', 1, '?') end |
#set_acceleration_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_ACCELERATION callback is triggered periodically. A value of 0 turns the callback off.
The default value is 0.
337 338 339 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 337 def set_acceleration_period(period) send_request(FUNCTION_SET_ACCELERATION_PERIOD, [period], 'L', 0, '') end |
#set_all_data_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_ALL_DATA callback is triggered periodically. A value of 0 turns the callback off.
425 426 427 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 425 def set_all_data_period(period) send_request(FUNCTION_SET_ALL_DATA_PERIOD, [period], 'L', 0, '') end |
#set_angular_velocity_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_ANGULAR_VELOCITY callback is triggered periodically. A value of 0 turns the callback off.
359 360 361 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 359 def set_angular_velocity_period(period) send_request(FUNCTION_SET_ANGULAR_VELOCITY_PERIOD, [period], 'L', 0, '') end |
#set_gravity_vector_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_GRAVITY_VECTOR callback is triggered periodically. A value of 0 turns the callback off.
403 404 405 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 403 def set_gravity_vector_period(period) send_request(FUNCTION_SET_GRAVITY_VECTOR_PERIOD, [period], 'L', 0, '') end |
#set_linear_acceleration_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_LINEAR_ACCELERATION callback is triggered periodically. A value of 0 turns the callback off.
392 393 394 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 392 def set_linear_acceleration_period(period) send_request(FUNCTION_SET_LINEAR_ACCELERATION_PERIOD, [period], 'L', 0, '') end |
#set_magnetic_field_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_MAGNETIC_FIELD callback is triggered periodically. A value of 0 turns the callback off.
348 349 350 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 348 def set_magnetic_field_period(period) send_request(FUNCTION_SET_MAGNETIC_FIELD_PERIOD, [period], 'L', 0, '') end |
#set_orientation_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_ORIENTATION callback is triggered periodically. A value of 0 turns the callback off.
381 382 383 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 381 def set_orientation_period(period) send_request(FUNCTION_SET_ORIENTATION_PERIOD, [period], 'L', 0, '') end |
#set_quaternion_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_QUATERNION callback is triggered periodically. A value of 0 turns the callback off.
414 415 416 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 414 def set_quaternion_period(period) send_request(FUNCTION_SET_QUATERNION_PERIOD, [period], 'L', 0, '') end |
#set_temperature_period(period) ⇒ Object
Sets the period in ms with which the CALLBACK_TEMPERATURE callback is triggered periodically. A value of 0 turns the callback off.
370 371 372 |
# File 'lib/tinkerforge/brick_imu_v2.rb', line 370 def set_temperature_period(period) send_request(FUNCTION_SET_TEMPERATURE_PERIOD, [period], 'L', 0, '') end |