QuirkyCort / gears

Generic Educational Robotics Simulator
Other
65 stars 41 forks source link

Pybricks mode color #115

Closed mrfabroa closed 2 years ago

mrfabroa commented 2 years ago

Converting blocks to Pybricks appears to not take into account the colors in Pybricks are specified using the Color class. When running Pybricks code generated from Gearsbot on a physical EV3, evaluation of color is not correct. For example color_sensor_in1.color() returns Color.RED on an EV3, however, when coded in blocks, referencing color is via name or number. So the Pybricks code below generated in Gearsbot from blocks will not work (not enter the loop when detecting red).

while color_sensor_in3.color() == 5:
    print(color_sensor_in3.color())
QuirkyCort commented 2 years ago

I've added a "color" block that generates the constants needed for color comparison. In ev3dev mode, it'll generate either the color number or color name, while in pybricks mode, it'll always generate the Color parameter constants.