Kenate

The Kernel

The Heartbeat

At the core of every Kenate robot is a deterministic C++ Kernel that pulses exactly 1000 times per second.

Millisecond Precision

Most programming languages suffer from "jitter"—unpredictable timing delays. For a robot moving at speed, a 50ms delay can be fatal. Kenate eliminates this by ensuring every on_update() hit happens exactly 1ms after the last.

Engine API Reference

The kenate.Engine class is the central manager of the robot brain.

add_state(state)

Registers a state object with the engine. The state becomes available for transitions.

set_state(name)

Forces the robot to switch to the named state immediately. Triggers on_exit() of current and on_enter() of new.

start(initial_state)

Commences the 1000Hz control loop thread. This call blocks the main thread.

stop()

Terminates the control loop safely, stopping all motors.

set_frequency(hz)

Adjusts the heartbeat speed (default 1000Hz). Advanced use only.

The 1ms Heartbeat

Most programming languages suffer from "jitter"—unpredictable delays in code execution. For a robot moving at high speeds, a 50ms delay can be catastrophic. Kenate's dedicated C++ Kernel pulses exactly 1000 times per second to eliminate this.

The Heartbeat

The 1000Hz internal clock that drives the engine.

The Bridge

The high-speed connection between Python logic and C++ hardware.

Tick Overruns & The Catch-Up Protocol

If your Python on_update() logic takes longer than 1ms, the engine detects that the next wake time has already passed. The C++ Kernel then follows the Catch-Up Protocol:

  • The engine skips the sleep command entirely.
  • It executes the next tick immediately.
  • The system runs at maximum CPU speed until it regains its 1ms schedule.

CRITICAL: Never use time.sleep() or blocking I/O inside on_update(). This forces a permanent Tick Overrun.

The BaseState Lifecycle

All custom behaviors inherit from kenate.BaseState.

on_enter()

Executes once when the state becomes active. Good for setup.

on_update()

The Heartbeat. Executes every 1ms. Put your control logic here.

on_exit()

Executes once when moving to a new state. Clean up here.