imu_v2_brick

package
v0.0.0-...-368b749 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2024 License: CC0-1.0 Imports: 5 Imported by: 0

Documentation

Overview

Full fledged AHRS with 9 degrees of freedom.

See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricks/IMUV2_Brick_Go.html.

Index

Constants

View Source
const DeviceDisplayName = "IMU Brick 2.0"
View Source
const DeviceIdentifier = 18

Variables

This section is empty.

Functions

This section is empty.

Types

type AccelerometerBandwidth

type AccelerometerBandwidth = uint8
const (
	//Deprecated: Use 7_81Hz instead.
	AccelerometerBandwidth781Hz  AccelerometerBandwidth = 0
	AccelerometerBandwidth7_81Hz AccelerometerBandwidth = 0
	//Deprecated: Use 15_63Hz instead.
	AccelerometerBandwidth1563Hz  AccelerometerBandwidth = 1
	AccelerometerBandwidth15_63Hz AccelerometerBandwidth = 1
	//Deprecated: Use 31_25Hz instead.
	AccelerometerBandwidth3125Hz  AccelerometerBandwidth = 2
	AccelerometerBandwidth31_25Hz AccelerometerBandwidth = 2
	//Deprecated: Use 62_5Hz instead.
	AccelerometerBandwidth625Hz  AccelerometerBandwidth = 3
	AccelerometerBandwidth62_5Hz AccelerometerBandwidth = 3
	AccelerometerBandwidth125Hz  AccelerometerBandwidth = 4
	AccelerometerBandwidth250Hz  AccelerometerBandwidth = 5
	AccelerometerBandwidth500Hz  AccelerometerBandwidth = 6
	AccelerometerBandwidth1000Hz AccelerometerBandwidth = 7
)

type AccelerometerRange

type AccelerometerRange = uint8
const (
	AccelerometerRange2G  AccelerometerRange = 0
	AccelerometerRange4G  AccelerometerRange = 1
	AccelerometerRange8G  AccelerometerRange = 2
	AccelerometerRange16G AccelerometerRange = 3
)

type CommunicationMethod

type CommunicationMethod = uint8
const (
	CommunicationMethodNone     CommunicationMethod = 0
	CommunicationMethodUSB      CommunicationMethod = 1
	CommunicationMethodSPIStack CommunicationMethod = 2
	CommunicationMethodChibi    CommunicationMethod = 3
	CommunicationMethodRS485    CommunicationMethod = 4
	CommunicationMethodWIFI     CommunicationMethod = 5
	CommunicationMethodEthernet CommunicationMethod = 6
	CommunicationMethodWIFIV2   CommunicationMethod = 7
)

type Function

type Function = uint8
const (
	FunctionGetAcceleration             Function = 1
	FunctionGetMagneticField            Function = 2
	FunctionGetAngularVelocity          Function = 3
	FunctionGetTemperature              Function = 4
	FunctionGetOrientation              Function = 5
	FunctionGetLinearAcceleration       Function = 6
	FunctionGetGravityVector            Function = 7
	FunctionGetQuaternion               Function = 8
	FunctionGetAllData                  Function = 9
	FunctionLedsOn                      Function = 10
	FunctionLedsOff                     Function = 11
	FunctionAreLedsOn                   Function = 12
	FunctionSaveCalibration             Function = 13
	FunctionSetAccelerationPeriod       Function = 14
	FunctionGetAccelerationPeriod       Function = 15
	FunctionSetMagneticFieldPeriod      Function = 16
	FunctionGetMagneticFieldPeriod      Function = 17
	FunctionSetAngularVelocityPeriod    Function = 18
	FunctionGetAngularVelocityPeriod    Function = 19
	FunctionSetTemperaturePeriod        Function = 20
	FunctionGetTemperaturePeriod        Function = 21
	FunctionSetOrientationPeriod        Function = 22
	FunctionGetOrientationPeriod        Function = 23
	FunctionSetLinearAccelerationPeriod Function = 24
	FunctionGetLinearAccelerationPeriod Function = 25
	FunctionSetGravityVectorPeriod      Function = 26
	FunctionGetGravityVectorPeriod      Function = 27
	FunctionSetQuaternionPeriod         Function = 28
	FunctionGetQuaternionPeriod         Function = 29
	FunctionSetAllDataPeriod            Function = 30
	FunctionGetAllDataPeriod            Function = 31
	FunctionSetSensorConfiguration      Function = 41
	FunctionGetSensorConfiguration      Function = 42
	FunctionSetSensorFusionMode         Function = 43
	FunctionGetSensorFusionMode         Function = 44
	FunctionSetSPITFPBaudrateConfig     Function = 231
	FunctionGetSPITFPBaudrateConfig     Function = 232
	FunctionGetSendTimeoutCount         Function = 233
	FunctionSetSPITFPBaudrate           Function = 234
	FunctionGetSPITFPBaudrate           Function = 235
	FunctionGetSPITFPErrorCount         Function = 237
	FunctionEnableStatusLED             Function = 238
	FunctionDisableStatusLED            Function = 239
	FunctionIsStatusLEDEnabled          Function = 240
	FunctionGetProtocol1BrickletName    Function = 241
	FunctionGetChipTemperature          Function = 242
	FunctionReset                       Function = 243
	FunctionWriteBrickletPlugin         Function = 246
	FunctionReadBrickletPlugin          Function = 247
	FunctionGetIdentity                 Function = 255
	FunctionCallbackAcceleration        Function = 32
	FunctionCallbackMagneticField       Function = 33
	FunctionCallbackAngularVelocity     Function = 34
	FunctionCallbackTemperature         Function = 35
	FunctionCallbackLinearAcceleration  Function = 36
	FunctionCallbackGravityVector       Function = 37
	FunctionCallbackOrientation         Function = 38
	FunctionCallbackQuaternion          Function = 39
	FunctionCallbackAllData             Function = 40
)

type GyroscopeBandwidth

type GyroscopeBandwidth = uint8
const (
	GyroscopeBandwidth523Hz GyroscopeBandwidth = 0
	GyroscopeBandwidth230Hz GyroscopeBandwidth = 1
	GyroscopeBandwidth116Hz GyroscopeBandwidth = 2
	GyroscopeBandwidth47Hz  GyroscopeBandwidth = 3
	GyroscopeBandwidth23Hz  GyroscopeBandwidth = 4
	GyroscopeBandwidth12Hz  GyroscopeBandwidth = 5
	GyroscopeBandwidth64Hz  GyroscopeBandwidth = 6
	GyroscopeBandwidth32Hz  GyroscopeBandwidth = 7
)

type GyroscopeRange

type GyroscopeRange = uint8
const (
	GyroscopeRange2000DPS GyroscopeRange = 0
	GyroscopeRange1000DPS GyroscopeRange = 1
	GyroscopeRange500DPS  GyroscopeRange = 2
	GyroscopeRange250DPS  GyroscopeRange = 3
	GyroscopeRange125DPS  GyroscopeRange = 4
)

type IMUV2Brick

type IMUV2Brick struct {
	// contains filtered or unexported fields
}

func New

func New(uid string, ipcon *ipconnection.IPConnection) (IMUV2Brick, error)

Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ipcon` is connected.

func (*IMUV2Brick) AreLedsOn

func (device *IMUV2Brick) AreLedsOn() (leds bool, err error)

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

func (*IMUV2Brick) DeregisterAccelerationCallback

func (device *IMUV2Brick) DeregisterAccelerationCallback(registrationId uint64)

Remove a registered Acceleration callback.

func (*IMUV2Brick) DeregisterAllDataCallback

func (device *IMUV2Brick) DeregisterAllDataCallback(registrationId uint64)

Remove a registered All Data callback.

func (*IMUV2Brick) DeregisterAngularVelocityCallback

func (device *IMUV2Brick) DeregisterAngularVelocityCallback(registrationId uint64)

Remove a registered Angular Velocity callback.

func (*IMUV2Brick) DeregisterGravityVectorCallback

func (device *IMUV2Brick) DeregisterGravityVectorCallback(registrationId uint64)

Remove a registered Gravity Vector callback.

func (*IMUV2Brick) DeregisterLinearAccelerationCallback

func (device *IMUV2Brick) DeregisterLinearAccelerationCallback(registrationId uint64)

Remove a registered Linear Acceleration callback.

func (*IMUV2Brick) DeregisterMagneticFieldCallback

func (device *IMUV2Brick) DeregisterMagneticFieldCallback(registrationId uint64)

Remove a registered Magnetic Field callback.

func (*IMUV2Brick) DeregisterOrientationCallback

func (device *IMUV2Brick) DeregisterOrientationCallback(registrationId uint64)

Remove a registered Orientation callback.

func (*IMUV2Brick) DeregisterQuaternionCallback

func (device *IMUV2Brick) DeregisterQuaternionCallback(registrationId uint64)

Remove a registered Quaternion callback.

func (*IMUV2Brick) DeregisterTemperatureCallback

func (device *IMUV2Brick) DeregisterTemperatureCallback(registrationId uint64)

Remove a registered Temperature callback.

func (*IMUV2Brick) DisableStatusLED

func (device *IMUV2Brick) DisableStatusLED() (err error)

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.

func (*IMUV2Brick) EnableStatusLED

func (device *IMUV2Brick) EnableStatusLED() (err error)

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.

func (*IMUV2Brick) GetAPIVersion

func (device *IMUV2Brick) GetAPIVersion() [3]uint8

Returns the version of the API definition (major, minor, revision) implemented by this API bindings. This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.

func (*IMUV2Brick) GetAcceleration

func (device *IMUV2Brick) GetAcceleration() (x int16, y int16, z int16, err error)

Returns the calibrated acceleration from the accelerometer for the x, y and z axis. The acceleration is in the range configured with SetSensorConfiguration.

If you want to get the acceleration periodically, it is recommended to use the RegisterAccelerationCallback callback and set the period with SetAccelerationPeriod.

func (*IMUV2Brick) GetAccelerationPeriod

func (device *IMUV2Brick) GetAccelerationPeriod() (period uint32, err error)

Returns the period as set by SetAccelerationPeriod.

func (*IMUV2Brick) GetAllData

func (device *IMUV2Brick) GetAllData() (acceleration [3]int16, magneticField [3]int16, angularVelocity [3]int16, eulerAngle [3]int16, quaternion [4]int16, linearAcceleration [3]int16, gravityVector [3]int16, temperature int8, calibrationStatus uint8, err error)

Return all of the available data of the IMU Brick.

* acceleration (see GetAcceleration) * magnetic field (see GetMagneticField) * angular velocity (see GetAngularVelocity) * Euler angles (see GetOrientation) * quaternion (see GetQuaternion) * linear acceleration (see GetLinearAcceleration) * gravity vector (see GetGravityVector) * temperature (see GetTemperature) * 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 RegisterAllDataCallback callback and set the period with SetAllDataPeriod.

func (*IMUV2Brick) GetAllDataPeriod

func (device *IMUV2Brick) GetAllDataPeriod() (period uint32, err error)

Returns the period as set by SetAllDataPeriod.

func (*IMUV2Brick) GetAngularVelocity

func (device *IMUV2Brick) GetAngularVelocity() (x int16, y int16, z int16, err error)

Returns the calibrated angular velocity from the gyroscope for the x, y and z axis. The angular velocity is in the range configured with SetSensorConfiguration.

If you want to get the angular velocity periodically, it is recommended to use the RegisterAngularVelocityCallback acallback nd set the period with SetAngularVelocityPeriod.

func (*IMUV2Brick) GetAngularVelocityPeriod

func (device *IMUV2Brick) GetAngularVelocityPeriod() (period uint32, err error)

Returns the period as set by SetAngularVelocityPeriod.

func (*IMUV2Brick) GetChipTemperature

func (device *IMUV2Brick) GetChipTemperature() (temperature int16, err error)

Returns the temperature 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.

func (*IMUV2Brick) GetGravityVector

func (device *IMUV2Brick) GetGravityVector() (x int16, y int16, z int16, err error)

Returns the current gravity vector of the IMU Brick for the x, y and z axis.

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 GetLinearAcceleration.

If you want to get the gravity vector periodically, it is recommended to use the RegisterGravityVectorCallback callback and set the period with SetGravityVectorPeriod.

func (*IMUV2Brick) GetGravityVectorPeriod

func (device *IMUV2Brick) GetGravityVectorPeriod() (period uint32, err error)

Returns the period as set by SetGravityVectorPeriod.

func (*IMUV2Brick) GetIdentity

func (device *IMUV2Brick) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, firmwareVersion [3]uint8, deviceIdentifier uint16, err error)

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 is the position in the stack from '0' (bottom) to '8' (top).

The device identifier numbers can be found `here <device_identifier>`. |device_identifier_constant|

func (*IMUV2Brick) GetLinearAcceleration

func (device *IMUV2Brick) GetLinearAcceleration() (x int16, y int16, z int16, err error)

Returns the linear acceleration of the IMU Brick for the x, y and z axis. The acceleration is in the range configured with SetSensorConfiguration.

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 GetGravityVector.

If you want to get the linear acceleration periodically, it is recommended to use the RegisterLinearAccelerationCallback callback and set the period with SetLinearAccelerationPeriod.

func (*IMUV2Brick) GetLinearAccelerationPeriod

func (device *IMUV2Brick) GetLinearAccelerationPeriod() (period uint32, err error)

Returns the period as set by SetLinearAccelerationPeriod.

func (*IMUV2Brick) GetMagneticField

func (device *IMUV2Brick) GetMagneticField() (x int16, y int16, z int16, err error)

Returns the calibrated magnetic field from the magnetometer for the x, y and z axis.

If you want to get the magnetic field periodically, it is recommended to use the RegisterMagneticFieldCallback callback and set the period with SetMagneticFieldPeriod.

func (*IMUV2Brick) GetMagneticFieldPeriod

func (device *IMUV2Brick) GetMagneticFieldPeriod() (period uint32, err error)

Returns the period as set by SetMagneticFieldPeriod.

func (*IMUV2Brick) GetOrientation

func (device *IMUV2Brick) GetOrientation() (heading int16, roll int16, pitch int16, err error)

Returns the current orientation (heading, roll, pitch) of the IMU Brick as independent Euler angles. Note that Euler angles always experience a https://en.wikipedia.org/wiki/Gimbal_lock. We recommend that you use quaternions instead, if you need the absolute orientation.

If you want to get the orientation periodically, it is recommended to use the RegisterOrientationCallback callback and set the period with SetOrientationPeriod.

func (*IMUV2Brick) GetOrientationPeriod

func (device *IMUV2Brick) GetOrientationPeriod() (period uint32, err error)

Returns the period as set by SetOrientationPeriod.

func (*IMUV2Brick) GetProtocol1BrickletName

func (device *IMUV2Brick) GetProtocol1BrickletName(port rune) (protocolVersion uint8, firmwareVersion [3]uint8, name string, err error)

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.

func (*IMUV2Brick) GetQuaternion

func (device *IMUV2Brick) GetQuaternion() (w int16, x int16, y int16, z int16, err error)

Returns the current orientation (w, x, y, z) of the IMU Brick as https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation.

You have to divide the return 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 RegisterQuaternionCallback callback and set the period with SetQuaternionPeriod.

func (*IMUV2Brick) GetQuaternionPeriod

func (device *IMUV2Brick) GetQuaternionPeriod() (period uint32, err error)

Returns the period as set by SetQuaternionPeriod.

func (*IMUV2Brick) GetResponseExpected

func (device *IMUV2Brick) GetResponseExpected(functionID Function) (bool, error)

Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.

For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by SetResponseExpected. For setter functions it is disabled by default and can be enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.

See SetResponseExpected for the list of function ID constants available for this function.

func (*IMUV2Brick) GetSPITFPBaudrate

func (device *IMUV2Brick) GetSPITFPBaudrate(brickletPort rune) (baudrate uint32, err error)

Returns the baudrate for a given Bricklet port, see SetSPITFPBaudrate.

.. versionadded:: 2.0.5$nbsp;(Firmware)

func (*IMUV2Brick) GetSPITFPBaudrateConfig

func (device *IMUV2Brick) GetSPITFPBaudrateConfig() (enableDynamicBaudrate bool, minimumDynamicBaudrate uint32, err error)

Returns the baudrate config, see SetSPITFPBaudrateConfig.

.. versionadded:: 2.0.10$nbsp;(Firmware)

func (*IMUV2Brick) GetSPITFPErrorCount

func (device *IMUV2Brick) GetSPITFPErrorCount(brickletPort rune) (errorCountACKChecksum uint32, errorCountMessageChecksum uint32, errorCountFrame uint32, errorCountOverflow uint32, err error)

Returns the error count for the communication between Brick and Bricklet.

The errors are divided into

* ACK checksum errors, * message checksum errors, * framing errors and * overflow errors.

The errors counts are for errors that occur on the Brick side. All Bricklets have a similar function that returns the errors on the Bricklet side.

.. versionadded:: 2.0.5$nbsp;(Firmware)

func (*IMUV2Brick) GetSendTimeoutCount

func (device *IMUV2Brick) GetSendTimeoutCount(communicationMethod CommunicationMethod) (timeoutCount uint32, err error)

Returns the timeout count for the different communication methods.

The methods 0-2 are available for all Bricks, 3-7 only for Master Bricks.

This function is mostly used for debugging during development, in normal operation the counters should nearly always stay at 0.

.. versionadded:: 2.0.7$nbsp;(Firmware)

Associated constants:

  • CommunicationMethodNone
  • CommunicationMethodUSB
  • CommunicationMethodSPIStack
  • CommunicationMethodChibi
  • CommunicationMethodRS485
  • CommunicationMethodWIFI
  • CommunicationMethodEthernet
  • CommunicationMethodWIFIV2

func (*IMUV2Brick) GetSensorConfiguration

func (device *IMUV2Brick) GetSensorConfiguration() (magnetometerRate MagnetometerRate, gyroscopeRange GyroscopeRange, gyroscopeBandwidth GyroscopeBandwidth, accelerometerRange AccelerometerRange, accelerometerBandwidth AccelerometerBandwidth, err error)

Returns the sensor configuration as set by SetSensorConfiguration.

.. versionadded:: 2.0.5$nbsp;(Firmware)

Associated constants:

  • MagnetometerRate2Hz
  • MagnetometerRate6Hz
  • MagnetometerRate8Hz
  • MagnetometerRate10Hz
  • MagnetometerRate15Hz
  • MagnetometerRate20Hz
  • MagnetometerRate25Hz
  • MagnetometerRate30Hz
  • GyroscopeRange2000DPS
  • GyroscopeRange1000DPS
  • GyroscopeRange500DPS
  • GyroscopeRange250DPS
  • GyroscopeRange125DPS
  • GyroscopeBandwidth523Hz
  • GyroscopeBandwidth230Hz
  • GyroscopeBandwidth116Hz
  • GyroscopeBandwidth47Hz
  • GyroscopeBandwidth23Hz
  • GyroscopeBandwidth12Hz
  • GyroscopeBandwidth64Hz
  • GyroscopeBandwidth32Hz
  • AccelerometerRange2G
  • AccelerometerRange4G
  • AccelerometerRange8G
  • AccelerometerRange16G
  • AccelerometerBandwidth781Hz
  • AccelerometerBandwidth1563Hz
  • AccelerometerBandwidth3125Hz
  • AccelerometerBandwidth625Hz
  • AccelerometerBandwidth125Hz
  • AccelerometerBandwidth250Hz
  • AccelerometerBandwidth500Hz
  • AccelerometerBandwidth1000Hz

func (*IMUV2Brick) GetSensorFusionMode

func (device *IMUV2Brick) GetSensorFusionMode() (mode SensorFusion, err error)

Returns the sensor fusion mode as set by SetSensorFusionMode.

.. versionadded:: 2.0.5$nbsp;(Firmware)

Associated constants:

  • SensorFusionOff
  • SensorFusionOn
  • SensorFusionOnWithoutMagnetometer
  • SensorFusionOnWithoutFastMagnetometerCalibration

func (*IMUV2Brick) GetTemperature

func (device *IMUV2Brick) GetTemperature() (temperature int8, err error)

Returns the temperature of the IMU Brick. The temperature is measured in the core of the BNO055 IC, it is not the ambient temperature

func (*IMUV2Brick) GetTemperaturePeriod

func (device *IMUV2Brick) GetTemperaturePeriod() (period uint32, err error)

Returns the period as set by SetTemperaturePeriod.

func (*IMUV2Brick) IsStatusLEDEnabled

func (device *IMUV2Brick) IsStatusLEDEnabled() (enabled bool, err error)

Returns *true* if the status LED is enabled, *false* otherwise.

func (*IMUV2Brick) LedsOff

func (device *IMUV2Brick) LedsOff() (err error)

Turns the orientation and direction LEDs of the IMU Brick off.

func (*IMUV2Brick) LedsOn

func (device *IMUV2Brick) LedsOn() (err error)

Turns the orientation and direction LEDs of the IMU Brick on.

func (*IMUV2Brick) ReadBrickletPlugin

func (device *IMUV2Brick) ReadBrickletPlugin(port rune, offset uint8) (chunk [32]uint8, err error)

Reads 32 bytes of firmware from the bricklet attached at the given port. The bytes are read starting at the position offset * 32.

This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.

func (*IMUV2Brick) RegisterAccelerationCallback

func (device *IMUV2Brick) RegisterAccelerationCallback(fn func(int16, int16, int16)) uint64

This callback is triggered periodically with the period that is set by SetAccelerationPeriod. The parameters are the acceleration for the x, y and z axis.

func (*IMUV2Brick) RegisterAllDataCallback

func (device *IMUV2Brick) RegisterAllDataCallback(fn func([3]int16, [3]int16, [3]int16, [3]int16, [4]int16, [3]int16, [3]int16, int8, uint8)) uint64

This callback is triggered periodically with the period that is set by SetAllDataPeriod. The parameters are as for GetAllData.

func (*IMUV2Brick) RegisterAngularVelocityCallback

func (device *IMUV2Brick) RegisterAngularVelocityCallback(fn func(int16, int16, int16)) uint64

This callback is triggered periodically with the period that is set by SetAngularVelocityPeriod. The parameters are the angular velocity for the x, y and z axis.

func (*IMUV2Brick) RegisterGravityVectorCallback

func (device *IMUV2Brick) RegisterGravityVectorCallback(fn func(int16, int16, int16)) uint64

This callback is triggered periodically with the period that is set by SetGravityVectorPeriod. The parameters gravity vector for the x, y and z axis.

func (*IMUV2Brick) RegisterLinearAccelerationCallback

func (device *IMUV2Brick) RegisterLinearAccelerationCallback(fn func(int16, int16, int16)) uint64

This callback is triggered periodically with the period that is set by SetLinearAccelerationPeriod. The parameters are the linear acceleration for the x, y and z axis.

func (*IMUV2Brick) RegisterMagneticFieldCallback

func (device *IMUV2Brick) RegisterMagneticFieldCallback(fn func(int16, int16, int16)) uint64

This callback is triggered periodically with the period that is set by SetMagneticFieldPeriod. The parameters are the magnetic field for the x, y and z axis.

func (*IMUV2Brick) RegisterOrientationCallback

func (device *IMUV2Brick) RegisterOrientationCallback(fn func(int16, int16, int16)) uint64

This callback is triggered periodically with the period that is set by SetOrientationPeriod. The parameters are the orientation (heading (yaw), roll, pitch) of the IMU Brick in Euler angles. See GetOrientation for details.

func (*IMUV2Brick) RegisterQuaternionCallback

func (device *IMUV2Brick) RegisterQuaternionCallback(fn func(int16, int16, int16, int16)) uint64

This callback is triggered periodically with the period that is set by SetQuaternionPeriod. The parameters are the orientation (w, x, y, z) of the IMU Brick in quaternions. See GetQuaternion for details.

func (*IMUV2Brick) RegisterTemperatureCallback

func (device *IMUV2Brick) RegisterTemperatureCallback(fn func(int8)) uint64

This callback is triggered periodically with the period that is set by SetTemperaturePeriod. The parameter is the temperature.

func (*IMUV2Brick) Reset

func (device *IMUV2Brick) Reset() (err error)

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!

func (*IMUV2Brick) SaveCalibration

func (device *IMUV2Brick) SaveCalibration() (calibrationDone bool, err error)

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.

func (*IMUV2Brick) SetAccelerationPeriod

func (device *IMUV2Brick) SetAccelerationPeriod(period uint32) (err error)

Sets the period with which the RegisterAccelerationCallback callback is triggered periodically. A value of 0 turns the callback off.

func (*IMUV2Brick) SetAllDataPeriod

func (device *IMUV2Brick) SetAllDataPeriod(period uint32) (err error)

Sets the period with which the RegisterAllDataCallback callback is triggered periodically. A value of 0 turns the callback off.

func (*IMUV2Brick) SetAngularVelocityPeriod

func (device *IMUV2Brick) SetAngularVelocityPeriod(period uint32) (err error)

Sets the period with which the RegisterAngularVelocityCallback callback is triggered periodically. A value of 0 turns the callback off.

func (*IMUV2Brick) SetGravityVectorPeriod

func (device *IMUV2Brick) SetGravityVectorPeriod(period uint32) (err error)

Sets the period with which the RegisterGravityVectorCallback callback is triggered periodically. A value of 0 turns the callback off.

func (*IMUV2Brick) SetLinearAccelerationPeriod

func (device *IMUV2Brick) SetLinearAccelerationPeriod(period uint32) (err error)

Sets the period with which the RegisterLinearAccelerationCallback callback is triggered periodically. A value of 0 turns the callback off.

func (*IMUV2Brick) SetMagneticFieldPeriod

func (device *IMUV2Brick) SetMagneticFieldPeriod(period uint32) (err error)

Sets the period with which the RegisterMagneticFieldCallback callback is triggered periodically. A value of 0 turns the callback off.

func (*IMUV2Brick) SetOrientationPeriod

func (device *IMUV2Brick) SetOrientationPeriod(period uint32) (err error)

Sets the period with which the RegisterOrientationCallback callback is triggered periodically. A value of 0 turns the callback off.

func (*IMUV2Brick) SetQuaternionPeriod

func (device *IMUV2Brick) SetQuaternionPeriod(period uint32) (err error)

Sets the period with which the RegisterQuaternionCallback callback is triggered periodically. A value of 0 turns the callback off.

func (*IMUV2Brick) SetResponseExpected

func (device *IMUV2Brick) SetResponseExpected(functionID Function, responseExpected bool) error

Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.

Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.

func (*IMUV2Brick) SetResponseExpectedAll

func (device *IMUV2Brick) SetResponseExpectedAll(responseExpected bool)

Changes the response expected flag for all setter and callback configuration functions of this device at once.

func (*IMUV2Brick) SetSPITFPBaudrate

func (device *IMUV2Brick) SetSPITFPBaudrate(brickletPort rune, baudrate uint32) (err error)

Sets the baudrate for a specific Bricklet port.

If you want to increase the throughput of Bricklets you can increase the baudrate. If you get a high error count because of high interference (see GetSPITFPErrorCount) you can decrease the baudrate.

If the dynamic baudrate feature is enabled, the baudrate set by this function corresponds to the maximum baudrate (see SetSPITFPBaudrateConfig).

Regulatory testing is done with the default baudrate. If CE compatibility or similar is necessary in your applications we recommend to not change the baudrate.

.. versionadded:: 2.0.5$nbsp;(Firmware)

func (*IMUV2Brick) SetSPITFPBaudrateConfig

func (device *IMUV2Brick) SetSPITFPBaudrateConfig(enableDynamicBaudrate bool, minimumDynamicBaudrate uint32) (err error)

The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is enabled, the Brick will try to adapt the baudrate for the communication between Bricks and Bricklets according to the amount of data that is transferred.

The baudrate will be increased exponentially if lots of data is sent/received and decreased linearly if little data is sent/received.

This lowers the baudrate in applications where little data is transferred (e.g. a weather station) and increases the robustness. If there is lots of data to transfer (e.g. Thermal Imaging Bricklet) it automatically increases the baudrate as needed.

In cases where some data has to transferred as fast as possible every few seconds (e.g. RS485 Bricklet with a high baudrate but small payload) you may want to turn the dynamic baudrate off to get the highest possible performance.

The maximum value of the baudrate can be set per port with the function SetSPITFPBaudrate. If the dynamic baudrate is disabled, the baudrate as set by SetSPITFPBaudrate will be used statically.

.. versionadded:: 2.0.10$nbsp;(Firmware)

func (*IMUV2Brick) SetSensorConfiguration

func (device *IMUV2Brick) SetSensorConfiguration(magnetometerRate MagnetometerRate, gyroscopeRange GyroscopeRange, gyroscopeBandwidth GyroscopeBandwidth, accelerometerRange AccelerometerRange, accelerometerBandwidth AccelerometerBandwidth) (err error)

Sets the available sensor configuration for the Magnetometer, Gyroscope and Accelerometer. The Accelerometer Range is user selectable in all fusion modes, all other configurations are auto-controlled in fusion mode.

.. versionadded:: 2.0.5$nbsp;(Firmware)

Associated constants:

  • MagnetometerRate2Hz
  • MagnetometerRate6Hz
  • MagnetometerRate8Hz
  • MagnetometerRate10Hz
  • MagnetometerRate15Hz
  • MagnetometerRate20Hz
  • MagnetometerRate25Hz
  • MagnetometerRate30Hz
  • GyroscopeRange2000DPS
  • GyroscopeRange1000DPS
  • GyroscopeRange500DPS
  • GyroscopeRange250DPS
  • GyroscopeRange125DPS
  • GyroscopeBandwidth523Hz
  • GyroscopeBandwidth230Hz
  • GyroscopeBandwidth116Hz
  • GyroscopeBandwidth47Hz
  • GyroscopeBandwidth23Hz
  • GyroscopeBandwidth12Hz
  • GyroscopeBandwidth64Hz
  • GyroscopeBandwidth32Hz
  • AccelerometerRange2G
  • AccelerometerRange4G
  • AccelerometerRange8G
  • AccelerometerRange16G
  • AccelerometerBandwidth781Hz
  • AccelerometerBandwidth1563Hz
  • AccelerometerBandwidth3125Hz
  • AccelerometerBandwidth625Hz
  • AccelerometerBandwidth125Hz
  • AccelerometerBandwidth250Hz
  • AccelerometerBandwidth500Hz
  • AccelerometerBandwidth1000Hz

func (*IMUV2Brick) SetSensorFusionMode

func (device *IMUV2Brick) SetSensorFusionMode(mode SensorFusion) (err error)

If the fusion mode is turned off, the functions GetAcceleration, GetMagneticField and GetAngularVelocity return uncalibrated and uncompensated sensor data. All other sensor data getters return no data.

Since firmware version 2.0.6 you can also use a fusion mode without magnetometer. In this mode the calculated orientation is relative (with magnetometer it is absolute with respect to the earth). However, the calculation can't be influenced by spurious magnetic fields.

Since firmware version 2.0.13 you can also use a fusion mode without fast magnetometer calibration. This mode is the same as the normal fusion mode, but the fast magnetometer calibration is turned off. So to find the orientation the first time will likely take longer, but small magnetic influences might not affect the automatic calibration as much.

.. versionadded:: 2.0.5$nbsp;(Firmware)

Associated constants:

  • SensorFusionOff
  • SensorFusionOn
  • SensorFusionOnWithoutMagnetometer
  • SensorFusionOnWithoutFastMagnetometerCalibration

func (*IMUV2Brick) SetTemperaturePeriod

func (device *IMUV2Brick) SetTemperaturePeriod(period uint32) (err error)

Sets the period with which the RegisterTemperatureCallback callback is triggered periodically. A value of 0 turns the callback off.

func (*IMUV2Brick) WriteBrickletPlugin

func (device *IMUV2Brick) WriteBrickletPlugin(port rune, offset uint8, chunk [32]uint8) (err error)

Writes 32 bytes of firmware to the bricklet attached at the given port. The bytes are written to the position offset * 32.

This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.

type MagnetometerRate

type MagnetometerRate = uint8
const (
	MagnetometerRate2Hz  MagnetometerRate = 0
	MagnetometerRate6Hz  MagnetometerRate = 1
	MagnetometerRate8Hz  MagnetometerRate = 2
	MagnetometerRate10Hz MagnetometerRate = 3
	MagnetometerRate15Hz MagnetometerRate = 4
	MagnetometerRate20Hz MagnetometerRate = 5
	MagnetometerRate25Hz MagnetometerRate = 6
	MagnetometerRate30Hz MagnetometerRate = 7
)

type SensorFusion

type SensorFusion = uint8
const (
	SensorFusionOff                                  SensorFusion = 0
	SensorFusionOn                                   SensorFusion = 1
	SensorFusionOnWithoutMagnetometer                SensorFusion = 2
	SensorFusionOnWithoutFastMagnetometerCalibration SensorFusion = 3
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL