question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GyroSensor.reset() failing on EV3

See original GitHub issue
  • ev3dev version: 4.14.117-ev3dev-2.3.4-ev3
  • ev3dev-lang-python version: Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description ++±==========================-==================-==================-========================================================= ii micropython-ev3dev2 2.0.0-beta5 all Python language bindings for ev3dev for MicroPython ii python3-ev3dev 1.2.0 all Python language bindings for ev3dev ii python3-ev3dev2 2.0.0-beta5 all Python language bindings for ev3dev

The GyroSensor reset method is throwing an exception for me. I’m using an EV3 with a 01N7 gyro on port 2 (I’ve tried other ports as well). I run the following code:

#!/usr/bin/env micropython

from sys import stderr
from ev3dev2.sensor.lego import GyroSensor
from ev3dev2._platform.ev3 import INPUT_2

gyro = GyroSensor()

print("gyro mode: {0}, angle {1}".format(gyro.mode, gyro.angle), file=stderr)
gyro.reset()
print("gyro mode: {0}, angle {1}".format(gyro.mode, gyro.angle), file=stderr)

while gyro.angle != 0:
	print("gyro mode: {0}, angle {1}".format(gyro.mode, gyro.angle), file=stderr)

And I get something like this as a result:

gyro mode: GYRO-ANG, angle 42
gyro mode: GYRO-ANG, angle 42
gyro mode: GYRO-ANG, angle 42
    ...<98 identical lines snipped>...
gyro mode: GYRO-ANG, angle 42
gyro mode: GYRO-ANG, angle 42
Traceback (most recent call last):
  File "/home/robot/Samples/gyro_reset_test.py", line 14, in <module>
  File "ev3dev2/sensor/lego.py", line 596, in angle
  File "ev3dev2/sensor/__init__.py", line 280, in _ensure_mode
  File "ev3dev2/sensor/__init__.py", line 182, in mode
  File "ev3dev2/__init__.py", line 322, in set_attr_string
  File "ev3dev2/__init__.py", line 264, in _set_attribute
  File "ev3dev2/__init__.py", line 264, in _set_attribute
  File "ev3dev2/__init__.py", line 282, in _raise_friendly_access_error
  File "ev3dev2/__init__.py", line 36, in chain_exception
ValueError: One or more arguments were out of range or invalid, value b'GYRO-ANG'
----------
Exited with error code 1.

When I run the code again, it returns quickly and successfully because the gyro, in fact, has now been reset to 0. So I lift up the robot and turn it a little, and get the same broken result above.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dlechcommented, Sep 22, 2019

https://github.com/ev3dev/ev3dev/issues/1269

I haven’t had time to dig into it.

0reactions
WasabiFancommented, Nov 25, 2019

Fix released in v2.0.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Fix A Gyrosensor Problem With Your LEGO EV3 Robot
Hey guys!!! This video will hopefully help you and your FLL team if your gyrosensor is flipping out and not getting your robot...
Read more >
Gyro Sensor Revisited - EV3 Lessons
“N4” sensor users can change modes without causing a recalibration. Mode changes do “reset” the angle to 0. This version of the calibration ......
Read more >
EV3 Gyro sensor erratic - leJOS - SourceForge
So I put the reset() call back in and it causes the angle change reported by the gyro to be about half the...
Read more >
Gyro Problems - FIRST Forums
In MakeCode we send a reset command and do the rate/angle switch. It seems that there are numerous variants of the gyro sensor...
Read more >
reset - LEGO® MINDSTORMS® Education EV3
Reset the gyro sensor. ... reset(): void;. To make the gyro measure rotation angle from the current position of the brick, it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found