motors API: speed_pct vs speed_dps vs speed_rps
See original GitHub issueWhile working on #353 #360 one thing we did not address was the API for specifying the motor speed in something other than speed_pct. The other two we want are degrees per second
and rotations per second
.
Some ideas that were floated:
Option 1 How about we make the default units % just like EV3-G, plus introduce scaling factor constants for those who want scientific units.
# run the motor at 50% of max speed
m.run(50)
# run the motor at 400 degrees/second
m.run(400 * m.DPS)
# run the motor at 60 RPM
m.run(60 * m.RPM)
Option 2 why not m.run(speed_pct=50), m.run(dps=400), and m.run(rpm=60)? If we define run as
def run(self, speed_pct=None, dps=None, rpm=None)
We have other parameters that need to be passed in though (speed) so basically everything becomes a positional arg. So the user would do one of
m.on_for_degrees(speed_pct=40, degrees=720)
m.on_for_degrees(speed_dps=90, degrees=720)
m.on_for_degrees(speed_rps=0.25, degrees=720)
Issue Analytics
- State:
- Created 6 years ago
- Comments:26 (17 by maintainers)
Top Results From Across the Web
Motor classes — python-ev3dev 2.1.0.post1 documentation
The motor class provides a uniform interface for using motors with positional and directional feedback such as the EV3 and NXT motors.
Read more >Using Motors - EV3dev Python - Google Sites
Motors are normally incapable of reliably and accurately achieving their rated maximum ... from ev3dev2.motor import SpeedDPS, SpeedRPM, SpeedRPS, SpeedDPM.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Strongly suggest you implement an EV3G compatible API as a loadable helper module - leave the basic API as is because it’s compatible across many scripting languages
I’ve been working on translating an EV3-G program for the last couple days and I am finding that having the API exactly the same as EV3-G is really the most useful thing to do and perhaps more importantly, it is just really fun.
What I mean by exactly is having positional arguments in the same order as the EV3-G software that take the exact same value. I thought I would like to have fancy extra features or tweak things (like changing names) to make it “better”, but I am finding that in practice, those kinds of changes are getting in the way (with the exception of correcting things that are just plain wrong in EV3-G, like using the name
speed
instead ofpower
). So, I would say put this issue on the back burner and move on to something else. Once we have the basics, we can start using the library and find what we are really missing and add more if needed. By then, we should have a better idea of what feels right instead of just trying to guess like we are now.Also…