Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ take a moment to read our suggestions for happy maintainers and
even happier users.

The ``ev3dev-stretch`` branch
---------------------
-----------------------------
Comment thread
bpmerkel marked this conversation as resolved.
Resolved

This is where the latest version of our library lives. It targets
`ev3dev-stretch`, which is currently considered a beta. Nonetheless,
Expand Down Expand Up @@ -39,13 +39,12 @@ notes.
If your change addresses an Issue
---------------------------------

Bug fixes are always welcome, especially if they are against known
Bug fixes are always welcome, especially if they are against known
issues!

When you send a pull request that addresses an issue, please add a
When you send a pull request that addresses an issue, please add a
note of the format ``Fixes #24`` in the PR so that the PR links back
to its relevant issue and will automatically close the issue when the
PR is merged.

.. _ev3dev: http://ev3dev.org

.. _ev3dev: http://ev3dev.org
126 changes: 50 additions & 76 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ A Python3 library implementing an interface for ev3dev_ devices,
letting you control motors, sensors, hardware buttons, LCD
displays and more from Python code.

If you haven't written code in Python before, you'll need to learn the language
before you can use this library.
If you haven't written code in Python before, you can certainly use this
library to help you learn the language!

Getting Started
---------------

This library runs on ev3dev_. Before continuing, make sure that you have set up
your EV3 or other ev3dev device as explained in the `ev3dev Getting Started guide`_.
Make sure you have an ev3dev-stretch version greater than ``2.2.0``. You can check
the kernel version by selecting "About" in Brickman and scrolling down to the
"kernel version". If you don't have a compatible version, `upgrade the kernel before continuing`_.
your EV3 or other ev3dev device as explained in the
`ev3dev Getting Started guide`_. Make sure you have an ev3dev-stretch version
greater than ``2.2.0``. You can check the kernel version by selecting
"About" in Brickman and scrolling down to the "kernel version".
If you don't have a compatible version,
`upgrade the kernel before continuing`_.

Usage
-----
Expand All @@ -36,8 +38,8 @@ once you have that set up.

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. If you don't know how to do that, you are probably better off
choosing the recommended option above.
your own solution. If you don't know how to do that, you are probably
better off choosing the recommended option above.

The template for a Python script
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -64,16 +66,19 @@ or additional utilities.

You should use the ``.py`` extension for your file, e.g. ``my-file.py``.

If you encounter an error such as ``/usr/bin/env: 'python3\r': No such file or directory``,
you must switch your editor's "line endings" setting for the file from "CRLF" to just "LF".
This is usually in the status bar at the bottom. For help, see `our FAQ page`_.
If you encounter an error such as
``/usr/bin/env: 'python3\r': No such file or directory``,
you must switch your editor's "line endings" setting for the file from
"CRLF" to just "LF". This is usually in the status bar at the bottom.
For help, see `our FAQ page`_.

Important: Make your script executable (non-Visual Studio Code only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

**To mark a program as executable from the command line (often an SSH session),
run** ``chmod +x my-file.py``.
Expand All @@ -85,8 +90,8 @@ Controlling the LEDs with a touch sensor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This code will turn the LEDs red whenever the touch sensor is pressed, and
back to green when it's released. Plug a touch sensor into any sensor port before
trying this out.
back to green when it's released. Plug a touch sensor into any sensor port
before trying this out.

.. code-block:: python
Expand Down Expand Up @@ -120,8 +125,8 @@ This will run a LEGO Large Motor at 75% of maximum speed for 5 rotations.
m.on_for_rotations(SpeedPercent(75), 5)
You can also run a motor for a number of degrees, an amount of time, or simply
start it and let it run until you tell it to stop. Additionally, other units are
also available. See the following pages for more information:
start it and let it run until you tell it to stop. Additionally, other units
are also available. See the following pages for more information:

- http://python-ev3dev.readthedocs.io/en/ev3dev-stretch/motors.html#ev3dev.motor.Motor.on_for_degrees
- http://python-ev3dev.readthedocs.io/en/ev3dev-stretch/motors.html#units
Expand All @@ -138,12 +143,12 @@ The simplest drive control style is with the `MoveTank` class:
# drive in a turn for 5 rotations of the outer motor
# the first two parameters can be unit classes or percentages.
tank_drive.on_for_rotations(SpeedPercent(50), SpeedPercent(75), 10)
# drive in a different turn for 3 seconds
tank_drive.on_for_seconds(SpeedPercent(60), SpeedPercent(30), 3)
There are also `MoveSteering` and `MoveJoystick` classes which provide different
styles of control. See the following pages for more information:
There are also `MoveSteering` and `MoveJoystick` classes which provide
different styles of control. See the following pages for more information:

- http://python-ev3dev.readthedocs.io/en/ev3dev-stretch/motors.html#multiple-motor-groups
- http://python-ev3dev.readthedocs.io/en/ev3dev-stretch/motors.html#units
Expand All @@ -160,74 +165,43 @@ If you want to make your robot speak, you can use the ``Sound.speak`` method:
sound = Sound()
sound.speak('Welcome to the E V 3 dev project!')
Make sure to check out the `User Resources`_ section for more detailed
information on these features and many others.
More Demo Code
~~~~~~~~~~~~~~

There are several demo programs that you can run to get acquainted with
this language binding. The programs are available
`at this GitHub site <https://github.com/ev3dev/ev3dev-lang-python-demo>`_.

You can also copy and run the programs in the `utils` directory to
understand some of the code constructs to use the EV3 motors, sensors,
LCD console, buttons, sound, and LEDs.

We also highly recommend `ev3python.com`_ where one of our community
members, @ndward, has put together a great website with detailed guides
on using this library which are targeted at beginners. If you are just
getting started with programming, we highly recommend that you check
it out at `ev3python.com`_!

Using Micropython
-----------------

Normal Python too slow? Try `Micropython`_ if it supports the features your
project needs.

User Resources
--------------
Normal Python too slow? Review `Micropython`_ to see if it supports the
features your project needs.

Library Documentation
**Class documentation for this library can be found on** `our Read the Docs page`_ **.**
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
**Class documentation for this library can be found on
** `our Read the Docs page`_ **.** You can always go there to get
Comment thread
bpmerkel marked this conversation as resolved.
Resolved
information on how you can use this library's functionality.

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.
If you are just getting started with programming, we highly recommend
that you check it out at `ev3python.com`_!

Frequently-Asked Questions
Experiencing an odd error or unsure of how to do something that seems
simple? Check our our `FAQ`_ to see if there's an existing answer.

ev3dev.org
`ev3dev.org`_ is a great resource for finding guides and tutorials on
using ev3dev, straight from the maintainers.

Support
If you are having trouble using this library, please open an issue
at `our Issues tracker`_ so that we can help you. When opening an
issue, make sure to include as much information as possible about
what you are trying to do and what you have tried. The issue template
is in place to guide you through this process.

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

You can upgrade this library from the command line as follows. Make sure
to type the password (the default is ``maker``) when prompted.

.. code-block:: bash
sudo apt-get update
sudo apt-get install --only-upgrade python3-ev3dev2
Developer Resources
-------------------

Python Package Index
The Python language has a `package repository`_ where you can find
libraries that others have written, including the `latest version of
this package`_.
--------------------------

Python 2.x and Python 3.x Compatibility
---------------------------------------
Experiencing an odd error or unsure of how to do something that seems
simple? Check our our `FAQ`_ to see if there's an existing answer.

Some versions of the ev3dev_ distribution come with both `Python 2.x`_ and `Python 3.x`_ installed
but this library is compatible only with Python 3.

.. _ev3dev: http://ev3dev.org
.. _ev3dev.org: ev3dev_
Expand Down
87 changes: 74 additions & 13 deletions docs/faq.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,81 @@
Frequently-Asked Questions
==========================

My script works when launched as ``python3 script.py`` but exits immediately or throws an error when launched from Brickman or as ``./script.py``
-------------------------------------------------------------------------------------------------------------------------------------------------
Q: Why does my Python program exit quickly or immediately throw an error?
Comment thread
bpmerkel marked this conversation as resolved.
Resolved
A: This may occur if your file includes Windows-style line endings
(CRLF--carriage-return line-feed), which are often inserted by editors on
Windows. To resolve this issue, open an SSH session and run the following
command, replacing ``<file>`` with the name of the Python file you're
using:

This may occur if your file includes Windows-style line endings, which are often
inserted by editors on Windows. To resolve this issue, open an SSH session and
run the following command, replacing ``<file>`` with the name of the Python file
you're using:
.. code:: shell
.. code:: shell
sed -i 's/\r//g' <file>
sed -i 's/\r//g' <file>
This will fix it for the copy of the file on the brick, but if you plan to edit
it again from Windows, you should configure your editor to use Unix-style
line endings (LF--line-feed). For PyCharm, you can find a guide on doing this
`here <https://www.jetbrains.com/help/pycharm/2016.2/configuring-line-separators.html>`_.
Most other editors have similar options; there may be an option for it in the
status bar at the bottom of the window or in the menu bar at the top.

This will fix it for the copy of the file on the brick, but if you plan to edit
it again from Windows you should configure your editor to use Unix-style endings.
For PyCharm, you can find a guide on doing this `here <https://www.jetbrains.com/help/pycharm/2016.2/configuring-line-separators.html>`_.
Most other editors have similar options; there may be an option for it in the
status bar at the bottom of the window or in the menu bar at the top.
Q: Where can I learn more about the ev3dev operating system?
A: `ev3dev.org`_ is a great resource for finding guides and tutorials on
using ev3dev, straight from the maintainers.

Q: How can I request support on the ev3dev2 Python library?
A: If you are having trouble using this library, please open an issue
at `our Issues tracker`_ so that we can help you. When opening an
issue, make sure to include as much information as possible about
what you are trying to do and what you have tried. The issue template
is in place to guide you through this process.

Q: How can I upgrade the library on my EV3?
A: You can upgrade this library from an Internet-connected EV3 with an
SSH shell as follows. Make sure to type the password
(the default is ``maker``) when prompted.

.. code-block:: bash
sudo apt-get update
sudo apt-get install --only-upgrade python3-ev3dev2
Q: Are there other useful Python modules to use on the EV3?
A: The Python language has a `package repository`_ where you can find
libraries that others have written, including the `latest version of
this package`_.

Q: What compatibility issues are there with the different versions of Python?
A: Some versions of the ev3dev_ distribution come with
`Python 2.x`_, `Python 3.x`_, and `micropython`_ installed,
but this library is compatible only with Python 3 and micropython.

.. _ev3dev: http://ev3dev.org
.. _ev3dev.org: ev3dev_
.. _Getting Started: ev3dev-getting-started_
.. _ev3dev Getting Started guide: ev3dev-getting-started_
.. _ev3dev-getting-started: http://www.ev3dev.org/docs/getting-started/
.. _upgrade the kernel before continuing: http://www.ev3dev.org/docs/tutorials/upgrading-ev3dev/
.. _detailed instructions for USB connections: ev3dev-usb-internet_
.. _via an SSH connection: http://www.ev3dev.org/docs/tutorials/connecting-to-ev3dev-with-ssh/
.. _ev3dev-usb-internet: http://www.ev3dev.org/docs/tutorials/connecting-to-the-internet-via-usb/
.. _our Read the Docs page: http://python-ev3dev.readthedocs.org/en/ev3dev-stretch/
.. _ev3python.com: http://ev3python.com/
.. _FAQ: http://python-ev3dev.readthedocs.io/en/ev3dev-stretch/faq.html
.. _our FAQ page: FAQ_
.. _our Issues tracker: https://github.com/ev3dev/ev3dev-lang-python/issues
.. _EXPLOR3R: demo-robot_
.. _demo-robot: http://robotsquare.com/2015/10/06/explor3r-building-instructions/
.. _robot-square: http://robotsquare.com/
.. _Python 2.x: python2_
.. _python2: https://docs.python.org/2/
.. _Python 3.x: python3_
.. _python3: https://docs.python.org/3/
.. _package repository: pypi_
.. _pypi: https://pypi.python.org/pypi
.. _latest version of this package: pypi-python-ev3dev_
.. _pypi-python-ev3dev: https://pypi.python.org/pypi/python-ev3dev2
.. _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/
.. _Micropython: http://python-ev3dev.readthedocs.io/en/ev3dev-stretch/micropython.html
Loading