Repository navigation
Flexible relative movement and improved parameter handling - #523
Conversation
also removed superfluous "float(...)"
| """ | ||
|
|
||
| if left_speed == 0 and right_speed == 0 and degrees != 0: | ||
| raise ValueError("Can't travel a nonzero distance at zero speed") |
There was a problem hiding this comment.
Two points:
- There is probably some larger than zero speed threshold where motor will stall, so zero is not that special
- I can imagine a situation where speed is set by some function (e.g. based on user input), where it may legitimately cross zero. Not sure if raising an exception would be a good idea in this case.
There was a problem hiding this comment.
I went back-and-forth on this so I'm not attached to this behavior. I agree with your points; what would you suggest the behavior be?
If we ask the motor driver to go a nonzero distance with zero speed, it will report being running stalled indefinetely, and in turn will immediately cause our wait_until_not_moving to return. So would your suggestion be to adopt that behavior? That feels weird to me, but it's consistent with our single-motor methods (#515) so probably makes sense.
There was a problem hiding this comment.
If we ask the motor driver to go a nonzero distance with zero speed, it will report being running stalled indefinetely, and in turn will immediately cause our wait_until_not_moving to return.
I think a return from wait_until_not_moving() here is an expected outcome. The speed the user asked was too small, so the motor is stalled, and is not moving.
There was a problem hiding this comment.
OK, thanks for the second opinion; I've updated the PR.
|
I'm going to merge this now and do some end-to-end testing so I can release the package today. If there are any issues here that I haven't caught, we can fix them in a separate PR. |
The primary goals here were to:
In the process, I:
_set_position_rotationsand_set_position_degrees_set_rel_position_degrees_and_speed_spand handles setting bothposition_spandspeed_spso it can normalize negativesposition_sp = position + delta; command = 'run-to-abs-pos'with usingrun-to-rel-pos. I read through EV3-G API: motors #360 where this was originally implemented, and don't see why it was done this way. (let me know if I missed something, @dwalton76)One question: On an individual motor, if you ask it to move a nonzero distance at zero speed, it will return immediately because the driver calls that a "stalling" state. However, with a motor pair, I adopted a different behavior: in that particular case it throws a
ValueError. Do others agree with this set of behaviors or should one of them be changed?Closes #516 (supersedes changes)
Fixes #504
Fixes #505
Fixes #507