Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[autogen][py] Provide convenience functions for motor commands #75

Merged
merged 1 commit into from
May 8, 2015
Merged

[autogen][py] Provide convenience functions for motor commands #75

merged 1 commit into from
May 8, 2015

Conversation

ddemidov
Copy link
Member

@ddemidov ddemidov commented May 8, 2015

This is in continuation of @dlech's comment in #51.

Each motor class (tacho-motor, dc-motor, servo-motor) provides a set of methods corresponding to possible commands. The methods take variable number of keyworded parameters. Each parameter should correspond to writable attribute of the motor. The attributes will be set before applying the command.

The methods are generated automatically based on the list of possible commands in spec.json.

Example:

>>> m = large_motor()
>>> m.run_timed(time_sp=1000, duty_cycle_sp=75)

The second line is equivalent to

>>> m.time_sp = 1000
>>> m.duty_cycle_sp = 75
>>> m.command = 'run-timed'

Each motor class (tacho-motor, dc-motor, servo-motor) provides a set of
methods corresponding to possible commands. The methods take variable
number of keyworded parameters. Each parameter should correspond to
writable attribute of the motor. The attributes will be set before
setting the command.

The methods are generated automatically based on the list of possible
commands in spec.json.

Example:

    >>> m = large_motor()
    >>> m.run_timed(time_sp=1000, duty_cycle_sp=75)

The second line is equivalent to

    >>> m.time_sp = 1000
    >>> m.duty_cycle_sp = 75
    >>> m.command = 'run-timed'
@ddemidov
Copy link
Member Author

ddemidov commented May 8, 2015

I am still thinking of how to achieve same elegance in C++ though.

WasabiFan added a commit that referenced this pull request May 8, 2015
[autogen][py] Provide convenience functions for motor commands
@WasabiFan WasabiFan merged commit b3de91d into ev3dev:develop May 8, 2015
@ddemidov ddemidov deleted the python-motor-commands branch May 8, 2015 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants