I am building a robot (2 powered wheels and one ball bearing). The problem is that I can't seem to make it drive straight. I literally find it impossible, I have been trying for weeks.

I have two gyro sensors (on each wheel) and the current motor rotations.

The end result would be to have the gyros at 0 degrees, I do not really care for motor rotations.

I tried to search on Google but most results are GPS related. Is there a way I can do this?

  • $\begingroup$ So the gyros are measuring the rotation rate of the wheels? $\endgroup$
    – holmeski
    May 20, 2018 at 15:35
  • $\begingroup$ @holmeski No, they are measuring the angle of the whole robot. $\endgroup$ May 20, 2018 at 15:37
  • $\begingroup$ As straight as possible. I am trying yet another solution and hopefully it will work. $\endgroup$ May 20, 2018 at 16:05
  • 1
    $\begingroup$ Right, but what have you done in software? I know what sensors you have. What are you doing with the measurements from the gyros? How straight do you need it to go? We may be able to conclude here that gyros will not be sufficient. $\endgroup$
    – holmeski
    May 20, 2018 at 16:18
  • $\begingroup$ What do you mean by gyro sensors on each wheels ? Are the gyros firmly attached to moving parts or to the base of your robot ? How are the gyro's oriented w.r.t. the wheel rotation axis and the robot motion direction? $\endgroup$
    – N. Staub
    May 22, 2018 at 9:02

2 Answers 2


If you’re using your gyros to measure the direction your bot is moving, you will need to use a PID system to adjust your direction based on the feedback your bot provides. This type of system continuously measures the state of your gyro and applies it to the speed of each wheel. This should keep your bot running straight. If you are using the gyros to measure the rotation of each wheel, then you should be using a rotary encoder instead. Two rotary encoded motors and a gyro will solve your problem completely


You need to describe your system as a linear system, preferably with a matrix notation. then change the base or make the state variables exactly what you want to measure, finally with an ¿observer' you would estimate any state if it is observable even if you are not measuring it directly, if it could be represented as a linear combination of its states then it will be observable.

Using two giroscopies in a rigid body actually does'nt help too much, just reduce a little the radius of the gaussian noise (the variance of normal distribution is the mean of the variances, probably reduce noise in half). It could be different if they are both rotating since the correlation will be broken and the information provided by them won't be the same/similar.

But you probably don't need two giroscopies if they are attached to the rigid body... To achieve what you want neither need sensor fusion, you only need to describe the system with inputs motor velocities and output as the angle of the rigid body, then close the loop using one gyroscope in order to feedback the error.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.