EV3 gyro sensor error


I am using EV3 gyro sensor for rotation of my vehicle and nxt ultrasonic sensor for obstruction detection. Please find the link to the video showing the motion of the robot and the codes for running the robot. The code is just move forward till there is obstruction. On seeing obstruction rotate right(turn90), then rotate left(turn -90) and again move forward. The robot works perfectly for the early iterations and then begins to rotate on getting the gyro error.
can you please tell what is the cause of this problem?
link to files-https://drive.google.com/open?id=0ByVO7RzMgAuzeFRteFVwQjBGNE0


A good place to start would be to make sure you use batteries when running motors. If you try running motors when powered only from USB power, the voltage is likely to be unstable, and many unpredictable things can happen.

Gyro sensors (such as the EV3 gyro) measure rate of rotation and integrate to determine accumulated angle. Essentially they are dead-reckoning, and that means errors will accumulate. To get truly absolute angle, you will need a gyro and compass with something like a Kalman filter algorithm.


I am Brickpi+. I have already implemented filter to rectify the sudden errors that occurs during measurement. The problem is after some iterations it starts giving error continuously. is there a way to reset the sensor.


Hi @palashhalder1988,

Can you give us more details on what you’re doing?
Things like code, physical setup, the power supply you’re using, the image, etc.

Without a really clear description of your issue, our job becomes a lot harder, if not impossible.

Thank you!


I have already attached the video, code and console data for the project in the link. I am using AC supply.


Actually i am making robot which can plan its path to the goal defined. I was planning to use the gyro sensor for turning the robot. the robot turns perfectly for the first few times then it just start rotating on seeing an obstacle (obstacle detection using ultrasonic sensor).


I’m not quite sure if we are talking about Gyro drift, the most common sensor error of gyro sensors.
How much are your errorneous readings (degrees per minute, no sensor reset in between), measured at stand-still?
a) directly the 1st minute after starting
b) after 3 minutes
c) after 6 minutes
d) after 10 minutes ?

then the same, after intermediately turning manually exactly 360 degees?


i have not measured the error in the value of gyro sensor. The problem is occasional errors can be rectified using filters. the problem arises after going for some iteration the gyro shows “-3” as the reading continuously as such the vehicle starts rotating. the program attached is actually a part of a bigger program where the vehicle will start moving after receiving its start and end coordinates in a text file in local storage.

the problem doesn’t have any pattern and it arises at any point after running the program. I actually need the value of the sensor for error correction i will use sensor fusion in later part of the projecct


Hi @palashhalder1988,

I’m not sure if I can fully comprehend your post, but I assume you’re having issues with the robot’s direction.
You say this is a consequence of the fact that the gyro sensor isn’t providing good values.

I don’t have the right tools to test with, so I can only give you suggestions.
Can you try to output the gyro's values into a graphical visualizer and then compare it while rotating the sensor in the air?
This should tell us if the problem is within the code you’ve shared or with the gyro sensor.

Thank you!


HI, let me rephrase the issue:

  1. I have built a “tank” type vehicle. it has one Ultrasonic sensor for obstruction detection and one gyro for detection of vehicle rotation. the vehicle moves in a 800 X 800 workspace.
  2. for localisation of the vehicle in the workspace the vehicle measures the distance from the end points of workspace.
  3. the actual code contains a code which divides the workspace into grids of size 200 X 200 and then runs an algorithm similar to A* algorithm to get the path to goal point. as such after localizing itself the vehicle get the direction of movement namely, ‘U’, ‘D’, ‘L’, ‘R’. the vehicle moves from one grid to another grid.
  4. for ‘U’ the vehicle must maintain a gyro value close to ‘0’. for D the gyro should be ‘180’ , for L it should be ‘-90’ and for R it should be ‘90’.
  5. for turning the robot i just rotate the two base motors in opposite direction.
  6. the problem is suppose after localizing the direction of movement comes to L. then the vehicle must rotate to gryo=-90. In the process of doing the same it repetitively starts to get the value ‘-3’. the motors continue to rotate in opposite direction and the robot goes into spin.
  7. the issue is shown in the video where after few iterations the robot starts to spin.
  8. the error value in gyro can occur at any instant after running the program.
    Please note that the gyro gives correct value when i am using the example code given by Dexter industries to test gyro. Also I am using AC power to run the vehicle. If something is wrong with my code please point it out.