""" TARS mini – physical model (MuJoCo), built on the TARS-AI V3 mechanism. Mechanism (from TARS-AI src/config.ini.template + 3D part list): * torso = the two middle slabs, one rigid block, holds electronics + battery * per side: a "height" servo in the torso drives a pusher in a guided channel -> the leg's shaft slides up/down relative to the torso (servo 0/1) * per side: a "leg swing" servo rotates the leg about that shaft (servo 2/3) Geometry = TARS-AI parts scaled x0.6 (measured from the STL files: torso 110 mm wide, legs 64 mm wide, depth 65 mm, height ~290 mm). Every number that is an assumption (not read from a datasheet/STL) is marked ASSUMED and is swept in the sensitivity study. """ from __future__ import annotations import dataclasses, math import numpy as np KGCM = 0.0980665 # N·m per kg·cm @dataclasses.dataclass class Params: # ---- geometry, m (TARS-AI x0.6) ---- H: float = 0.175 # slab height (290 mm * 0.6) D: float = 0.039 # depth front-back (65 * 0.6) W_torso: float = 0.066 # torso width (110 * 0.6) W_leg: float = 0.0385 # leg width (64 * 0.6) gap: float = 0.003 hip_from_top: float = 0.030 # ASSUMED: shaft sits in the leg "hull", ~50 mm from top at full scale pad: float = 0.0035 # TPU foot pad thickness (6.2 mm * 0.6) pad_D: float | None = None # foot-pad depth front-back (None = same as body depth D); a deeper TPU sole # ---- mass budget, kg ---- torso_shell: float = 0.102 # PLA, 1.6 mm walls + internal mounts (computed from geometry) leg_shell: float = 0.055 # PLA, 1.2 mm walls + ribs servo: float = 0.0134 # MG90S (TowerPro datasheet 13.4 g) board: float = 0.015 # ESP32-S3-LCD-1.54 pca: float = 0.010 # Grove PCA9685 ups: float = 0.035 # Waveshare UPS HAT (B) board cells: float = 0.092 # 2 x 18650 (~46 g each) misc: float = 0.040 # speaker, wiring, pushers, shafts, screws, TPU pads batt_z: float = -0.045 # battery centre below torso centre (mounted low) mass_scale: float = 1.0 # ---- MG90S @ 5 V (TowerPro: 1.8 kg·cm @4.8 V, 2.2 @6 V; 0.10 s/60° @4.8 V) ---- tau_stall_kgcm: float = 1.85 t60: float = 0.10 p_band_deg: float = 4.0 # ASSUMED: error at which an analog servo reaches full torque i_stall: float = 0.75 # A, datasheet 750 mA ±10 % @4.8 V i_idle: float = 0.010 # A, holding with no load i_run: float = 0.15 # A, moving with no load (typical micro servo) servo_J: float = 3e-4 # ASSUMED: rotor inertia reflected through the gearbox, kg·m² @property def servo_b(self): """Back-EMF damping = stall torque / no-load speed (straight from the datasheet curve).""" return self.tau_stall / self.w0 # ---- optional different servo for the 2 HEIGHT joints (None = same as leg servos) ---- tau_h_kgcm: float | None = None t60_h: float | None = None servo_h: float | None = None # mass of one height servo (0 = no height servos, fixed slide) i_stall_h: float | None = None @property def tau_stall_h(self): return (self.tau_h_kgcm if self.tau_h_kgcm is not None else self.tau_stall_kgcm) * KGCM @property def w0_h(self): return math.radians(60) / (self.t60_h if self.t60_h is not None else self.t60) @property def servo_b_h(self): return self.tau_stall_h / self.w0_h # ---- height pusher (crank) ---- crank_r: float = 0.012 # ASSUMED: horn hole radius; swept 8–16 mm # ---- contact ---- mu: float = 0.8 # TPU pad on wood/table (swept 0.5–1.0) # ---- derived ---- @property def tau_stall(self): return self.tau_stall_kgcm * KGCM @property def w0(self): return math.radians(60) / self.t60 @property def x_leg(self): return self.W_torso / 2 + self.gap + self.W_leg / 2 def masses(self): s = self.mass_scale sh = self.servo if self.servo_h is None else self.servo_h torso = (self.torso_shell + self.board + self.pca + self.ups + self.misc + 2 * sh) * s cells = self.cells * s leg = (self.leg_shell + self.servo) * s return dict(torso=torso, cells=cells, leg=leg, total=torso + cells + 2 * leg) def build_xml(p: Params) -> str: m = p.masses() hz = p.H / 2 hip_z = hz - p.hip_from_top # shaft height in torso frame leg_cz = -(p.H / 2 - p.hip_from_top) # leg centre below shaft pad_z = -p.H / 2 + p.pad / 2 xl = p.x_leg def leg(side, sx): return f""" """ return f""" """