From f898883ff2a520a74d16e0488522739d99f6a634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?PROFERIS=20-=20Mi=C2=B3osz=20Stocki?= Date: Wed, 8 Jul 2026 11:55:09 +0200 Subject: [PATCH] fix kinematics - maybe? --- gemini.md | 50 ++++++++++--------- web/js/kinematics.js | 85 +++++++++++++++++---------------- web/js/sections/stepper-test.js | 36 +++++++------- 3 files changed, 85 insertions(+), 86 deletions(-) diff --git a/gemini.md b/gemini.md index e22d3e8..56d81a4 100644 --- a/gemini.md +++ b/gemini.md @@ -41,21 +41,19 @@ only BLE between the ESP32 firmware and a local web SPA. ELBOW1 ELBOW2 \ / l1 (85 mm) l1 (85 mm) - \ / - MOTOR1 (+12.9,0) MOTOR2 (-12.9,0) + \ / + MOTOR1 (-12.9,0) MOTOR2 (+12.9,0) | | [===BASE (25.8 mm)===] ``` **⚠️ CRITICAL MOTOR CONVENTION** (source of many past bugs): -`PositionControl.cpp` from the original project uses: -- `xmd = x - d2` → Motor 1 pivot is at **(+d2, 0) = (+12.9, 0)** — the RIGHT side -- `xpd = x + d2` → Motor 2 pivot is at **(-d2, 0) = (-12.9, 0)** — the LEFT side +The original C++ firmware has a variable swap bug where `angle2` is passed to `stepper1` and `angle1` to `stepper2`. Thus, the physical mapping is: +- **Motor 1** is the **LEFT** motor, pivoting at **(-d2, 0) = (-12.9, 0)**. It uses `xpd = x + d2`. +- **Motor 2** is the **RIGHT** motor, pivoting at **(+d2, 0) = (+12.9, 0)**. It uses `xmd = x - d2`. -This is counter-intuitive. Motor 1 is physically on the right. **Every piece of code that -computes elbow or motor-base positions must use M1 at +12.9 and M2 at -12.9 or the arms -will appear visually crossed even for valid target positions.** +**Every piece of code that computes elbow or motor-base positions must use M1 at -12.9 and M2 at +12.9 or the arms will appear visually crossed and physically collide.** ### Arm constants (from `PositionControl.cpp`) @@ -184,20 +182,20 @@ hamburger (`☰`) button. It contains `