Main Content

readAngularVelocity

Read one angular velocity data sample from LSM6DSL sensor

Since R2021a

Description

example

[gyroReadings,timestamp] = readAngularVelocity(sensor) returns one sample of the angular velocity data from the LSM6DSL IMU sensor. The angular velocity sample is returned as a 3-by-1 vector in rad/s along the X, Y, and Z axes. The function also returns the timestamp at which MATLAB® receives the angular velocity data from the LSM6DSL sensor. The timestamp output is optional.

Examples

collapse all

Read the angular velocity data from the LSM6DSL IMU sensor on the X, Y, and Z axes.

Create a connection from MATLAB to the Raspberry Pi® hardware board.

mypi = raspi;
mypi = 

  Raspi with Properties:

           DeviceAddress: 'raspberrypi-hysdu8X38o'
                    Port: 18734
               BoardName: 'Raspberry Pi 3 Model B+'
           AvailableLEDs: {'led0'}
    AvailableDigitalPins: [4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
    AvailableSPIChannels: {‘CE0’,’CE1’}
       AvailableI2CBuses: {'i2c-1'}
             I2CBusSpeed: 100000
        AvailabelWebCams: mmal service 16.1 (platform:bcm2835-v4l2)

Create an lsm6dsl sensor object on the I2C bus 'i2c-1' on address '0x6B'.

sensor = lsm6dsl(mypi,'Bus','i2c-1','I2CAddress','0x6B');
sensor = 

  lsm6dsl with properties:

                         I2CAddress: 107 ("0x6B")
                                Bus: i2c-1

Return one sample of angular velocity data read from the LSM6DSL sensor on the X, Y, and Z axes.

[gyroReadings,timestamp] = readAngularVelocity(sensor);
gyroReadings =

  data

    -0.0173   -0.0311   -0.0070


timestamp = 

  datetime

   5-Jan-2021 11:36:29.135

Since the timestamp output is optional, you can obtain only the angular velocity data from the LSM6DSL sensor.

[gyroReadings] = readAngularVelocity(sensor);
gyroReadings =

  data

    -0.0173   -0.0311   -0.0070

Input Arguments

collapse all

LSM6DSL sensor object connection to the Raspberry Pi hardware board, specified as a lsm6dsl object.

Example: sensor = lsm6dsl(mypi) creates a connection to the LSM6DSL sensor on the Raspberry Pi object mypi.

Output Arguments

collapse all

Read the angular velocity data from the LSM6DSL sensor on the X, Y, and Z axes.

Read the date and time at which MATLAB receives the angular velocity sample value from the LSM6DSL sensor, specified as a datetime.

Extended Capabilities

Version History

Introduced in R2021a