question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

motors API: passing something other than speed percentage

See original GitHub issue

Today in on_for_rotations(), etc the user passes the speed_pct because this is how the EV3-G block works. I started updating the MINDCUBER demo to use the new API but I end up doing the following all over the place (two lines, one to cald the speed_pct and a second to call the API)

        speed_pct = self.turntable.dps_to_speed(MindCuber.rotate_speed)
        self.turntable.on_to_position(speed_pct, temp_pos)

which works just fine but doesn’t look super clean (side note, on_to_position() is new). What if the on_to_XYZ() methods accepted either speed_pct or (speed_type, speed_value) tuple such as the following

        self.turntable.on_to_position(('dps', MindCuber.rotate_speed), temp_pos)

Valid types there could be ‘dps’, ‘dpm’, ‘rps’, or ‘rpm’.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dwalton76commented, Oct 10, 2017

Another option would be something like

class SpeedRPS(int):
    pass

class SpeedRPM(int):
    pass

class SpeedDPS(int):
    pass

class SpeedDPM(int):
    pass

and then the user would call via

    motor.on_for_rotations(SpeedRPS(400), 3)

That does look a little less hackish doesn’t it

0reactions
dwalton76commented, Oct 10, 2017

yeah but I bet most programs only use one speed unit so hopefully won’t be bad…new code posted

Read more comments on GitHub >

github_iconTop Results From Across the Web

Motors C++ API — PROS for V5 3.7.3 documentation
This is designed to map easily to the input from the controller's analog stick for simple opcontrol use. The actual behavior of the...
Read more >
FMCSA revs up plan to mandate speed limits on truck engines
Federal regulators plan to propose setting a truck speed limit using electronic engine devices in a proposed rule anticipated in 2023.
Read more >
VEX V5 C++ API: vex::motor Class Reference - Robot Mesh
Sets the velocity of the motor based on the parameters set in the command. This command will not run the motor. Any subsequent...
Read more >
What is an API: Definition, Types, Specifications, Documentation
API is a set of programming code that enables data transmission between one software product and another. It also contains terms of this ......
Read more >
Techniques for Drivers to Conserve Fuel
Reducing your speed by 5 to 10 mph can improve fuel economy by 7%–14%. Using cruise control on the highway can help drivers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found