# Keep the LEGO Mindstorms robot orientation straight by using the Gyro Sensor. Proportional Part. ProPreview

The first part of making the robot move straight is to keep it oriented straight. While it moves it could make an error and turn slightly to the right and then the program should turn in back to the left to make its orientation straight. In this video tutorial, we would discuss how to implement a program to keep the robot orientation straight even when we are pushing or pulling it to either side and in the same time it has different wheels.

• #653
• 10 Jan 2018
• 5:13

### Proportional Part

As the robot moves slightly to the left we will steer it to the right. If it moves slightly to the right we will steer it to the left. We get the angle that the gyro is detecting. If this angle is 0, this means we are moving forward. If this angle is not zero, this means we are not oriented straight. So we must take the difference and apply this difference to the steering block. The farther it moves from the 0, the greater the steering should be. This is what proportional means. As the error gets larger we should proportionally try to move in the reverse direction.

### Different wheels

The robot has different wheels. The experiment will keep the robot straight even though it has different wheels because it will be constantly compensating for the turning.

### Pushing/pulling the robot while moving

While the robot is moving we can push or pull it and it will correct for this very large error and continue moving forward.

### Program for keeping the robot straight with the Gyro Sensor (Proportional compensation)

Proportional implementation for keeping the LEGO Mindstorms robot straight. The program will take the value of the Mindstorms Gyro sensor and will apply this value to the steering block. This will make the robot steer in a direction that would put the robot in a straight position again.