Skip to content

motors API: speed_pct vs speed_dps vs speed_rps #370

@dwalton76

Description

@dwalton76

While 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions