# Rotation Mechanism

##### Gyroscope Sensor:

The gyroscope sensor measures the angular velocity of an object.

In our proposal, the gyro sensor measures the angle by which the robot has made its turn.`get_sensor_value0(sn_gyro, &gyro_value)`

The *gyro_value* returns the current value of the gyroscopic readings.

The problem we faced initially was, with the starting position, there was already some gyro values returned by our function. This problem was solved by using a single liner function to calibrate the gyro in the starting so that the starting angle value returned by the gyroscope is 0.

`sensor_set_mode(0x1L, LEGO_EV3_GYRO_GYRO_CAL)`

*Usage*:**(1)** In our model, the gyroscope was used to make *TURNs* of the robot with more precision.

The turn algorithm is:

`arr[a] = [50,10,1,1,1,1,.....1];`

`for(i < length(arr[a]){`

`gyro_reading_difference = 90`

//or 89 for different floors`a = 1;`

`if(a == gyro_reading_difference){`

`degrees -> 5`

`turn(degrees*arr[i])`

`//More conditions`

`}`

`}`

Mostly, we are taking turns in packets of 90 degrees. To make a turn, first the robot turns immediately by 50 degrees and then it rotates by 10 degrees and then 1 degrees each until the `a`

becomes 90 i.e. the robot turns by 90 degrees.

The values like 50 and 10 are statically taken into account taking the floor condition into account.