code wiki / (root) / nx_robot_control.nx

nx_robot_control.nx

buildroot/runtime/nx_robot_control.nx

2919 B59 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind librarytopic robot
docsdependenciesstructsconstsfunctions

about

nx_robot_control.nx -- SOVEREIGN closed-loop motion CONTROL (the essence of "true control": read sensor -> compute -> drive actuator, in a loop, until the goal is reached). This is what makes a robot/sensor/actuator actually CONTROL something -- the same loop the printer and the IoT devices run, generalized. Fixed-point / NO FLOAT throughout (gains scaled by /100). A simple, provably-stable first-order plant (a motor+load: position advances by (command - load)/inertia per tick) stands in for real hardware so the loop is gate-verifiable without a machine. NEVER-BRICK (#26) BY CONSTRUCTION: the controller output is CLAMPED to +/-UMAX, so no matter how large the error, the actuator can never be commanded past a safe limit -- a hardware-safety invariant proven mechanically by the gate, not promised. (The real hardware-write driver inherits this clamp + a watchdog + safe-state-on-fault.) license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_robot_control.nx nx_robot_control_gate.nx nx_robot_firmware.nx

imports: nx_syscalls.nx

imported by: nx_robot_control_gate.nxnx_robot_firmware.nx

structs

none

consts

none

functions

15func ctl_p(e: i64, kp: i64, umax: i64) -> i64
23func ctl_p_raw(e: i64, kp: i64) -> i64 { return kp * e / 100 }
called by 1: main
26func plant_step(p: i64, u: i64, load: i64, inertia: i64) -> i64
32func run_closed(setpoint: i64, kp: i64, umax: i64, load: i64, inertia: i64, ticks: i64, out_maxu: *i64) -> i64
called by 1: main calls 2: ctl_pplant_step
51func run_open(setpoint: i64, fixed_u: i64, load: i64, inertia: i64, ticks: i64) -> i64
called by 1: main calls 1: plant_step