Bot Box is a client application for https://roboportal.io. It enables peer-to-peer controls, video and audio streaming between robots and web-based control panels. In other words, if you are building the robot and planning to add remote-control functionality and real-time video/audio streaming, it is worth considering using this service.
- real time video and bidirectional audio streaming
- keyboard and gamepad controls streaming with data channel
- telemetry streaming to the platform. Position on map and battery voltage are supported
- connect robot via UART or ZeroMQ
- Prepare SD card with Raspberry Pi OS image. How To guide for Raspberry Pi Imager. We don't need Desktop version for this application.
- Enable camera, SSH (optional, but handy) and set up the WiFi with
raspi-config
. It also make sense to change the default password and set up the auto login. Default GPU memory allocation (128MB) might not be enough for real-time video converting / streaming, so it should be ~256MB. Documentation for raspi-config.. - Install git, wget and other required packages (staring from this step you'll need an internet connection)
sudo apt update
sudo apt install git wget libatomic-ops-dev pkg-config libvpx-dev libopus-dev libopusfile-dev libasound2-dev libsodium-dev libzmq3-dev libczmq-dev
- Install golang
Raspberry Pi OS 32 bit:
wget https://go.dev/dl/go1.21.0.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go1.21.0.linux-armv6l.tar.gz
rm go1.21.0.linux-armv6l.tar.gz
Raspberry Pi OS 64 bit:
wget https://go.dev/dl/go1.21.0.linux-arm64.tar.gz
sudo tar -C /usr/local -xzf go1.21.0.linux-arm64.tar.gz
rm go1.21.0.linux-arm64.tar.gz
-
And configure it:
- Open .profile
nano ~/.profile
- And insert this:
PATH=$PATH:/usr/local/go/bin GOPATH=$HOME/go
- save your changes and exit nano:
Ctrl + O
andCtrl + X
- apply your changes:
source ~/.profile
- check the installation:
go version
- Open .profile
-
Clone this repository to your Raspberry:
git clone https://github.com/roboportal/bot_box.git
-
Navigate to the repo:
cd ./bot_box
-
And compile the BotBox:
- Raspberry Pi OS 32 bit:
CGO_LDFLAGS="-latomic" go build -tags=arm
- Raspberry Pi OS 64 bit:
CGO_LDFLAGS="-latomic" go build -tags=arm64
- Mac:
go build
- Raspberry Pi OS 32 bit:
-
Create
.env
file for the configuration following the instructions. -
Run the bot by executing:
./bot_box
All the configuration of Box Bot is done by setting up .env
file. You can use .env_example
as a staring point for your config.
The list of params:
srv_url
- the WSS endpoint of roboportal.iopublic_key
andsecret_key
- the key pair obtained after the bot creationstun_urls
- comma-separated list of STUN servers URLsvideo_codec_bit_rate
- bit rate for video codecframe_format
- camera image formatvideo_width
- camera image widthvideo_frame_rate
- camera frame rateaudio_input_enabled
- enable audio streaming to roboportalaudio_output_enabled
- enable audio streaming form roboportaloutput_mode
- destination for control commands:console
|serial
|ipc
port_name
- name of the serial port to communicate with robot hardwarebaud_rate
- serial port baud ratebot_box_ipc_port
- BotBox ipc portrobot_ipc_port
- robot ipc portrobot_ipc_host
- robot ipc host namecamera_multiplexor_i2c_bus
- i2c bus number for camera multiplexer devicedebug
- enable additional logging
Let's setup supervisor. It will start Bot Box process after Raspberry Pi boot and handle restarts after possible application crashes.
- Install the supervisor:
sudo apt-get install supervisor
- The next step is to setup
supervisorctl
forpi
user:sudo nano /etc/supervisor/supervisord.conf
- Under the section
[unix_http_server]
modify and create this:
chmod=0770
chown=root:pi
- Create the config file for Bot Box:
sudo nano /etc/supervisor/conf.d/bot-box.conf
- Add there the following:
[program:bot-box]
command=/home/pi/bot_box/entrypoint.sh
directory=/home/pi/bot_box
autostart=true
autorestart=true
user=pi
killasgroup=true
stopasgroup=true
- To start the bot box run
supervisorctl start bot-box
. There are some handy commands:
supervisorctl stop bot-box
supervisorctl restart bot-box
supervisorctl tail -f bot-box stdout
supervisorctl tail -f bot-box stderr
bot_box
communicates with robot via JSON serialized messages.
Typical control message has the format: {"address": a, "controls": m}
.
In such message address 'a' is an integer number: 0 or 1. 0 is a default value, 1 is applicable to the second control in a 'Fight Mode'. When 'Fight Mode' is disabled address could be ignored by the robot hardware.
Controls message 'm' contains a payload of commands for robot hardware to execute.
For example:
-
Enable controls -
{"address":0,"controls":{"start":true}}
- this message will be sent to robot after 'Controls' are enabled in RoboPortal UI. -
Disable controls -
{"address":0,"controls":{"stop":true}}
- this message will be sent to robot after 'Controls' are disabled in UI or interrupted p2p connection. -
Control command -
{"address":0,"controls":{"l":0,"r":0,"f":100,"b":0}}
- such payload is defined by 'Controls Setup' in RoboPortal application by setting key-value pairs. The message above is used in 'Scout' robot example. It represents 'Move Forward' command.
Robot could send it's location and battery data to be presented to user as widgets using following format:
{
"id": 0,
"location": {
"lat": 49.2766275048836,
"lng": -123.13133235249737,
"headingAngle": 90
},
"battery": {
"min": 18,
"max": 25.2,
"value": 24,
"uom": "V",
"charging": False
},
"genericData": {
"customKey": "customValue"
}
}
lat
- latitude
lng
- longitude
headingAngle
- magnetic compass angle
min
- minimum possible value
max
- maximum possible value
value
- current value (charge, voltage)
uom
- unit of measure for value (V, % etc)
charging
- is charging or not
User specified key-value pairs to be displayed as text.
The Bot Box can utilize a dual camera adapter for seamless camera switching during operation. This feature is particularly useful for navigation and arm camera control or for switching between forward and backward cameras. To enable this feature, users must simply enable the 'Camera SW' widget in the robot settings.
- To enable Raspberry Pi Camera Module support on Raspbian Bullseye
Legacy Camera Mode
should be enabled withraspi-config
. - How to use USB audio devices with Raspberry Pi.
- How to Control a Robot using WebRTC - great tutorial on robot mania YouTube channel.
Visit the ROBOPORTAL YouTube channel for the tutorials.
Using with arduino and serial port
Join our Discord channel or reach out over email: [email protected]