GetGyro

Reads the current value of the HiTechnic Gyro sensor

Contents

Syntax

angularVelocity = GetGyro(port)

angularVelocity = GetGyro(port, handle)

Description

angularVelocity = GetGyro(port) returns the current rotational speed detected by the HiTechnic Gyroscopic sensor. Maximum range is from -360 to 360 degrees per second (according to HiTechnic documentation), however greater values have been observed. Returned values are accurate to +/- 1 degree.

Integration over time gives the rotational position (in degrees). Tests give quite good results. The given port number specifies the connection port. The value port can be addressed by the symbolic constants SENSOR_1, SENSOR_2, SENSOR_3 and SENSOR_4 analog to the labeling on the NXT Brick.

Before using this function, the gyro sensor must be initialized using OpenGyro and calibrated using CalibrateGyro.

The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).

Example

   OpenGyro(SENSOR_2);
   CalibrateGyro(SENSOR_2, 'AUTO');
   speed = GetGyro(SENSOR_2);
   CloseSensor(SENSOR_2);

See also

OpenGyro, CalibrateGyro, CloseSensor, NXT_SetInputMode, NXT_GetInputValues,

Signature