Main Content

readAngularVelocity

Read one sample of angular velocity from BNO055 sensor

Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.

Description

[gyroReadings,timestamp] = readAngularVelocity(bno055) returns angular velocity along x, y, and z axes of the BNO055 sensor as a 3-by-1 vector in units of rad/s along with the timestamp. In ndof mode, the elements of the vector represent calibrated values, whereas in amg mode, the elements represent raw values.

example

Examples

Read Angular Velocity from Sensor in NDOF Mode

Create an arduino object

a = arduino('COM4', 'Uno', 'Libraries', 'I2C');

Create the BNO055 sensor object.

imu = bno055(a,'OperatingMode','ndof');

Calibrate the sensor using steps mentioned in Calibrate BNO055 Sensors

tic; 
while (toc < 50)
    [status,timestamp] = readCalibrationStatus(imu); 
    if strcmpi(status.Gyroscope,'full')
        break; %If Gyroscope is calibrated proceed further
    end
    pause(1);
end

Read angular velocity data.

[gyroReadings,timestamp]  = readAngularVelocity(imu)
gyroReadings = 3×1

    0.0011    0.0011         0

timestamp = datetime
   21-Jul-2020 14:53:36.836

Read Angular Velocity from Sensor in AMG Mode

Create an arduino object

a = arduino('COM4', 'Uno', 'Libraries', 'I2C');

Create the BNO055 sensor object.

imu = bno055(a,'OperatingMode','amg');

Read angular velocity data.

[gyroReadings,timestamp]  = readAngularVelocity(imu)
gyroReadings = 3×1

    0.0138    0.0092    0.0034

timestamp = datetime
   21-Jul-2020 14:53:36.836

Input Arguments

collapse all

BNO055 sensor object created in either ndof or amg operating mode with the default or specified properties.

Output Arguments

collapse all

The angular velocity values along x, y, and z axes of the sensor as a 3-by-1 vector. In ndof mode, the elements of the vector represent calibrated values, whereas in amg mode, the elements represent raw values.

The time at which MATLAB® receives angular velocity data from the sensor, specified as a datetime.

More About

collapse all

Code Generation Using MATLAB Function Block

  • Use readAngularVelocity in a MATLAB Function block with the Simulink® Support Package for Arduino® Hardware to generate code that can be deployed on Arduino Hardware.

  • Timestamp returned is always in seconds.

  • readAngularVelocity returns raw values of the angular velocity if the sensor is not calibrated. Ensure you calibrate the sensor before using it in the ndof operating mode. See Calibrate BNO055 Sensors for the steps.

Version History

Introduced in R2019a