Steps to reproduce
- On an EV3 running ev3dev-stretch-ev3-generic-2020-04-10 attach the LEGO EV3 IR sensor to sensor port 4.
- run this program (composed in ORL):
#!/usr/bin/python
from __future__ import absolute_import
from roberta.ev3 import Hal
from ev3dev import ev3 as ev3dev
import math
import os
class BreakOutOfALoop(Exception): pass
class ContinueLoop(Exception): pass
_brickConfiguration = {
'wheel-diameter': 5.6,
'track-width': 18.0,
'actors': {
},
'sensors': {
'4':Hal.makeInfraredSensor(ev3dev.INPUT_4),
},
}
hal = Hal(_brickConfiguration)
def run():
while not hal.isKeyPressed('escape'):
if hal.getInfraredSensorSeek('4')[0] > 0:
hal.drawText("Hallo", 0, 0)
else:
hal.drawText("Goodbye", 0, 0)
def main():
try:
run()
except Exception as e:
hal.drawText('Fehler im EV3', 0, 0)
hal.drawText(e.__class__.__name__, 0, 1)
hal.drawText(str(e), 0, 2)
hal.drawText('Press any key', 0, 4)
while not hal.isKeyPressed('any'): hal.waitFor(500)
raise
if __name__ == "__main__":
main()
Expected result
The code should evaluate the first item in the list returned by getInfraredSensorSeek().
Actual result
getInfraredSensorSeek() seems to return a float.
This is the traceback:
robot@ev3dev:~$ ./lupo.py
Traceback (most recent call last):
File "./lupo.py", line 41, in <module>
main()
File "./lupo.py", line 31, in main
run()
File "./lupo.py", line 24, in run
if hal.getInfraredSensorSeek('4')[0] > 0:
TypeError: 'float' object is not subscriptable
Further information
Maybe #56 is related?
If I change the python code like this it works as expected:
24c24
< if hal.getInfraredSensorSeek('4')[0] > 0:
---
> if hal.getInfraredSensorSeek('4') > 0:
If the beacon is left of the sensor (when looking from behind the sensor) the values are positive (up to 25?) else negative (down to -25?).
Further Questions
How is the sensor supposed to work? Is it similar to lejos getSeekMode?
Steps to reproduce
Expected result
The code should evaluate the first item in the list returned by
getInfraredSensorSeek().Actual result
getInfraredSensorSeek()seems to return a float.This is the traceback:
Further information
Maybe #56 is related?
If I change the python code like this it works as expected:
If the beacon is left of the sensor (when looking from behind the sensor) the values are positive (up to 25?) else negative (down to -25?).
Further Questions
How is the sensor supposed to work? Is it similar to lejos getSeekMode?