# Turning a 2 wheeled robot 90°

i got a task for which i need to drive a certain distance and move around an object. I finally managed that my robot goes almost straight but i think its enough. But now i gotta tackle the problem how to turn my robot by 90° at certain points. Can someone give me some advise how i can program the turning of the robot? For measurements i got wheel encoders and an IMU but i dont have any experience using the IMU. Thanks you for reading :)

## 1 Answer

Usually IMUs have only an accelerometer and a Gyro. Gyro gives the angular rates around x,y and z axes. The gyro can help to measure the rotated angle around z axis. But this is not very accurate method since gyro gives the angular rate to calculate the rotated angle by multiplying from the sample time.

$$\theta = \omega_z*\Delta t$$

Calculating the absolute rotation is not possible unless you use an magnetometer. My personal advice is to use the wheel encoders to calculate the rotated angle using the following method. 