Repository navigation
Closed
Description
4.14.96-ev3dev-2.3.2-ev3
ii python3-ev3dev 1.2.0 all Python language bindings for ev3dev
ii python3-ev3dev2 2.0.0~beta3 all Python language bindings for ev3dev
Hello!
I'm Testing to Get Value from 'TILT-ANGLE' mode of Gyro Sensor.
But The Following Error Occurs :
('TILT-RATE' Mode Is No Problem And Date Code of Sensor Is 'N6')
-Source Code-
#!/usr/bin/env python3
from ev3dev2.sensor import INPUT_1
from ev3dev2.sensor.lego import GyroSensor
from time import sleep
import sys
gy = GyroSensor(INPUT_1)
sleep(0.5)
while True:
print(gy.tilt_angle, file=sys.stderr)
#print(gy.tilt_rate, file=sys.stderr)
sleep(0.5)
-Error code-
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 261, in _set_attribute
attribute.write(value)
OSError: [Errno 22] Invalid argument
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/robot/start/01_gyro.py", line 16, in <module>
print(int(gy.tilt_angle), file=sys.stderr)
File "/usr/lib/python3/dist-packages/ev3dev2/sensor/lego.py", line 617, in tilt_angle
self._ensure_mode(self.MODE_TILT_ANG)
File "/usr/lib/python3/dist-packages/ev3dev2/sensor/__init__.py", line 280, in _ensure_mode
self.mode = mode
File "/usr/lib/python3/dist-packages/ev3dev2/sensor/__init__.py", line 182, in mode
self._mode = self.set_attr_string(self._mode, 'mode', value)
File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 321, in set_attr_string
return self._set_attribute(attribute, name, value)
File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 264, in _set_attribute
self._raise_friendly_access_error(ex, name)
File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 281, in _raise_friendly_access_error
chain_exception(ValueError("One or more arguments were out of range or invalid"), driver_error)
File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 38, in chain_exception
raise exception from cause
ValueError: One or more arguments were out of range or invalid
----------
Exited with error code 1.
Can Someone Fix This Problem by Modifying the Code?
Thank You !
Metadata
Metadata
Assignees
Labels
No labels
Activity
dlech commentedon Apr 11, 2019
What is the date stamp on your gyro sensor? (should be something like 25N5)
The tilt mode is a hidden feature that is only available on some sensors.
deopark commentedon Apr 12, 2019
Date Stamp of My Seneor Is '25N6', and the Following Code Works Well. (It Reads Value of tilt_rate Well)
As a Result, Except Value of tilt_angle(), It Can Get Value of All 'property' method(in GyroSensor class) including 'tilt_rate(self)'
Is That Possible?
dlech commentedon Apr 12, 2019
Maybe there is a typo in the mode name. What is the output of...
deopark commentedon Apr 13, 2019
Thank You for Your Reply.
Your Advice Was Right.
gy.modes
['GYRO-ANG', 'GYRO-RATE', 'GYRO-FAS', 'GYRO-G&A', 'GYRO-CAL', 'TILT-RATE', 'TILT-ANG']Mode Name is 'TILT-ANG'.
But It was defined In GyroSensor class like Below.
MODE_TILT_ANG = 'TILT-ANGLE'MODE_TILT_RATE = 'TILT-RATE'`
so, I Could Get a Value of 'Tilt_angle' by Modifying my Code like Below.
Nevertheless, How Can I Modify the GyroSensor class Variable ?
dlech commentedon Apr 13, 2019
At the beginning of your program (after the
importstatements), you can put...Fix name of EV3 Gyro sensor TILT-ANG mode
Fix name of EV3 Gyro sensor TILT-ANG mode (#618)