Kenate

Masterclass V1.0.6

Autonomous Delivery

Warehouse SuiteFail-Safe Architecture

Introduction

"I'm going to build a delivery system that doesn't immediately crash into the nearest wall and explode. Let's actually engineer this properly."

01. Install Engine

$ git clone https://github.com/otesh-o/Kenate.git
$ cd kenate

02. Scaffold Workspace

$ kenate init WarehouseBot
$ cd WarehouseBot

03. The Implementation

from kenate import Robot, BaseState
from kenate.stdlib import WaitState, BlackBoxLogger
from kenate.diag import TerminalVisualizer

# PHASE 1: THE SAFETY LAYER (EMERGENCY LOCKDOWN)
class SafetyLockdown(BaseState):
    def on_enter(self):
        print("\n[CRITICAL] EMERGENCY LOCKDOWN TRIGGERED.")
        # Kill power to actuators here
    
    def on_update(self):
        pass

# PHASE 2: THE STARTUP AUDIT (BATTERY CHECK)
class BatteryCheck(BaseState):
    def on_enter(self):
        self.logger = BlackBoxLogger()
        print("[SYSTEM] Pre-Flight Energy Audit...")

    def on_update(self):
        battery = self.get_battery_level()
        if battery > 20:
            self.transition_to("Navigation")
        else:
            self.transition_to("SafetyLockdown")

# PHASE 3: THE HEARTBEAT LOOP (NAVIGATION)
class Navigation(BaseState):
    def on_enter(self):
        self.viz = TerminalVisualizer(robot_id="MASTER-TRANS-01")
        self.traveled = 0.0

    def on_update(self):
        # 1. SENSE: Gather data
        dist = self.get_distance_sensor()
        temp = self.get_system_temperature()
        
        # 2. THINK: Logic transitions (Fail-safe)
        if temp > 80.0:
            self.transition_to("SafetyLockdown")
            return

        if dist < 30:
            print("\n[ALERT] Obstacle! Braking...")
            self.transition_to("WaitState") 
            return

        # 3. ACT: Move and render
        self.traveled += 0.1 
        self.viz.render(self.name, {'distance': self.traveled})

def main():
    robot = Robot(port="SIMULATION")
    robot.create_state("StartUp", BatteryCheck)
    robot.create_state("Navigation", Navigation)
    robot.create_state("SafetyLockdown", SafetyLockdown)
    robot.start()

Breakdown: To The Bone

The Safety Layer

I need a "Safe Zone" for when things inevitably catch on fire. The SafetyLockdown state is completely isolated. If your navigation logic crashes hard, this state ensures the motors are immediately killed so your robot doesn't autonomously drive itself off a cliff.

Pre-Flight Audit

I don't want a robot dying halfway down a corridor because you forgot to charge it. The BatteryCheck logs its findings to the Black Box so when the inevitable happens, I have the receipts.

04. Deploying to Hardware

Once the code is on the Raspberry Pi, run:

$ kenate run src/delivery_bot.py
The Python script wakes up the C++ engine inside the robot's brain, and the navigation begins!