How do I extract the individual hsv values?(urgent) #1920
-
This is the code I'm using to extract the h,s, and v into its own little variables.
How do I then extract the individual values? Would it work on a 2 sensor system? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hello, According to the doc on the stable version of pybricks the In the stable 3.5.0 version I got the same error as you describe. Also tested the current beta firmware, no problem there. You can go to beta.pybricks.com and install the firmware there and run the program. I do not have two color sensors, so I ran this program one sensor at a time: from pybricks.pupdevices import ColorSensor
from pybricks.parameters import Port
from pybricks import version
print(version)
LEFT = False
if LEFT:
left_color_sensor = ColorSensor(Port.B)
h_left, s_left, v_left = left_color_sensor.hsv(surface=True)
print(h_left, s_left, v_left)
else:
right_color_sensor = ColorSensor(Port.A)
h_right, s_right, v_right = right_color_sensor.hsv(surface=True)
print(h_right, s_right, v_right) With this result:
Bert |
Beta Was this translation helpful? Give feedback.
-
You can do it as follows: color = left_color_sensor.hsv(surface=True)
color.h # this is the hue, and so on. In the next release, iterating like you tried will also be supported. |
Beta Was this translation helpful? Give feedback.
You can do it as follows:
In the next release, iterating like you tried will also be supported.