Skip to content

Added wait_until_not_moving()#327

Merged
ddemidov merged 2 commits intoev3dev:developfrom
dwalton76:develop-wait-until-not-moving
Jun 23, 2017
Merged

Added wait_until_not_moving()#327
ddemidov merged 2 commits intoev3dev:developfrom
dwalton76:develop-wait-until-not-moving

Conversation

@dwalton76
Copy link
Copy Markdown
Collaborator

If you call wait_while('running', timeout=1000) there are times when the state reads both running and stalled so you end up waiting for your timeout to expire even though the motor has stalled. The added function allows you to wait until the motor has stopped, either due to a stall or because it is no longer 'running'.

This helps my rubiks cube robot run a good bit faster as I don't end up waiting on so many timeouts in the wait_while calls.

Copy link
Copy Markdown
Member

@WasabiFan WasabiFan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the thinking here. Have you used this enough to be confident that it doesn't end prematurely in various motor conditions?

Comment thread ev3dev/core.py
if cond(self.state):
return True

def wait_until_not_moving(self, timeout=None):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add a documentation comment here so that it shows up on the docs site.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used it when solving a 5x5x5 cube which was about 9 minutes of off/on movement of three large motors and a medium motor. If it had exited early it would have caused the cube to jam up but it was smooth sailing so I think it is good to go.

I'll add a docstring to it in the morning.

@WasabiFan WasabiFan requested a review from ddemidov June 23, 2017 04:07
@ddemidov ddemidov merged commit 579111c into ev3dev:develop Jun 23, 2017
@ddemidov
Copy link
Copy Markdown
Member

Thanks!

@dwalton76 dwalton76 deleted the develop-wait-until-not-moving branch September 1, 2017 00:34
WasabiFan added a commit that referenced this pull request Oct 8, 2017
dwalton76 pushed a commit that referenced this pull request Nov 14, 2017
* Remove "connected" attribute

Fixes #327

* Fix things

* I'm terrible at both staging and committing everything

* Update error name and text

* Fix things

* Revert GyroBalancer changes

* Strip exception context when device isn't connected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants