We All Code Robot
Table of Contents
Requirements
- Docker
- Python >= 3.7
- Pip >= 10.0
- VCP Drivers (MacOS)
Install
Unfortunately, sharing USB devices between MacOS and Docker is not yet possible, so this project requires Python and Pip to be installed in addition to the VCP Drivers for USB serial communication.
make install
Flash Firmware
make firmware
make flash
The last command above will hang and eventually show a message stating
lua: cannot open init.lua
. When you see this message, you can hit ctrl-]
to
complete this step. This is because there is firmware but no software.
Common Issues:
- Sometimes you'll need to hit enter to see the prompt.
- Sometimes on Linux you need to unplug and replug the usb cable after flashing.
Upload Software
make upload <robotname>
When complete, you can hit ctrl-]
.
Setup
For the first two minutes that the robot is turned on, an open WiFi network
named We All Code [<robotname>]
will be broadcast. Join the network to be
brought to a captive portal setup page. On this page you can instruct the robot
which WiFi network it should join on boot. These settings will be saved until
changed manually.
API
Once attached to a network, the robot will listen for HTTP requests at
http://<robotname>.local
with the following endpoints:
Endpoint | Description |
---|---|
/ |
Shows the WiFi Setup page |
/hello |
Returns a minimal hello response |
/command |
Accepts commands for the robot's wheels, LED, and buzzer |
/update |
Triggers a code update |
/wifi |
WiFi Setup submission page |
/command
Endpoint: Note: this endpoint can be upgraded to a websocket and will accept line-delimited commands in the form of a search string. Alternatively, you can
POST
to this endpoint and send data in the body.
Param | Description | Type | Values | Example |
---|---|---|---|---|
w |
wheels | mixed |
left,right (-100 to 100) |
w=87,100 |
l |
led | mixed |
r,g,b , on ,off
|
l=255,0,34 |
b |
buzzer | mixed |
hz,period , on ,off
|
b=1000,1023 |
s |
sleep | int |
hz,period ,on ,off
|
b=1000,1023 |
Examples:
GET http://robotname.local/stack?w=100,100l=255,255,255
POST http://robotname.local/stack
body:
w=100,100&l=255,255,255&b=1000,1023
s=1000
w=0,0&l=off&b=off
GET ws://robotname.local/command
data:
w=100,100&l=255,255,255&b=1000,1023
s=1000
w=0,0&l=off&b=off
data:
w=80,80&l=128,128,128&b=500,512
s=500
w=0,0&l=off&b=off
/update
Endpoint: Note: downloading the
.img
file from an https source is not yet supported as the SSL connection requires too much memory.
Param | Type | Description | Default |
---|---|---|---|
host | string | Domain name | robots.weallcode.org |
dir | string | Path to file | /lfs |
image | string | File name | flash.img |
Examples:
http://robotname.local/update
http://robotname.local/update?host=wac.fyi&dir=/&image=flash.img
/wifi
Endpoint: Note: Only WiFi WPA2 networks are currently supported.
Param | Type | Description |
---|---|---|
ssid | string | WiFi network name |
padd | string | WiFi network password |
Examples:
http://robotname.local/wifi?ssid=We+All+WiFi&pass=Coder4life
Diagram
Maintainers
Contributing
PRs accepted.
Small note: If editing the README, please conform to the standard-readme specification.
License
MIT © 2019 We All Code