when i try to simulate my code or even the standard race.py code i always get exceptions and the robot doesn't follow any track, exceptions says :
Exception in thread 1:
Traceback (most recent call last):
File "C:\Users\Mohamed\Anaconda2\lib\threading.py", line 801, in __bootstrap_i
nner
self.run()
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 463, in
run
self.ProcessImage(image)
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 787, in
ProcessImage
if self.lastFrame != None:
ValueError: The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all()
Exception in thread 3:
Traceback (most recent call last):
File "C:\Users\Mohamed\Anaconda2\lib\threading.py", line 801, in __bootstrap_i
nner
self.run()
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 463, in
run
self.ProcessImage(image)
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 787, in
ProcessImage
if self.lastFrame != None:
ValueError: The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all()
Exception in thread 4:
Traceback (most recent call last):
File "C:\Users\Mohamed\Anaconda2\lib\threading.py", line 801, in __bootstrap_i
nner
self.run()
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 463, in
run
self.ProcessImage(image)
File "C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py", line 787, in
ProcessImage
if self.lastFrame != None:
ValueError: The truth value of an array with more than one element is ambiguous.
Use a.any() or a.all()
and i also get some warnings :
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:802: RuntimeWarning: d
ivide by zero encountered in divide
adjustment = 255.0 / maximum
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:881: RuntimeWarning: d
ivide by zero encountered in divide
autoGainR = Settings.targetLevel / rAll.max()
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:882: RuntimeWarning: d
ivide by zero encountered in divide
autoGainG = Settings.targetLevel / gAll.max()
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:883: RuntimeWarning: d
ivide by zero encountered in divide
autoGainB = Settings.targetLevel / bAll.max()
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:885: RuntimeWarning: i
nvalid value encountered in multiply
red = (red - dropR) * Settings.redGain * autoGainR
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:886: RuntimeWarning: i
nvalid value encountered in multiply
green = (green - dropG) * Settings.greenGain * autoGainG
C:\Users\Mohamed\Downloads\raceyourcode\ImageProcessor.py:887: RuntimeWarning: i
nvalid value encountered in multiply
blue = (blue - dropB) * Settings.blueGain * autoGainB
any help ?
it was simply solved by adding numpy.all() containing line 787
Put simply older versions of Numpy (like on the robots) are happy with the
!= None
syntax which works with most other Python objects. In one of the updates they changed it so that it fails instead.Using
numpy.all()
should work okay, although it does read slightly strange.The correct replacement which has the intended behaviour in all circumstances would be:
This way is both easier to read and should work fine in all versions of Numpy :)
Have the warnings gone now that the exceptions have been fixed?
Hello,
I replace in the imageprocessor.py !=None by is not None.
I still have warning and my bot doesn't start.
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:800: RuntimeWarning: divide by zero encountered in divide
adjustment = 255.0 / maximum
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:874: RuntimeWarning: divide by zero encountered in divide
autoGainR = Settings.targetLevel / rAll.max()
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:875: RuntimeWarning: divide by zero encountered in divide
autoGainG = Settings.targetLevel / gAll.max()
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:876: RuntimeWarning: divide by zero encountered in divide
autoGainB = Settings.targetLevel / bAll.max()
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:878: RuntimeWarning: invali value encountered in multiply
red = (red - dropR) * Settings.redGain * autoGainR
C:\Users\tdtran\Desktop\formulapi\ImageProcessor.py:879: RuntimeWarning: invalid value encountered in multiply
green = (green - dropG) * Settings.greenGain * autoGainG
1C:\Users\tdtran\Desktop\formulapi\ImageP
rocessor.py:880: RuntimeWarning: invali d value encountered in multiply
blue = (blue - dropB) * Settings.blueGain * autoGainB
6:11:14.959000 StartDetailedLoging()
Thanks for the helps,
Tri Duc
I received all the same runtime warnings every time I ran the simulator. They didn’t affect the simulator. I finally fixed them mid way through last season and there was no measurable improvement observed.
Are you trying to run the simulatorFull.py from the same computer you are running the Java simulator on? Everything worked better for me when I ran simulatorFull.py from the Pi and the Java simulator on my Mac.
Add new comment