Learn how to configure multiple OctoMY™ Agents (robots) to work together, communicate, and coordinate their actions.
Pro Tip
Start with just two Agents to understand the basics of peer communication. Add more Agents once you're comfortable with pairing, messaging, and coordination patterns. Debugging a swarm of robots is much harder than debugging two!
Multi-Agent setups enable:
Multi-Agent Network
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Agent 1 │◄───►│ Agent 2 │◄───►│ Agent 3 │
│ (Scout) │ │ (Worker) │ │ (Worker) │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
└───────────────────┼───────────────────┘
│
┌──────┴──────┐
│ Hub │ (optional)
│ Coordinator │
└─────────────┘
Agents communicate directly with each other:
Agent A ◄──────────► Agent B
│ │
└──────► Agent C ◄───┘
Pros:
Cons:
A Hub manages all agents:
┌───────────┐
│ Hub │
└─────┬─────┘
┌──────────┼──────────┐
▼ ▼ ▼
┌────────┐ ┌────────┐ ┌────────┐
│ Agent A│ │ Agent B│ │ Agent C│
└────────┘ └────────┘ └────────┘
Pros:
Cons:
Did You Know?
OctoMY™'s peer-to-peer communication uses the same encrypted protocol as Agent-Remote connections. This means Agents can securely share sensor data and coordinate actions without worrying about eavesdropping, even on untrusted networks.
Mix of direct and Hub communication:
┌───────────┐
│ Hub │
└─────┬─────┘
│
┌──────────┼──────────┐
▼ ▼ ▼
┌────────┐ ┌────────┐ ┌────────┐
│ Agent A│◄┤ Agent B├►│ Agent C│
└────────┘ └────────┘ └────────┘
└──────────────────────┘
(direct peer links)
Each Agent needs a distinct personality:
Agent 1: "Scout Alpha" - Exploration role
Agent 2: "Worker Beta" - Task execution
Agent 3: "Worker Gamma" - Task execution
Ensure all Agents can reach each other:
┌─────────────────────────────────────────────┐
│ Network Settings - Scout Alpha │
├─────────────────────────────────────────────┤
│ │
│ Local Address: 192.168.1.101 │
│ Listen Port: 8124 │
│ │
│ Discovery: │
│ [✓] Enable multicast discovery │
│ [✓] Auto-connect to known peers │
│ │
│ Peer Timeout: [30___] seconds │
│ │
└─────────────────────────────────────────────┘
┌─────────────────────────────────────────────┐
│ Pair with Agent │
├─────────────────────────────────────────────┤
│ │
│ Discovered Agents: │
│ │
│ ┌────────────────────────────────────┐ │
│ │ 🤖 Worker Beta │ │
│ │ 192.168.1.102:8124 │ │
│ │ [Pair] │ │
│ ├────────────────────────────────────┤ │
│ │ 🤖 Worker Gamma │ │
│ │ 192.168.1.103:8124 │ │
│ │ [Pair] │ │
│ └────────────────────────────────────┘ │
│ │
│ [Refresh] [Manual Address] │
│ │
└─────────────────────────────────────────────┘
Set appropriate trust levels for coordination:
┌─────────────────────────────────────────────┐
│ Agent Trust: Worker Beta │
├─────────────────────────────────────────────┤
│ │
│ Trust Level: │
│ ○ Handshake - View status only │
│ ○ Trust - Receive commands │
│ ● Depend - Full coordination │
│ │
│ Permissions: │
│ [✓] Share sensor data │
│ [✓] Receive plan commands │
│ [✓] Coordinate movements │
│ [✓] Emergency stop authority │
│ │
│ [Save] │
│ │
└─────────────────────────────────────────────┘
Security Consideration
The "Depend" trust level grants significant authority to peer Agents, including emergency stop capability. Only use this level with Agents you control. For third-party or experimental robots, start with "Trust" level and upgrade once you've verified their behavior.
Agents can share sensor readings:
plan CoordinatedSearch {
// Read own sensors
var my_distance = sensors.distance.front
// Read peer sensor data
var peer_distance = peers["Worker Beta"].sensors.distance.front
if my_distance < 30 && peer_distance < 30 {
// Both see obstacle - coordinate avoidance
broadcast("obstacle_detected", my_position)
}
}
Send messages between Agents:
plan ScoutAndReport {
// Scout role
loop {
var reading = sensors.distance.front
if reading < 20 {
// Found something - notify workers
send_to("Worker Beta", "target_found", {
"location": my_position,
"distance": reading
})
}
delay(100)
}
}
Handle incoming messages:
plan WorkerRole {
// Handle messages from Scout
on_message("target_found") { msg ->
log("Target at: " + msg.location)
navigate_to(msg.location)
}
loop {
// Normal worker behavior
do_work()
delay(100)
}
}
One Agent leads, others follow:
// Leader Agent
plan Leader {
loop {
var heading = plan_route()
broadcast("follow_heading", heading)
drive_heading(heading)
delay(100)
}
}
// Follower Agent
plan Follower {
var leader_heading = 0
on_message("follow_heading") { h ->
leader_heading = h
}
loop {
drive_heading(leader_heading)
delay(100)
}
}
Distribute tasks among workers:
// Coordinator (Hub or designated Agent)
plan TaskCoordinator {
var tasks = ["area_a", "area_b", "area_c", "area_d"]
var available_workers = []
on_message("worker_ready") { worker ->
available_workers.add(worker.id)
}
on_message("task_complete") { result ->
log("Task done: " + result.task)
available_workers.add(result.worker)
}
loop {
if tasks.length > 0 && available_workers.length > 0 {
var task = tasks.pop()
var worker = available_workers.pop()
send_to(worker, "do_task", task)
}
delay(100)
}
}
// Worker Agent
plan Worker {
init {
broadcast("worker_ready", {id: my_id})
}
on_message("do_task") { task ->
execute_task(task)
broadcast("task_complete", {
worker: my_id,
task: task
})
}
}
Maintain relative positions:
plan FormationMember {
var formation_offset = {x: 2, y: 1} // 2m right, 1m behind leader
on_message("leader_position") { pos ->
var target_x = pos.x + formation_offset.x
var target_y = pos.y + formation_offset.y
navigate_to(target_x, target_y)
}
loop {
maintain_position()
delay(50)
}
}
Agents can synchronize clocks:
// Synchronize action timing
plan SyncDemo {
// Wait for sync signal
wait_for_message("sync_start")
// Execute at precisely the same time
var start_time = synced_time()
execute_at(start_time + 1000) { // 1 second from now
do_synchronized_action()
}
}
Share state across the fleet:
plan SharedState {
// Local state
var my_state = "idle"
// Update fleet about state changes
function set_state(new_state) {
my_state = new_state
broadcast("state_update", {
agent: my_id,
state: new_state
})
}
// Track other agents' states
var fleet_states = {}
on_message("state_update") { update ->
fleet_states[update.agent] = update.state
}
// Check if all agents are ready
function all_ready() {
for agent in fleet_states {
if fleet_states[agent] != "ready" {
return false
}
}
return true
}
}
Monitor peer status:
plan HealthMonitor {
var peer_last_seen = {}
var timeout = 5000 // 5 seconds
on_message("heartbeat") { msg ->
peer_last_seen[msg.from] = now()
}
loop {
// Send our heartbeat
broadcast("heartbeat", {from: my_id})
// Check for lost peers
for peer in peer_last_seen {
if now() - peer_last_seen[peer] > timeout {
handle_peer_lost(peer)
}
}
delay(1000)
}
}
Handle Agent failures:
plan FailoverWorker {
var primary_task = null
var is_backup = true
on_message("primary_failed") { task ->
if is_backup {
log("Taking over task: " + task)
primary_task = task
is_backup = false
execute_task(task)
}
}
on_message("primary_recovered") { _ ->
if !is_backup {
log("Primary back, reverting to backup")
is_backup = true
primary_task = null
}
}
}
┌─────────────────────────────────────────────────────────────┐
│ Fleet: Search Team │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Map View │ │
│ │ │ │
│ │ [A]──────→ ← Scout Alpha │ │
│ │ \ │ │
│ │ [B] [C] ← Workers Beta/Gamma │ │
│ │ │ │
│ │ [ ] = Search area [*] = Target found │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ Status: │
│ • Scout Alpha: Searching sector 4 │
│ • Worker Beta: Investigating target at (12, 45) │
│ • Worker Gamma: En route to sector 6 │
│ │
│ Messages/sec: 45 Sync drift: <10ms │
│ │
└─────────────────────────────────────────────────────────────┘
| Issue | Solution |
|---|---|
| Different networks | Ensure same subnet or use VPN |
| Firewall blocking | Open port 8124/UDP |
| Discovery failing | Try manual IP entry |
| Issue | Solution |
|---|---|
| Not paired | Complete pairing first |
| Wrong trust level | Set to "Depend" for messaging |
| Network congestion | Reduce message rate |
| Issue | Solution |
|---|---|
| Time sync drift | Use Hub as time reference |
| State inconsistency | Add acknowledgments |
| Race conditions | Use leader election |