You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One thing I've noticed is Pybricks ColorSensor class doesn't provide a way to calibrate. I came out with a workaround for now but I wonder whether there is any "official" way to do it like what you can do with EV3 Mindstorms Color Sensor block?
philso replied:
EV3Lessons has a tutorial on how to calibrate the color sensor using the EV3 programming language. That tutorial includes some pseudocode that can be converted to MicroPython. There is a note in that tutorial that it would be best to calibrate each color sensor connected separately. The sensors are not calibrated from the factory and different examples will generally return different values when they are exposed to the same area on the mat.
The text was updated successfully, but these errors were encountered:
philso followup:
I am sorry, I don't have any real experience with the EV3 language. My sons used Robolab on the NXT when they competed. One of them developed his own program to calibrate the light sensor while the robot was traveling so the calibration would always be current and independent of ambient light. It appears that it should be possible to do something similar in MicroPython since it is a text based language with what looks like relatively easy use of variables (unlike the NXT and EV3 languages). I believe he looked at the reflected light values being returned and constantly compared them to the variables for the maximum value and the minimum value to see if there was a new maximum value or a new minimum value. After he knew he had crossed from the white area on one side of the black line to the white area on the other side of the line, he calculated the average of the maximum and the minimum values and used it as his threshold to follow the line.
Edited to add: I found a video where they describe how they did the calibration on the fly. It should be possible to adapt the algorithm to any language as long as one can use variables.
Kcinn followup:
That's exactly what I did, the challenge is how to persist the new min/max (black/white) values at the end of the calibration program, since PyBricks ColorSensor class doesn't provide a function to save it like what EV3 color sensor block does. I ended up storing the calibrated min/max values to a file on the brick, then read the values back to calculate target value before each line following run, which has been working well
from fllforums
One thing I've noticed is Pybricks ColorSensor class doesn't provide a way to calibrate. I came out with a workaround for now but I wonder whether there is any "official" way to do it like what you can do with EV3 Mindstorms Color Sensor block?
philso replied:
EV3Lessons has a tutorial on how to calibrate the color sensor using the EV3 programming language. That tutorial includes some pseudocode that can be converted to MicroPython. There is a note in that tutorial that it would be best to calibrate each color sensor connected separately. The sensors are not calibrated from the factory and different examples will generally return different values when they are exposed to the same area on the mat.
The text was updated successfully, but these errors were encountered: