Remote controll server with REST API. It's written in python. It uses ev3dev (alternative ev3 os).
ev3dev - ev3dev
Bottle - python http server pip install bottle
It's Track3r with phone stand.
Hardcoded values:
- ip and port (last line)
- list of motors (9th and 10th line)
- emergency stop timeout (19th line, you don't have to use it)
Everything is using GET method.
url | arguments | what it does |
---|---|---|
/ping |
none | when you first time send it it activates thread that stops motors if you don't send it |
/STOP |
none | stops motors (designed as emergency stop) |
/stop/<motor> |
motor - int, read lines 9-10 | stops motor, so it can freely rotate |
/start/<motor> |
motor - int, read lines 9-10 | starts motor, remember to set speed |
/speed/<motor>/<speed> |
motor - int, same as above, speed - int, percentage | sets speed for motor |
/_forward/<speed> |
speed - int, percentage | sets speed for both motors and starts them |
/_turn_left/<speed> |
speed - same as above | sets speed for one motor and -speed for second, then starts them |
/_turn_right/<speed> |
same as above | same as above |
/_stop |
none | sets speed for both motor to 0 and starts them (it prevents rotating freely) |
Client uses 2 files because it's easier to test that way - one file doesn't require http connection and second one doesn't require GUI. Here is GUI part: tank_client.py and here is http part: tank_client_lib.py
Hardcoded values:
- ip and port (6th line)
- delay between pings (24th line)
I've used python3. It MAY be compatible with 2.7, but I'm not sure. I will make it compatible.
Pygame - python game engine
Requests - http requests library pip3 install requests