MOSS: a small, mostly 3D-printed litter-picking rover. Cleaner streets, one maker at a time.
Python
base: measured defaults after the drive wheels were seated: pulsing off, floor 40 % (both tracks turn continuously from 40 %), pivots at 100 % (80 % turns one track only); launcher ramp 5 5 by default
metrox9d0be7f7792b
diff --git a/benches/bench_moss_adapter_cold.py b/benches/bench_moss_adapter_cold.pyindex 1774892..c4877f8 100644--- a/benches/bench_moss_adapter_cold.py+++ b/benches/bench_moss_adapter_cold.py@@ -155,10 +155,10 @@ check(twist_to_tracks(0.15, 0.0, GF) == (25, 25), "floor 12: the limit is untouccheck(twist_to_tracks(0.09, 0.0, GF) == (15, 15), "floor 12: 15 % above the floor passes as is")check(twist_to_tracks(0.06, 0.0, G) == (10, 10), "floor 0 (explicit): L=10 R=10 unchanged")GD = MossGeometry() # the MOSS default: the tracks only turn at full duty-check(GD.min_pct == 100, f"the default floor is 100 (full duty only): {GD.min_pct}")-check(twist_to_tracks(0.02, 0.0, GD) == (100, 100), f"default: a slow forward twist -> 100/100: {twist_to_tracks(0.02, 0.0, GD)}")-check(twist_to_tracks(0.0, 0.2, GD) == (-100, 100), f"default: the planner's slowest pivot (0.2 rad/s) -> -100/+100: {twist_to_tracks(0.0, 0.2, GD)}")-check(twist_to_tracks(-0.02, 0.0, GD) == (-100, -100), "default: slow reverse -> -100/-100 (sign kept)")+check(GD.min_pct == 40, f"the default floor is 40 (measured): {GD.min_pct}")+check(twist_to_tracks(0.02, 0.0, GD) == (40, 40), f"default: a slow forward twist -> 40/40: {twist_to_tracks(0.02, 0.0, GD)}")+check(twist_to_tracks(0.0, 0.2, GD) == (-40, 40), f"default: the planner's slowest pivot (0.2 rad/s) -> -40/+40 before pivot_tracks: {twist_to_tracks(0.0, 0.2, GD)}")+check(twist_to_tracks(-0.02, 0.0, GD) == (-40, -40), "default: slow reverse -> -40/-40 (sign kept)")check(twist_to_tracks(0.0001, 0.0, GD) == (0, 0), "default: a twist that rounds to 0 is still a stop")check(twist_to_tracks(0.06, 0.0, MossGeometry(track_m=0.30, mps_at_limit=0.15, max_pct=25, min_pct=99)) == (25, 25),"a floor above the limit is clamped to the limit")@@ -276,7 +276,7 @@ check(MossGeometry.from_env().min_pct == MossGeometry.from_env().max_pct, "MOSS_os.environ["MOSS_MIN_PCT"] = "-5"check(MossGeometry.from_env().min_pct == 0, "MOSS_MIN_PCT negative -> 0")os.environ.pop("MOSS_MIN_PCT", None)-check(MossGeometry.from_env().min_pct == 100, "MOSS_MIN_PCT unset -> 100 (the tracks only turn at full duty)")+check(MossGeometry.from_env().min_pct == 40, "MOSS_MIN_PCT unset -> 40 (measured floor: both tracks turn from 40 %)")# ── 8. the fake is the firmware: its own refusals ──────────────────────print("8. fake firmware fidelity (Control.h)")@@ -444,7 +444,7 @@ check(pulse_ms() == 500, "MOSS_PULSE_MS=500 -> 500")os.environ["MOSS_PULSE_MS"] = "9000"check(pulse_ms() == 2000, "MOSS_PULSE_MS above the cap -> 2000")os.environ.pop("MOSS_PULSE_MS", None)-check(pulse_ms() == 500, "MOSS_PULSE_MS unset -> 500 (the MOSS default: pulsing on)")+check(pulse_ms() == 0, "MOSS_PULSE_MS unset -> 0 (the MOSS default: pulsing off, the tracks turn continuously from 40 %)")os.environ["MOSS_PULSE_MS"] = "500"os.environ.pop("MOSS_RAMP_MS", None)os.environ.pop("MOSS_PULSE_MIN_PCT", None)@@ -476,8 +476,8 @@ os.environ["MOSS_PULSE_MS"] = "0"fw8 = FakeMossFirmware()f8 = lambda: fw8 # noqa: E731f8.is_mock = True-pb = MossBaseAdapter(dof=3, port_factory=f8, geometry=MossGeometry(track_m=0.30, mps_at_limit=0.15, max_pct=100))-check(pb._pulse_n == 0 and pb._map_geometry.min_pct == 100, "MOSS_PULSE_MS=0 -> no pulsing, the 100 % floor applies instead")+pb = MossBaseAdapter(dof=3, port_factory=f8, geometry=MossGeometry(track_m=0.30, mps_at_limit=0.15, max_pct=100, min_pct=100))+check(pb._pulse_n == 0 and pb._map_geometry.min_pct == 100, "MOSS_PULSE_MS=0 -> no pulsing, the geometry's floor applies instead (100 here)")check(pb.connect() and not any(c.startswith("ramp") for c in fw8.commands), "...and no ramp line without MOSS_RAMP_MS")pb.disconnect()os.environ.pop("MOSS_PULSE_MS", None)diff --git a/benches/bench_moss_fly_gates_cold.py b/benches/bench_moss_fly_gates_cold.pyindex 99189ac..c6f7519 100644--- a/benches/bench_moss_fly_gates_cold.py+++ b/benches/bench_moss_fly_gates_cold.py@@ -380,7 +380,7 @@ check("one launch: --rerun-open none --nerf-speed 0.5 run moss-dimos.moss-nav --env_l = run_l[0].split("| ENV ", 1)[1] if run_l and "| ENV " in run_l[0] else ""for want in (f"MOSS_PORT={qtpy}", f"MOSS_LIDAR_PORT={c1}", "DIMOS_TRANSPORT=lcm","TRANSPORT=lcm", "GLIBC_TUNABLES=glibc.rtld.optional_static_tls=4194304", "MOSS_MAX_PCT=100",- "MOSS_RAMP_MS=1 1", "MOSS_RECORD=1", "MOSS_CAMERA=1", f"MOSS_STATE_DIR={case / 'state'}"):+ "MOSS_RAMP_MS=5 5", "MOSS_RECORD=1", "MOSS_CAMERA=1", f"MOSS_STATE_DIR={case / 'state'}"):check(f"stack env: {want.split('=')[0]}={want.split('=', 1)[1][-40:]}",re.search(r"(^| )" + re.escape(want) + r"( |$)", env_l) is not None, env_l[-120:])check("the launcher does not export ROBOT_PROFILE (MOSS is the only profile)",diff --git a/moss_dimos/moss_adapter.py b/moss_dimos/moss_adapter.pyindex 423e71f..3c58d52 100644--- a/moss_dimos/moss_adapter.py+++ b/moss_dimos/moss_adapter.py@@ -60,11 +60,11 @@ Calibration (env, all optional):(default robot_profile.MOSS.track_m, 0.266 CAD, placeholder)MOSS_MPS_AT_LIMIT floor speed in m/s at MOSS_MAX_PCT, measuredMOSS_MAX_PCT percent ceiling, <= the firmware's 100- MOSS_MIN_PCT static-friction floor in percent (0 = off, default 100: the tracks only turn at full duty): a non-zero track command below it is raised to it, sign kept+ MOSS_MIN_PCT static-friction floor in percent (0 = off, default 40: measured, both tracks turn from 40 %): a non-zero track command below it is raised to it, sign keptMOSS_TICKS_PER_M encoder ticks per metre of track travel, measuredMOSS_TURN_GAIN turn authority vs forward speed (teleop_speeds), 0.5..4, default 2MOSS_RAMP_MS "UP DOWN" sent as 'ramp UP DOWN' after connect (while pulsing, unset = "1 1")- MOSS_PULSE_MS period of the full-duty time slicing (default 500, 0 = off): a percent becomes a duty of+ MOSS_PULSE_MS period of the full-duty time slicing (default 0 = off; 500 = five slices of 100 ms): a percent becomes a duty offull-power slices over the period (pulse_tracks), the way MOSS's tracks can be steeredMOSS_PULSE_MIN_PCT duty floor of a non-zero track while pulsing (default 40)MOSS_PIVOT_PCT every pivot (tracks in opposite directions) is sent at this percent, both tracks (default 100, 0 = as asked)@@ -102,7 +102,9 @@ REPLY_TIMEOUT_S = 0.150 # the firmware answers within a loop tick (ms)CONNECT_PROBE_S = 1.000 # the first "status" of a process: reader thread start + first parse on a Jetson take longer than a reply tickTELEMETRY_FRESH_S = 1.0 # mode read from telemetry older than this = unknownMOCK_BUS_ENV = "MOSS_MOCK_BUS"-PULSE_MS_DEFAULT = 500 # MOSS_PULSE_MS: period of the full-duty time slicing, 0 = off (then MOSS_MIN_PCT applies)+PULSE_MS_DEFAULT = 0 # MOSS_PULSE_MS: period of the full-duty time slicing, 0 = off (then MOSS_MIN_PCT applies).+ # Off on MOSS: with the drive wheels seated on their axles the tracks turn continuously+ # from 40 % (floor probe), so slices are only for a base that moves at full duty alonePULSE_MS_MAX = 2000PULSE_RAMP = "1 1" # firmware ramp while pulsing: 1 ms per %, so a 100 ms slice reaches full dutyPIVOT_PCT_DEFAULT = 100 # MOSS_PIVOT_PCT: a pivot (tracks in opposite directions) is sent at this percent on both@@ -206,7 +208,7 @@ class MossGeometry:mps_at_limit: float = 0.45 # PLACEHOLDER: floor speed at 100 % (JGB37-520 178 rpm on a ~60 mm sprocket ~ 0.5 m/s), to measuremax_pct: int = FIRMWARE_MAX_PCTticks_per_m: float | None = None # None = no encoder calibration yet- min_pct: int = 100 # static-friction floor: a non-zero track command below this percent is raised to it (sign kept). 0 = off. MOSS_MIN_PCT. 100 on MOSS: the geared motors behind the MDD3A only turn at full duty, so every non-zero command is a full-duty command (the planner's 0.2 rad/s pivots map to ~8 %, which does not move the tracks)+ min_pct: int = 40 # static-friction floor: a non-zero track command below this percent is raised to it (sign kept). 0 = off. MOSS_MIN_PCT. 40 on MOSS: the floor probe (straight, continuous duty, wheels seated) turns both tracks from 40 %, barely at 20 %@classmethoddef from_env(cls) -> "MossGeometry":diff --git a/tools/moss-fly.sh b/tools/moss-fly.shindex ccc1c07..f26671a 100755--- a/tools/moss-fly.sh+++ b/tools/moss-fly.sh@@ -62,9 +62,9 @@ export GLIBC_TUNABLES=glibc.rtld.optional_static_tls=4194304 # larger static TBUS="${DIMOS_TRANSPORT:-${TRANSPORT:-lcm}}"export DIMOS_TRANSPORT="$BUS" TRANSPORT="$BUS"export MOSS_MAX_PCT="${MOSS_MAX_PCT:-100}" # firmware limit 100; lower it for a cautious lap-# firmware ramp, ms per % up/down: 1 1 while the base adapter pulses (a 100 ms slice must-# reach full duty, MOSS_PULSE_MS, 500 by default), 5 5 when pulsing is off (MOSS_PULSE_MS=0)-if [ "${MOSS_PULSE_MS:-500}" != "0" ]; then export MOSS_RAMP_MS="${MOSS_RAMP_MS:-1 1}"; else export MOSS_RAMP_MS="${MOSS_RAMP_MS:-5 5}"; fi+# firmware ramp, ms per % up/down: 5 5 (pulsing off, the default), 1 1 while the base adapter+# pulses (MOSS_PULSE_MS=<ms>: a 100 ms slice must reach full duty)+if [ "${MOSS_PULSE_MS:-0}" != "0" ]; then export MOSS_RAMP_MS="${MOSS_RAMP_MS:-1 1}"; else export MOSS_RAMP_MS="${MOSS_RAMP_MS:-5 5}"; fiexport MOSS_STATE_DIR="${MOSS_STATE_DIR:-$HOME/.local/state/moss}"export MOSS_RECORD="${MOSS_RECORD:-1}"export MOSS_CAMERA="${MOSS_CAMERA:-1}"