This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

readRotationRate

Read rotation rate from gyroscopic sensor

Syntax

rotationrate = readRotationRate(mygyrosensor)

Description

example

rotationrate = readRotationRate(mygyrosensor) reads the rate of rotation of the sensor, and returns the measurement in degrees per second.

Examples

collapse all

Measure rate of rotation, degrees per second, using a gyroscopic sensor.

Create a connection to the EV3 brick called myev3.

myev3 = legoev3
myev3 = 

  legoev3 with properties:

      FirmwareVersion: 'V1.03E'
           HardwareID: []
            IPAddress: []
    CommunicationType: 'USB'
         BatteryLevel: 100
     ConnectedSensors: {'touch'  'gyro'  'color'  'sonic'}

The sensor appears in the list of connected sensors.

Create a connection to the gyroscopic sensor called mygyrosensor.

mygyrosensor = gyroSensor(myev3)
mygyrosensor = 

  gyroSensor with properties:

    InputPort: 2

Measure the current rate of rotation, in degrees per second.

rate = readRotationRate(mygyrosensor)
ans =

           12

The gyro sensor is rotating at 12 degrees per second.

Input Arguments

collapse all

Connection to gyroscopic sensor, specified as a string that represents the object created using gyroSensor.

Example: mygyrosensor

Data Types: double

Output Arguments

collapse all

The rate of rotation, returned as an int32 value, from -440 to 440 degrees per second.