README.md 3.77 KB
Newer Older
Cédric Bonhomme's avatar
Cédric Bonhomme committed
1 2 3 4 5
EV3WebController
================

# Presentation

6 7
[EV3WebController](https://bitbucket.org/cedricbonhomme/ev3webcontroller)
provides a Web interface in order to control the Lego Mindstorms EV3 robot.
Cédric Bonhomme's avatar
Cédric Bonhomme committed
8 9 10

Tested with Python 3.4 and Python 2.7.

11 12
# Installation

Cédric Bonhomme's avatar
Cédric Bonhomme committed
13 14
## Installation of the system

15 16 17 18
First, install [ev3dev](http://www.ev3dev.org) on your
Lego Mindstorms EV3 brick.

For the network I recommend the Wireless Nano Adapter *Edimax EW-7811Un* which
19
is working perfectly out of the box.
20

Cédric Bonhomme's avatar
Cédric Bonhomme committed
21 22
## Installation of EV3WebController and the requirements

23 24 25
    $ ssh root@192.168.1.16
    $ wget https://bootstrap.pypa.io/get-pip.py
    $ python get-pip.py
Cédric Bonhomme's avatar
Cédric Bonhomme committed
26 27 28 29
    $ wget https://bitbucket.org/cedricbonhomme/ev3webcontroller/get/master.tar.gz
    $ tar -xzvf master.tar.gz
    $ rm master.tar.gz
    $ mv cedricbonhomme-ev3webcontroller-* EV3WebController
Cédric Bonhomme's avatar
Cédric Bonhomme committed
30
    $ cd EV3WebController/
31
    $ pip install -r requirements.txt
32 33 34 35 36 37 38
    $ wget https://github.com/topikachu/python-ev3/archive/master.tar.gz
    $ tar -xzvf master.tar.gz
    $ rm master.tar.gz
    $ cd python-ev3-master/
    $ python setup.py install
    $ cd ..
    $ rm -Rf python-ev3-master/
Cédric Bonhomme's avatar
Cédric Bonhomme committed
39
    $ cp conf/conf.cfg-sample conf/conf.cfg
40

Cédric Bonhomme's avatar
Cédric Bonhomme committed
41
Launch EV3WebController:
42 43

    $ python runserver.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
    * Restarting with stat

# Launch EV3WebController at boot

In order to get EV3WebController start at boot, just create a new systemd
service.

First create the file */etc/systemd/system/brickrc.service*:

    [Unit]
    Description=EV3WebController
    After=multi-user.target

    [Install]
    WantedBy=multi-user.target

    [Service]
    Type=oneshot
    RemainAfterExit=yes
    ExecStart=/root/EV3WebController/run.sh

Then enable the new service:

    $ systemctl daemon-reload
    $ systemctl enable brickrc.service
    $ systemctl restart brickrc.service

72

73
# How to use the interface
Cédric Bonhomme's avatar
Cédric Bonhomme committed
74

75 76
## Move the robot

Cédric Bonhomme's avatar
Cédric Bonhomme committed
77
    $ GET http://192.168.1.16:5000/move/<direction>/<speed=800>
78

Cédric Bonhomme's avatar
Cédric Bonhomme committed
79
The value of *speed* is optional. Default is 800.
80 81 82 83 84 85 86 87 88 89 90

Acceptable values for *direction*:

* forward;
* backward;
* left;
* right;
* stop.

### Examples

91 92
#### Action successfully completed

Cédric Bonhomme's avatar
Cédric Bonhomme committed
93 94
    $ GET http://192.168.1.16:5000/move/forward
    {"action": "move", "direction": "forward", "message": "OK"}
95 96 97

In this case the HTTP status code returned is 200.

98 99
#### Unable to understand the request

Cédric Bonhomme's avatar
Cédric Bonhomme committed
100
    $ GET http://192.168.1.16:5000/move/nowhere
101 102 103 104
    {"message": "Unknown direction", "direction": "nowhere", "action": "move"}

In this case the HTTP status code returned is 400.

105 106 107 108
#### Hit a wall

    $ GET http://192.168.1.16:5000/move/forward?blocks=25
    {"action": "move", "direction": "forward", "message": "hit_wall"}
109

Cédric Bonhomme's avatar
Cédric Bonhomme committed
110 111 112
If a wall is detected the current action is stopped and the server
will return the message "hit_wall".

Cédric Bonhomme's avatar
Typo.  
Cédric Bonhomme committed
113
#### End of the labyrinth
Cédric Bonhomme's avatar
Cédric Bonhomme committed
114 115 116 117

    $ GET http://192.168.1.16:5000/move/forward?blocks=20
    {"action": "move", "direction": "forward", "message": "in_target"}

Cédric Bonhomme's avatar
Cédric Bonhomme committed
118 119 120
If the red color is detected the current action is stopped and the server
will return the message "in_target".

121
## Retrieve values from sensors (not yet implemented)
122

Cédric Bonhomme's avatar
Cédric Bonhomme committed
123
    $ GET http://192.168.1.16:5000/sensor/<sensor_name>
124 125 126 127 128 129 130 131

Acceptable values for *sensor_name*:

* button;
* ir_sensor.

### Examples

Cédric Bonhomme's avatar
Cédric Bonhomme committed
132
    $ GET http://192.168.1.16:5000/sensor/ir_sensor
133
    {"distance": 12}
Cédric Bonhomme's avatar
Cédric Bonhomme committed
134 135
    $ GET http://192.168.1.16:5000/sensor/color_sensor
    {"rgb": [78, 31, 15], "mode": "RGB-RAW"}
136

137 138 139 140 141
# Donation

If you wish and if you like *EV3WebController*, you can donate via bitcoin
[1GVmhR9fbBeEh7rP1qNq76jWArDdDQ3otZ](https://blockexplorer.com/address/1GVmhR9fbBeEh7rP1qNq76jWArDdDQ3otZ).
Thank you!
142 143 144

# License

Cédric Bonhomme's avatar
typo.  
Cédric Bonhomme committed
145
EV3WebController is free software released under the "Modified BSD license"
146

147
Copyright (c) 2014-2015 Cédric Bonhomme - https://www.cedricbonhomme.org
Cédric Bonhomme's avatar
Cédric Bonhomme committed
148 149 150

# Contact

151
[Cédric Bonhomme](https://www.cedricbonhomme.org).