From e5bf10cdb007d552409a5bb0c4495123d484b2fa Mon Sep 17 00:00:00 2001 From: Rune Harlyk Date: Mon, 1 Sep 2025 18:41:59 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Updates=20and=20simplifies=20com?= =?UTF-8?q?mand=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/lib/components/Visualization.svelte | 19 ++++++----- app/src/lib/gait.ts | 19 ++++++----- app/src/routes/controller/Controls.svelte | 31 ++++++++++-------- esp32/include/gait/bezier_state.h | 13 ++++---- esp32/include/gait/crawl_state.h | 2 +- esp32/include/gait/four_phase_trot_state.h | 2 +- esp32/include/gait/phase_state_base.h | 2 +- esp32/include/gait/rest_state.h | 2 +- esp32/include/gait/stand_state.h | 2 +- esp32/include/gait/state.h | 24 ++++++-------- esp32/include/kinematics.h | 4 +-- esp32/include/message_types.h | 28 +++++++++++++++++ esp32/include/motion.h | 35 ++++++++++++--------- esp32/test/gait_performance.cpp | 5 +-- 14 files changed, 111 insertions(+), 77 deletions(-) create mode 100644 esp32/include/message_types.h diff --git a/app/src/lib/components/Visualization.svelte b/app/src/lib/components/Visualization.svelte index f48c9d1..02f54de 100644 --- a/app/src/lib/components/Visualization.svelte +++ b/app/src/lib/components/Visualization.svelte @@ -33,7 +33,7 @@ import SceneBuilder from '$lib/sceneBuilder' import { lerp, degToRad } from 'three/src/math/MathUtils' import { GUI } from 'three/addons/libs/lil-gui.module.min.js' - import Kinematic, { type body_state_t } from '$lib/kinematic' + import { type body_state_t } from '$lib/kinematic' import { BezierState, CalibrationState, @@ -264,16 +264,15 @@ if (sceneManager.isDragging || !settings['Internal kinematic']) return const controlData = get(outControllerData) const data = { - stop: controlData[0], - lx: controlData[1], - ly: controlData[2], - rx: controlData[3], - ry: controlData[4], - h: controlData[5], - s: controlData[6], - s1: controlData[7] + lx: controlData[0], + ly: controlData[1], + rx: controlData[2], + ry: controlData[3], + h: controlData[4], + s: controlData[5], + s1: controlData[6] } - body_state.ym = ((data.h + 127) * 0.35) / 100 + body_state.ym = data.h let planner = planners[get(mode)] const delta = performance.now() - lastTick diff --git a/app/src/lib/gait.ts b/app/src/lib/gait.ts index 021f523..df8e504 100644 --- a/app/src/lib/gait.ts +++ b/app/src/lib/gait.ts @@ -14,7 +14,6 @@ export interface gait_state_t { } export interface ControllerCommand { - stop: number lx: number ly: number rx: number @@ -61,11 +60,11 @@ export abstract class GaitState { map_command(command: ControllerCommand) { const newCommand = { - step_height: 0.4 + (command.s1 / 128 + 1) / 2, - step_x: command.ly / 128, - step_z: -command.lx / 128, - step_velocity: command.s / 128 + 1, - step_angle: command.rx / 128, + step_height: 0.4 + (command.s1 + 1) / 2, + step_x: command.ly, + step_z: -command.lx, + step_velocity: command.s, + step_angle: command.rx, step_depth: 0.002 } @@ -112,10 +111,10 @@ export class StandState extends GaitState { step(body_state: body_state_t, command: ControllerCommand, dt: number = 0.02) { body_state.omega = 0 - body_state.phi = command.rx / 8 - body_state.psi = command.ry / 8 - body_state.xm = command.ly / 2 / 100 - body_state.zm = command.lx / 2 / 100 + body_state.phi = command.rx + body_state.psi = command.ry + body_state.xm = command.ly / 4 + body_state.zm = command.lx / 4 body_state.feet = this.default_feet_pos return body_state } diff --git a/app/src/routes/controller/Controls.svelte b/app/src/routes/controller/Controls.svelte index f71b96a..0b1ae66 100644 --- a/app/src/routes/controller/Controls.svelte +++ b/app/src/routes/controller/Controls.svelte @@ -1,11 +1,11 @@