mBot with gyro-sensor control


#1

Turning the mBot by gyro-control

The aim was to turn mBot for a specific angle, e.g. 90°.
Turning the bot by driving the motors for a specific time and power is very inaccurate, because of different friction of the ground and capacity of batteries.
A good solution is to use a gyro-sensor and to integrate the angle-velocity over the time until the specified angle is reached.
The Me-3-axis-Gyrosensor can use to do this job.
Get sure, that you use the z-axis to get the right turning angle!
I got best results, when I determined an angle of less 5 degrees, e.g. for a wished 90° turn I gave it 85°.
I think it’s because of the inertia of mass and slipperyness of ground.
You can download Arduino-program under the following link:

Arduino program

Get sure, that the ports of motors and gyro sensor in the program correspond to your mBot configuration.

Have fun!

Sigtrygg

mBot Video


#2

Thanks for sharing. Interesting to see that it works so well. I am going to give it a try in the near future.

Greetings, PinkyPepper (https://www.youtube.com/channel/UCtVRNnOm-70dMkJt9vUSGWA)


#3

Well done Sigtrygg !

I’ve done a lot of experimentation about gyro control in oder to turn for a specific angle.

I can share information with you about that
I had a look to your code, you have defined a approximative angle to assume a exact turn, for example : 84°<=> 90° or 39° <=> 45° … this come from the naturel drift of the value of the device.
In fact the Gyro Z-Value come from integration of the movement during a particular time. If you do nothing after calling primitive fonction gyro-begin() , the value is going to increase alone. more time is spending to turn and more the value will be different to the real value… so you can accelerate the move to reduce the drift but in this case the primary value will be less accurate.
In your example, you have assumed that for 120 rpm speed , the drift can be estimated to a few degrees and you have substract them to the aim angle. It can work but it depends to the speed and the power of batteries …
Another approch is to check more often and to call the gyro-begin() function each delta time (where delta is very frequent) in order to well predict the drift.

  • I can say that a exact left turn is more easy to do because the drift is going to appear in the same direction. By the way, you can turn exactly to the aim (exact degree) and complete your turn with a little more movement. The value to add depend to the number of seconds that you have used to turn.

  • The right turn is more complicated because you have to stop before your arrived :wink: In this case you have to predict the exact value with time, angle and speed …
    In my oppinion, the best way to reduce the drift of the device is to well power the gyro and to first initialize the device when it is immobilised.

Best regards


#4

hi can we see an example for your suggusted solution

I apply Sigtrygg code, but the turns are not accurate my speed is 60, not 120


Me Gyro - Piece of junk
#5

I’m keen to get mBots to make more precise turns. I see you have posted information on using the gyro sensor as well as a separate post using the compass sensor. Could either be used in performing turns? From Lego EV3 experience, gyro sensors are often affected by drift and compass sensors are often affected by electromagnetic interference. Neither appears perfect - is that your opinion for the Makeblock products as well?

From your experience, would you recommend using one or the other? Is it possible or even useful to use both in a project?


#6

I can’t give advice about compass but I guess sensor might be affected by electromagnetic interference … I can tell that gyro sensor is really affected by drift symptom … so there is no ideal solution for this kind of issue


#7

Oh what a great job. say that a exact left turn is more easy to do because the drift is going to appear in the same اجاره ون


#8

Since my last post I bought compass module and … It’s not bad at all !!! I was kindly surprised by the result. It’s necessary to configure compass after building robot structure and the configuration is valid for a place but it is quite efficient to make a control turn … more efficient than the Gyro module for turning < 20°


#9

TestBoussole.sb2 (198.2 KB)

You can try this example (Auriga mount)… don’t be affraid by the rendering on screen :wink: it won’t be complicated to wired the robot : sonar sensor + compass + embeded gyro