ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
422 stars 146 forks source link

How to stop the Move Tank class #766

Open FUJI-AF opened 3 years ago

FUJI-AF commented 3 years ago

If the question is in the wrong place, delete this question.

Is there a way to stop it when I use the follow_line method of the Move Tank class with the follow_for_forever option?

For example, exit follow_line when the touch sensor is pressed.

WesleyJ-128 commented 3 years ago

There might (is a) be some weird hacky way to do this involving multiple threads/processes. However, there is no "nice" way to do this. What I ended up doing (I needed to stop after a certain number of encoder ticks) was copying the code from Motor.py into my own function, changing the condition that ends the loop, and using that. Not exactly nice, but it works and is cleaner than using multithreading for this.