Repository navigation
Add on_to_position(), on_for_XYZ accept additional speed inputs - #407
Conversation
|
Implements the idea floated in #406 |
|
Will fix fake-sys to have |
| return ("%d dps" % self) | ||
|
|
||
| def get_speed_pct(self, motor): | ||
| return motor.dps_to_speed(self) |
There was a problem hiding this comment.
Doesn't it seem a bit odd that we convert degrees-per-second into percentage of max speed just to convert it back? I think this is one of those cases where we should choose the native unit and base everything on that -- degrees per second are the reasonable "scientific" units whereas the percentage isn't.
There was a problem hiding this comment.
A little...but the fact that we set the motor speed in terms of dps and EV3-G uses percentages means there is going to be some funkyness. I can live with converting this one and then later having it converted back, since it means we treat all of these SpeedInteger classes consistently.
| Speed in rotations-per-second | ||
| """ | ||
|
|
||
| def __str__(self): |
| """ | ||
| Return the motor speed percentage to achieve rps (rotations-per-second) | ||
| """ | ||
| assert abs(rps) <= self._max_rps, "%s maximum rotations-per-second is %s, %s was requested" % (self, self._max_rps, rps) |
There was a problem hiding this comment.
What do you think about moving these conversions into the individual unit classes (or somewhere else)?
There was a problem hiding this comment.
sounds good...I am going to change Motor._max_rps to Motor.max_rps though since SpeedRPS will be accessing it to do the conversion
| """ | ||
| Return the motor speed percentage to achieve desired rotations-per-second | ||
| """ | ||
| return float(self/motor.max_rps) * 100 |
There was a problem hiding this comment.
Side-note: does this actually require the float conversion? As of Python 3 it'll do floating-point division anyway.
There was a problem hiding this comment.
I still do this out of python2 habit...will drop the float call
WasabiFan
left a comment
There was a problem hiding this comment.
Looks good to me! Last thing: docs on the methods that accept the new speed values?
No description provided.