ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
428 stars 145 forks source link

The new functions of follow_line and calibrate_white #670

Closed JohnHZheng closed 4 years ago

JohnHZheng commented 5 years ago

I am very eager of the new functions follow_line and calibrate_white in beta 5 code. However, the documentation of both are very limited.

There is one sample code for follow_line, but I cannot make it work. It keeps complaining the robot is moving too fast even I set to speed to 5%. Or it will complain lost the line in the move.

How do I use calibrate_white? Is it just run it once for an new environment and then it will work? Like to see some examples. Appreciate if anyone can share some knowledge.

dwalton76 commented 5 years ago

For follow_line try using this program to fine tune the kp, ki, kd constants for your robot. The ideal settings for these can vary a lot from robot to robot so they defaults may not work for yours. https://github.com/ev3dev/ev3dev-lang-python/blob/ev3dev-stretch/utils/line-follower-find-kp-ki-kd.py

Regarding calibrate_white basically yes, just run it once when the environment changes (lighting, etc) and whatever the color_sensor is looking at when you run calibrate_white is what it will consider as white until you run it calibrate_white again.

dwalton76 commented 5 years ago

FYI since these are both related to the python library https://github.com/ev3dev/ev3dev-lang-python/ would be a better place to open issues

dlech commented 5 years ago

issue has been transferred

JohnHZheng commented 5 years ago

We tried the find kpkikd in the link and spent a lot of hours by tweaking the parameters. It never worked out for us. We get values like kp=4.7, ki=0.1, and kd=3. But it will always ends with lost the line exception no matter what tweaking we can make. We did print the PDF and use an oval for our testing field. Anyone has successful stories of make follow_line really working? Thanks

dwalton76 commented 4 years ago

I had it working but granted I only ever tested on one type of robot. There must be some kinks to work out depending on the build. Can you share info on what your robot looked like?

dwalton76 commented 4 years ago

feel free to re-open with some details about the robot so we can narrow down the problem