Skip to content

Robot Agent is an open-source tool to manage networking in robotics systems.

License

Notifications You must be signed in to change notification settings

airalab/otaberu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About Robot Agent

Robot-agent is an open-source dev tool to setup scalable peer-to-peer network for edge devices and manage data and CI/CD pipelines over it. It is based on libp2p protocol, offering pub-sub message passing, built-in encryption, and NAT traversal, among other useful features.

You can use it on-prem without internet access to update the code/configs and get the data from your fleet, using CLI tool with terminalUI. Or in a distributed network across many deployment locations and in the cloud, with the same level of security and no additional setup. It can scale to millions of nodes and its underlying protocol is used daily in some of the largest distributed systems including Ethereum, IPFS, Polkadot, and Filecoin.

This tool is ideal for roboticists and developers looking to create distributed, scalable systems where agents can collaborate and have adaptable mesh networks with minimal manual configuration. It is also a great way to enable secure, cross-fleet communication between devices owned by different organizations.

Download agent

Download agent from https://github.com/otaberu/robot-agent/releases/latest for your platform architecture

For example: wget https://github.com/otaberu/robot-agent/releases/download/0.1.1/robot-agent-aarch64-apple-darwin

Rename it mv robot-agent-aarch64-apple-darwin robot-agent

And make executable: chmod +x robot-agent

Install rn-cli

pipx install rn-cli

Create owner key

We create a keypair for an organization owner. Public key will be place to all agents while startup. Secret key is used to sign messages for the Robot Network.

To create key, use cli command: rn keys gen owner.key

After running this command, key will be created by set path and you will see public key in base64 format: Public Key: Qwu4TtfNOcQzMJkGiYvJ4IuZSuszM0w1ViEEuAHlzo0=

To continue, let's set USER_KEY_PATH environment variable that contains path to owner key export USER_KEY_PATH=owner.key

Also, you need to add owner's public key as identifier for your robot network export OWNER_KEY=<Public Key From Two Step Before>

Create configuration for robots network

To publish config, you should firstly add address of RPC node through which you will communicate with network export AGENT_RPC=<YOUR NODE ADDRESS>.

For example, you could use Otaberu's node ws://104.131.170.157:8888.

We use cli's TUI to configure a list of robots: rn tui config robots.json

After launch, you will see an interface with robots:

Then we click "Add robot" to generate key and set info:

Save Private Key, it will be used to start agent on a device. If you have problem to select a text, try holding shift or option key

After adding all robots, press key p or click on 'publish config' in footer

Start Agent on robot

To start agent use:

./robot-agent --owner <OWNER_PUBLIC_KEY> --secret-key <ROBOT_SECRET_KEY>

Argument Description Default
--socket-filename (-s) path to create unix socket rn.socket
--key-filename (-k) path to save secret key rn.key
--port-libp2p (-l) port to use as libp2p node 8765
--bootstrap-addr (-b) multiaddress of bootstrap node
--secret-key (-s) secret key in base64 to use on startup
--owner (-0) base64 public key of the owner

To connect via our bootstrap node (not locally), use --bootstrap-addr /ip4/104.131.170.157/tcp/8765

See robots list

To see robots in network we use cli command rn robots list

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━┓
┃ PeerId                                               ┃ Name   ┃ Status  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━┩
│ 12D3KooWFGndT5BRXBSUGcQzT5zgYgyUVR6rbsVYTf4iSVA5Udob │ laptop │ Unknown │
│ 12D3KooWAgJuo1havrarkR4oy1zauEBTv9Bvg21g1V5qihhMnmEw │ robot  │ Unknown │
└──────────────────────────────────────────────────────┴────────┴─────────┘

Start docker job

We can use CLI to launch docker job. rn jobs add command accepts path to json with job description and robot name(or peer_id) as arguments.

rn jobs add <PATH_TO_JSON> <ROBOT>

Let's start example alpine:3 container (https://github.com/Smehnov/rn/blob/main/job_terminal.json):

rn jobs add job_terminal.json turtlebot-0

After sending command you will see a message with job_id

Preparing job:  521652a7-5715-496f-961d-1a0f1efbf1cc
Requests sent

See jobs list

rn jobs list <ROBOT>

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Job Id                               ┃ Job Type                ┃ Status     ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ 521652a7-5715-496f-961d-1a0f1efbf1cc │ docker-container-launch │ processing │
└──────────────────────────────────────┴─────────────────────────┴────────────┘

Connect to job's terminal

We can access job terminal if job was launched with "custom_command": "sh"

rn jobs terminal <ROBOT> <JOB_ID> rn jobs terminal turtlebot-0 521652a7-5715-496f-961d-1a0f1efbf1cc

receiver started
===TERMINAL SESSION STARTED===

/ #
/ # ls
/ # bin    etc    lib    mnt    proc   run    srv    tmp    var
dev    home   media  opt    root   sbin   sys    usr

Use Ctrl+D to exit