Skip to content

Commit 3a79f78

Browse files
authored
Include RPyC tutorial into the docs (#237)
* Include RPyC tutorial into the docs
1 parent 7a1108f commit 3a79f78

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
:maxdepth: 3
1212

1313
spec
14+
rpyc
1415

1516
Indices and tables
1617
==================

docs/rpyc.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Working with ev3dev remotely using RPyC
2+
=======================================
3+
4+
RPyC_ (pronounced as are-pie-see), or Remote Python Call, is a transparent
5+
python library for symmetrical remote procedure calls, clustering and
6+
distributed-computing. RPyC makes use of object-proxying, a technique that
7+
employs python’s dynamic nature, to overcome the physical boundaries between
8+
processes and computers, so that remote objects can be manipulated as if they
9+
were local. Here are simple steps you need to follow in order to install and
10+
use RPyC with ev3dev:
11+
12+
1. Install RPyC both on the EV3 and on your desktop PC with the following
13+
command (depending on your operating system, you may need to use ``pip3`` or
14+
``pip`` on the PC instead of ``easy_install3``):
15+
16+
.. code-block:: shell
17+
18+
sudo easy_install3 rpyc
19+
20+
2. Create file ``rpyc_server.sh`` with the following contents on the EV3:
21+
22+
.. code-block:: shell
23+
24+
#!/bin/bash
25+
python3 `which rpyc_classic.py`
26+
27+
and make the file executable:
28+
29+
.. code-block:: shell
30+
31+
chmod +x rpyc_classic.py
32+
33+
Launch the created file either from ssh session, or from brickman.
34+
35+
3. Now you are ready to connect to the RPyC server from your desktop PC:
36+
37+
.. code-block:: py
38+
39+
import rpyc
40+
conn = rpyc.classic.connect('ev3dev') # host name or IP address of the EV3
41+
ev3 = conn.modules['ev3dev.ev3'] # import ev3dev.ev3 remotely
42+
m = ev3.LargeMotor('outA')
43+
m.run_timed(time_sp=1000, speed_sp=600)
44+
45+
You can run scripts like this from any interactive python environment, like
46+
ipython shell/notebook, spyder, pycharm, etc.
47+
48+
Some *advantages* of using RPyC with ev3dev are:
49+
50+
* It uses much less resources than running ipython notebook on EV3; RPyC server
51+
is lightweight, and only requires an IP connection to the EV3 once set up (no
52+
ssh required).
53+
* The scripts you are working with are actually stored and edited on your
54+
desktop PC, with your favorite editor/IDE.
55+
* Some robots may need much more computational power than what EV3 can give
56+
you. A notable example is the Rubics cube solver: there is an algorithm that
57+
provides almost optimal solution (in terms of number of cube rotations), but
58+
it takes more RAM than is available on EV3. With RPYC, you could run the
59+
heavy-duty computations on your desktop.
60+
61+
The most obvious *disadvantage* is latency introduced by network connection.
62+
This may be a show stopper for robots where reaction speed is essential.
63+
64+
.. _RPyC: http://rpyc.readthedocs.io/

0 commit comments

Comments
 (0)