Control RPi robot using scratch-like(visual programming) web interface.
-
Clone repository to your RPi
git clone https://github.com/ret7020/WebRoboBlock
-
Install modules
pip3 install -r requirements.txt
-
Start flask server
python3 main.py
-
Check your local ip
ip a
-
Open web interface located here: http://YOUR_RPI_IP:8080/
But you can use ngrok tunnel, read more in Configuring section. -
Play!
Your code maked from blocks "compiling" to JSON format:
[
{
action: "forward",
distance: 10,
speed: 1000,
sensor_id: -1,
sensor_val: 1
},
{
action: "forward",
distance: 12,
speed: 2000,
sensor_id: -1,
sensor_val: 1
}
]
Each block generates block with different arguments(but there is an "action" argument en each)!
After "compiling" you can deploy your code to execution on real robot. IDE(web site) hosted on real robot. When you deploy project compiled json file sended via POST to web server and then this JSON going through interpreter. Each command executed one by one.
Interpreter code file interpreter.py
Communication with arduino and RPI library Repo
All settings stored in conf.json file.
{ "web_port": 8080, #WebServer port; "tg_bot_token": "", #API token for your telegram bot "tg_user_chat_to_send": 1, # "camera_enabled": true, #Enable/Disable camera shot from web site "camera_id": 1, #id of camera(used in cv2.VideoCapture()) "ngrok_start": false #Start http tunnel using ngrok }To use 80 port you have to run main.py with root privileges(
sudo main.py
)
- Create Telegram bot with @BotFather
- Copy token and insert into config file(tg_bot_token section).
- Init the dialog with your bot(open your bot and click "start" button).
- Get your chat id with @chatIDrobot bot.
- Copy obtained token and insert into config file(tg_user_chat_to_send section).