Kenate

Getting Started

Project Structure

A Kenate project is organized to separate your behaviors from your configuration. Clean code, happy life.

Standard Layout

When you run kenate init my_robot, this is what you get:

my_robot/
hardware.tomlHardware configuration
main.pyEntry point
states/
__init__.py
patrol.pyYour state files
alert.py
idle.py
tests/
test_patrol.pyUnit tests
build/(Generated) C++ artifacts
.kenate/(Hidden) Cache

Key Files Explained

hardware.toml

Defines your hardware configuration. Change this file to switch platforms without touching your Python code. It's like magic, but with TOML.

[driver]
type = "raspberry_pi"  # or "odrive", "serial", "mock"

[motors]
left_wheel = { pin = 18, type = "pwm" }
right_wheel = { pin = 19, type = "pwm" }

[sensors]
front_sonar = { pin = 23, type = "hc-sr04" }

main.py

The entry point. You register your states and start the Engine here. Nice and simple.

import kenate
from states.patrol import PatrolState
from states.alert import AlertState
from states.idle import IdleState

engine = kenate.Engine()
engine.load_config("hardware.toml")

engine.register_state("Idle", IdleState())
engine.register_state("Patrol", PatrolState())
engine.register_state("Alert", AlertState())

engine.start("Idle")  # Blocking call

states/

Each behavior lives in its own file. One state per file keeps things clean and testable. Your future self will thank you.

# states/patrol.py
import kenate

class PatrolState(kenate.BaseState):
    def on_enter(self):
        self.log("Starting patrol...")
    
    def on_update(self):
        self.set_motor_speed(0, 50)  # Left motor
        self.set_motor_speed(1, 50)  # Right motor
        
        if self.get_distance(0) < 30:
            self.change_state("Alert")