Skip to content
Harco Kuppens edited this page Feb 28, 2020 · 109 revisions

Thonny-ev3dev: plugin for Thonny for EV3

The thonny-ev3dev plugin makes it easier to program the EV3 programmable LEGO brick using the Thonny Python IDE for beginners.

Thonny-ev3dev allows you to run your EV3 program easily

  • on the EV3 or
  • on the PC in a simulator (default on PC)
  • on the PC remotely steering the EV3

The thonny-ev3dev plugin comes with an ev3dev simulator:

To see the simulator in action watch the following movie: http://www.cs.ru.nl/lab/ev3dev2simulator.html .

Features thonny-ev3dev plugin

  • the thonny-ev3dev plugin just like Thonny aims to make things as easy as possible for beginning programmers. For example when uploading a script it asks to add a shebang if it is missing, and automatically makes the file executable on the EV3.

  • it allows you to run your EV3 program easily

    • on the EV3 or
    • on the PC in a simulator (default on PC)

    without the need to change a single line of code.

  • there is also an Special mode which needs special activation

    • on the PC remotely steering the EV3

This mode can be useful in special cases where you need advanced debugging on the EV3.

  • you can just use the standard ev3dev2 API in your programs:

    For ev3dev2 you use

          from ev3dev2 import auto as ev3  
    

    The older ev3dev API is not supported in the simulator, so don't use that anymore.

  • support for logging and easy retrieval of logs from the EV3. See the Example page.

  • the thonny-ev3dev plugin by default uses USB tethering but using a dialog lets you configure other ways to connect with the EV3

  • the thonny-ev3dev plugin just integrates the functionality of the ev3devcmd library into Thonny using nice buttons, menus and magic commands. This allows you to easily upload/start/download/delete/cleanup programs on the EV3 using a press of a button within Thonny.

  • the ev3dev command-line program, which also uses the ev3devcmd library, lets you

    • upload/start/stop/download/delete/cleanup programs on the EV3 using a command-line shell on your PC.
    • use just any editor together with the ev3dev command-line tool. You don't really need Thonny! All functionality is provided in the ev3devcmd library. For details see the use without IDE page.
  • instead of running the program on the PC in a simulator, you can also run the program on the PC but instead of steering the robot in the simulator it is remotely steering a real EV3. For that mode to work you only need to import the 'ev3devrpyc' module at the beginning of your python program before the ev3dev2 api is loaded. The 'ev3devrpyc' module loads a special importer which instead of loading the ev3dev modules from the simulator it proxies the ev3dev modules on a remote EV3. So when doing API calls to this proxied module all these calls are forwarded to the EV3.

  • it most be noted that before you can use the 'ev3devrpyc' module you must install an rpyc server on the EV3. This can be easily done in two ways:

    • with the Thonny IDE:
          select the menu item "Device > Install the rpyc server on the EV3."
    • with the ev3dev command line tool:
          ev3dev install_rpyc_server
  • the thonny-ev3dev plugin changes the behaviour of the "stop" button into an universal stop command. Meaning that independent of what context you EV3 program is running it does it best to stop everything running. For example when remotely steering the EV3 then the stop button stops the remote control program running on the PC. But it also executes remote rpyc calls to the EV3 to stop the motors on the EV3 which could have been left running. So it always does it best to stop everything no matter the context.

Requires ev3dev operating system on sdcard

The thonny-ev3dev plugin uses the python ev3dev library which requires an alternative operating system from a microSD card, called ev3dev, which makes it possible to run, a Debian Linux-based operating system.

Ev3dev is not firmware, but it’s more like dual-boot. The ev3dev operating system runs from a microSD card and doesn’t ever touch the firmware installed on the EV3. To switch back, you just shut down and remove the microSD card - no flashing required.

Installation

For installation of the thonny-ev3dev plugin follow the instruction at the wiki's Installation page.

After the installation try out the example.