Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
d62aeb2
Remove unused files (#345)
WasabiFan Sep 7, 2017
af4c11d
Remove hard coded outA on port4 assumption (#337)
dwalton76 Sep 7, 2017
b93b22a
Added class MotorSet (#336)
dwalton76 Sep 7, 2017
b8d780e
Exit cleanly if kociemba returns an ERROR (#350)
dwalton76 Sep 7, 2017
22d493e
Throw friendly errors (#342)
WasabiFan Sep 10, 2017
06ae05f
Stretch fixes (#366)
dwalton76 Sep 20, 2017
7ca8d03
Remove ev3dev-lang and autogen (#368)
dwalton76 Sep 21, 2017
1ca3e28
Remove demo directory (#369)
dwalton76 Sep 21, 2017
5febabf
Update motor tests to work with BrickPi (#213)
ddemidov Sep 21, 2017
6f8f6af
EV3-G API: motors (#360)
dwalton76 Sep 22, 2017
4974253
EV3-G API: touch sensor add is_released (#367)
dwalton76 Sep 23, 2017
b33533e
Use index instead of name for device ID regex group (#376)
WasabiFan Sep 26, 2017
390da18
EV3-G API infrared sensor (#374)
dwalton76 Sep 26, 2017
28b97f4
ColorSensor: Move rgb() from helper.py to core.py (#371)
dwalton76 Sep 27, 2017
1350cd5
Use /sys/class/board-info/ to detect platform type (#383)
dwalton76 Sep 29, 2017
3171043
Throw friendly error when device is disconnected (#373)
WasabiFan Sep 29, 2017
2fa6cb0
Deprecate auto_mode (#382)
dwalton76 Sep 29, 2017
6315c83
EV3-G API for Button (#386)
dwalton76 Oct 1, 2017
1d61fee
EV3-G API GyroSensor (#387)
dwalton76 Oct 1, 2017
799920e
InfraredSensor on_red_up, etc support for multiple channels (#388)
dwalton76 Oct 1, 2017
5e33dff
split core.py (#391)
dwalton76 Oct 4, 2017
10d8b03
Fix utils/ imports
dwalton76 Oct 4, 2017
9f87c9e
Move motor constants to top of motor class
dwalton76 Oct 4, 2017
b29bee1
Add missing list_device_names imports
dwalton76 Oct 4, 2017
aab7a1c
Fix steering bug (#394)
gregcowell Oct 4, 2017
3de7d34
motor: assert to validate rotations and degrees
dwalton76 Oct 4, 2017
e42f4c0
Support for 'fake' platform type
dwalton76 Oct 4, 2017
dc91c1c
Fix steering bug (#394)
gregcowell Oct 4, 2017
7a96951
Merge pull request #395 from dwalton76/misc
dwalton76 Oct 4, 2017
aeb0155
Switch fake-sys submodule from rhempel to ddemidov (#397)
dwalton76 Oct 5, 2017
ef23296
EV3-G API Sound (#396)
dwalton76 Oct 8, 2017
6bd6721
Enable using markdown for Sphinx docs (#401)
WasabiFan Oct 8, 2017
96f77b4
Added MoveJoystick (#398)
dwalton76 Oct 10, 2017
d505bb8
Add on_to_position(), on_for_XYZ accept additional speed inputs (#407)
dwalton76 Oct 11, 2017
081ea21
Add a wait_until_angle_changed_by() method to GyroSensor (#408)
gregcowell Oct 11, 2017
8e57eea
EV3-G API Display (#410)
dwalton76 Oct 13, 2017
83e41c3
Initial set of updates to documentation for Stretch
WasabiFan Oct 13, 2017
6e7b0ec
Missing build dependency for python3-pillow
ddemidov Oct 20, 2017
889fcd1
Added ColorSensor.lab(), hsv() and hls() (#417)
dwalton76 Oct 20, 2017
a00032c
Update GyroBalancer module (#421)
gregcowell Oct 25, 2017
779b921
Fix Display class on stretch. (#424)
ddemidov Oct 28, 2017
7e2f71e
fix travis link (#426)
moriarty Oct 29, 2017
bc8e5a0
Replaces print statement with built in function (#428)
moriarty Oct 29, 2017
623ff39
Add gitter.im badge (#427)
ddemidov Oct 30, 2017
923080b
Remove "connected" attribute (#402)
WasabiFan Nov 14, 2017
5516016
Proposed implementation for issue #403 (#431)
EricPobot Nov 23, 2017
78470e5
Fix description of EV3 color sensor's "ambient" mode (#436)
vagoston Dec 8, 2017
4a1720b
Remove "indices and tables" section of home page
WasabiFan Dec 21, 2017
7578c1f
Fix documentation for Motor.position_sp
ddemidov Jan 8, 2018
ee75c5c
Separate GyroBalancer drive control loop from balance loop (#432)
gregcowell Jan 11, 2018
fb7b885
Bring documentation up-to-date with the develop branch
ddemidov Jan 8, 2018
30252d9
Spell out evdev dependency for readthedocs
ddemidov Jan 8, 2018
916ecec
Don't use a list if we look for a single driver. (#444)
ensonic Jan 12, 2018
6e87447
Update navbar link
WasabiFan Jan 29, 2018
8e1bd88
Rename namespace: ev3dev -> ev3dev2 (#412)
WasabiFan Jan 29, 2018
2de6ece
ev3dev#1026: Sound.speak does not work with double quotes (#443)
amandaoneal Jan 30, 2018
39dd003
EV3-G API: ultrasonic sensor #364 (#445)
dwalton76 Jan 31, 2018
1801911
"address" argument on LEDs #422 (#446)
dwalton76 Jan 31, 2018
b8026b5
one line import #420 (#447)
dwalton76 Feb 1, 2018
c968ab1
Replace pkg_resources with __file__/glob combination (#458)
ddemidov Apr 30, 2018
70b7b44
Update display for 4.14 kernel (#462)
ddemidov May 20, 2018
ac39011
Update brickpi names for ev3dev-2.0.0 kernel (#460)
dlech May 23, 2018
5e3786e
Merge branch 'stretch'
WasabiFan Jun 10, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ __pycache__
dist
*.egg-info
RELEASE-VERSION
ev3dev/version.py
ev3dev2/version.py
build
.idea
5 changes: 1 addition & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "ev3dev-lang"]
path = ev3dev-lang
url = https://github.com/ev3dev/ev3dev-lang.git
[submodule "tests/fake-sys"]
path = tests/fake-sys
url = https://github.com/rhempel/ev3dev-lang-fake-sys.git
url = https://github.com/ddemidov/ev3dev-lang-fake-sys.git
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ python:
sudo: false
install:
- pip install Pillow
- pip install evdev
script:
- ./tests/api_tests.py
deploy:
Expand Down
139 changes: 63 additions & 76 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
Python language bindings for ev3dev
===================================

.. image:: https://travis-ci.org/rhempel/ev3dev-lang-python.svg?branch=master
:target: https://travis-ci.org/rhempel/ev3dev-lang-python
.. image:: https://travis-ci.org/ev3dev/ev3dev-lang-python.svg?branch=master
:target: https://travis-ci.org/ev3dev/ev3dev-lang-python
.. image:: https://readthedocs.org/projects/python-ev3dev/badge/?version=stable
:target: http://python-ev3dev.readthedocs.org/en/stable/?badge=stable
:alt: Documentation Status
.. image:: https://badges.gitter.im/ev3dev/chat.svg
:target: https://gitter.im/ev3dev/chat
:alt: Chat at https://gitter.im/ev3dev/chat

A Python3 library implementing an interface for ev3dev_ devices,
letting you control motors, sensors, hardware buttons, LCD
Expand Down Expand Up @@ -36,109 +39,96 @@ your Python code to a file.
Make sure that you look at the `User Resources`_ section as well for links
to documentation and larger examples.

Usage Examples
Usage
--------------

To run these minimal examples, run the Python3 interpreter from
the terminal using the ``python3`` command:
To start out, you'll need a way to work with Python. We recommend the
`ev3dev Visual Studio Code extension`_. If you're interested in using that,
check out our `Python + VSCode introduction tutorial`_ and then come back
once you have that set up.

.. code-block:: bash
Otherwise, you can can work with files via an SSH connection with an editor
such as `nano`_, use the Python interactive REPL (type ``python3``), or roll
your own solution.

$ python3
Python 3.4.2 (default, Oct 8 2014, 14:47:30)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
The template for a Python script
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ``>>>`` characters are the default prompt for Python. In the examples
below, we have removed these characters so it's easier to cut and
paste the code into your session.
Every Python program should have a few basic parts. Use this template
to get started:

Required: Import the library
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python

If you are using an EV3 brick (which is the case for most users), add the
following to the top of your file:
#!/usr/bin/env python3
from ev3dev2.motor import LargeMotor, OUTPUT_A
from ev3dev2.sensor.lego import TouchSensor
from ev3dev2.led import Leds

.. code-block:: python
# TODO: Add code here

import ev3dev.ev3 as ev3
The first line should be included in every Python program you write
for ev3dev. It allows you to run this program from Brickman, the graphical
menu that you see on the device screen. You will need to add additional classes
to the import list if you want to use other types of devices.

If you are using a BrickPi, use this line:
You should use the ``.py`` extension for your file, e.g. ``my-file.py``.

.. code-block:: python
Important: Make your script executable
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import ev3dev.brickpi as ev3
To be able to run your Python file, **your program must be executable**. If
you're using the `ev3dev Visual Studio Code extension`_, this step will be
automatically performed when you download your code to the brick. **You can
skip this step.**

**To mark a program as executable from the command line (often an SSH session),
run **``chmod +x my-file.py``.

You can now run ``my-file.py`` via the Brickman File Browser or you can run it
from the command line by preceding the file name with ``./``: ``$ ./my-file.py``

Controlling the LEDs with a touch sensor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This code will turn the left LED red whenever the touch sensor is pressed, and
back to green when it's released. Plug a touch sensor into any sensor port and
then paste in this code - you'll need to hit ``Enter`` after pasting to complete
the loop and start the program. Hit ``Ctrl-C`` to exit the loop.
back to green when it's released. Plug a touch sensor into any sensor port before
trying this out.

.. code-block:: python

ts = ev3.TouchSensor()
ts = TouchSensor()
leds = Leds()

while True:
ev3.Leds.set_color(ev3.Leds.LEFT, (ev3.Leds.GREEN, ev3.Leds.RED)[ts.value()])
if ts.is_pressed:
leds.set_color(leds.led_groups.LEFT, leds.led_colors.GREEN)
else:
leds.set_color(leds.led_groups.LEFT, leds.led_colors.RED)

Running a motor
~~~~~~~~~~~~~~~

Now plug a motor into the ``A`` port and paste this code into the Python prompt.
This little program will run the motor at 500 ticks per second, which on the EV3
"large" motors equates to around 1.4 rotations per second, for three seconds
(3000 milliseconds).
This will run a LEGO Large Motor at 75% power for 5 rotations.

.. code-block:: python

m = ev3.LargeMotor('outA')
m.run_timed(time_sp=3000, speed_sp=500)

The units for ``speed_sp`` that you see above are in "tacho ticks" per second.
On the large EV3 motor, these equate to one tick per degree, so this is 500
degress per second.


m = LargeMotor(OUTPUT_A)
m.on_for_rotations(75, 5)

Using text-to-speech
~~~~~~~~~~~~~~~~~~~~

If you want to make your robot speak, you can use the `Sound.speak` method:

.. code-block:: python
from ev3dev2.sound import Sound

ev3.Sound.speak('Welcome to the E V 3 dev project!').wait()

**To quit the Python REPL, just type** ``exit()`` **or press** ``Ctrl-D`` **.**
sound = Sound()
sound.speak('Welcome to the E V 3 dev project!').wait()

Make sure to check out the `User Resources`_ section for more detailed
information on these features and many others.

Writing Python Programs for Ev3dev
----------------------------------

Every Python program should have a few basic parts. Use this template
to get started:

.. code-block:: python

#!/usr/bin/env python3
from ev3dev.ev3 import *

# TODO: Add code here

The first two lines should be included in every Python program you write
for ev3dev. The first allows you to run this program from Brickman, while the
second imports this library.

When saving Python files, it is best to use the ``.py`` extension, e.g. ``my-file.py``.
To be able to run your Python code, **your program must be executable**. To mark a
program as executable run ``chmod +x my-file.py``. You can then run ``my-file.py``
via the Brickman File Browser or you can run it from the command line via ``$ ./my-file.py``

User Resources
--------------

Expand All @@ -147,6 +137,11 @@ Library Documentation
You can always go there to get information on how you can use this
library's functionality.

Demo Code
There are several demo programs that you can run to get acquainted with
this language binding. The programs are available at
https://github.com/ev3dev/ev3dev-lang-python-demo

ev3python.com
One of our community members, @ndward, has put together a great website
with detailed guides on using this library which are targeted at beginners.
Expand All @@ -168,17 +163,6 @@ Support
what you are trying to do and what you have tried. The issue template
is in place to guide you through this process.

Demo Robot
Laurens Valk of robot-square_ has been kind enough to allow us to
reference his excellent `EXPLOR3R`_ robot. Consider building the
`EXPLOR3R`_ and running the demo programs referenced below to get
familiar with what Python programs using this binding look like.

Demo Code
There are `demo programs`_ that you can run to get acquainted with
this language binding. The programs are designed to work with the
`EXPLOR3R`_ robot.

Upgrading this Library
----------------------

Expand Down Expand Up @@ -249,3 +233,6 @@ Python 3 and this is the only version that will be supported from here forward.
.. _pypi: https://pypi.python.org/pypi
.. _latest version of this package: pypi-python-ev3dev_
.. _pypi-python-ev3dev: https://pypi.python.org/pypi/python-ev3dev
.. _ev3dev Visual Studio Code extension: https://github.com/ev3dev/vscode-ev3dev-browser
.. _Python + VSCode introduction tutorial: https://github.com/ev3dev/vscode-hello-python
.. _nano: http://www.ev3dev.org/docs/tutorials/nano-cheat-sheet/
10 changes: 0 additions & 10 deletions autogen-config.json

This file was deleted.

2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Maintainer: Ralph Hempel <rhempel@hempeldesigngroup.com>
Section: python
Priority: optional
Standards-Version: 3.9.5
Build-Depends: python3-setuptools (>= 0.6b3), python3-all (>= 3.4), debhelper (>= 9), dh-python
Build-Depends: python3-setuptools (>= 0.6b3), python3-all (>= 3.4), debhelper (>= 9), dh-python, python3-pillow
VCS-Git: git://github.com/rhempel/ev3dev-lang-python.git
VCS-Browser: https://github.com/rhempel/ev3dev-lang-python

Expand Down
29 changes: 0 additions & 29 deletions demo/BALANC3R

This file was deleted.

28 changes: 0 additions & 28 deletions demo/EV3D4/EV3D4RemoteControl.py

This file was deleted.

29 changes: 0 additions & 29 deletions demo/EV3D4/EV3D4WebControl.py

This file was deleted.

46 changes: 0 additions & 46 deletions demo/EV3D4/README.md

This file was deleted.

Loading