Skip to content

armgit / moss

Public Imported from GitHub
0

MOSS: a small, mostly 3D-printed litter-picking rover. Cleaner streets, one maker at a time.

Python

obstacle latency and drift: the costmap counts an obstacle at its first sighting (MOSS_OCCUPIED_AT 1, new viewpoint every 5 cm, a grid every two revolutions, all overridable), the base floor rises to 50 % and a frozen track pushes at 75 % for one window before it counts as a contact, the planner's speed scale goes to 0.7, and the lidar odometry deskews each revolution by bearing

metrox27d2fd7370f9
diff --git a/benches/bench_costmap2d_cold.py b/benches/bench_costmap2d_cold.py
index c00ce60..257a3c5 100644
--- a/benches/bench_costmap2d_cold.py
+++ b/benches/bench_costmap2d_cold.py
@@ -76,6 +76,12 @@ import numpy as np # noqa: E402
# MOSS's own numbers, whatever the shell exported
for _var in [v for v in os.environ if v.startswith("MOSS_")]:
del os.environ[_var]
+# the checks below pin the cautious rules (a wall from two places, viewpoints 10 cm apart, one grid per
+# five revolutions); the module defaults are the fast ones (first sighting counts, 5 cm, every two),
+# checked in a subprocess by test_the_fast_defaults
+os.environ["MOSS_OCCUPIED_AT"] = "2"
+os.environ["MOSS_NEW_VIEWPOINT_M"] = "0.10"
+os.environ["MOSS_PUBLISH_EVERY"] = "5"
from dimos_lcm.std_msgs import Bool # noqa: E402
@@ -918,7 +924,20 @@ def test_body_clear_resets_the_camera_wall_flag() -> None:
f"left on: a wall)")
-TESTS = (test_leg_needs_two_viewpoints_and_ray_is_free, test_ramp_hit_from_one_spot_never_becomes_a_wall,
+def test_the_fast_defaults() -> None:
+ """Without the environment the module counts an obstacle at its first sighting,
+ takes a new viewpoint every 5 cm and publishes every two revolutions (the
+ obstacle-latency levers)."""
+ import subprocess, sys as _sys
+ env = {k: v for k, v in os.environ.items() if not k.startswith("MOSS_")}
+ env["PYTHONPATH"] = os.environ.get("PYTHONPATH", "")
+ out = subprocess.run([_sys.executable, "-c", "import moss_dimos.costmap2d as c; print(c.OCCUPIED_AT, c.NEW_VIEWPOINT_M, c.PUBLISH_EVERY)"],
+ capture_output=True, text=True, env=env, timeout=120).stdout.split()
+ assert out == ["1", "0.05", "2"], out
+ print(" defaults: OCCUPIED_AT 1, NEW_VIEWPOINT_M 0.05, PUBLISH_EVERY 2 (this bench pins 2 / 0.10 / 5 for its own checks)")
+
+
+TESTS = (test_the_fast_defaults, test_leg_needs_two_viewpoints_and_ray_is_free, test_ramp_hit_from_one_spot_never_becomes_a_wall,
test_chair_moved_is_forgotten_by_lidar_rays, test_reinforcement_is_capped_and_unlearning_bounded,
test_parked_rover_never_erases_an_established_wall, test_body_clear_is_the_moss_footprint,
test_the_lidar_tag_is_one_exact_height, test_the_map_writes_only_during_the_mission,
diff --git a/benches/bench_lidar_odometry_cold.py b/benches/bench_lidar_odometry_cold.py
index 4f5b45f..8ff936c 100644
--- a/benches/bench_lidar_odometry_cold.py
+++ b/benches/bench_lidar_odometry_cold.py
@@ -230,10 +230,10 @@ finally:
LO.Module.start = real_module_start
LO.logger = real_logger
cfg = getattr(o._kiss, "cfg", None)
-check("start() builds kiss-icp: max 12 m, min 0.35 m, no deskew, voxel 0.05 m, 30 points/voxel, threshold 0.3 m, min motion 0.02 m",
+check("start() builds kiss-icp: max 12 m, min 0.35 m, deskew on, voxel 0.05 m, 30 points/voxel, threshold 0.3 m, min motion 0.02 m",
cfg is not None and (cfg.data.max_range, cfg.data.min_range, cfg.data.deskew, cfg.mapping.voxel_size,
cfg.mapping.max_points_per_voxel, cfg.adaptive_threshold.initial_threshold,
- cfg.adaptive_threshold.min_motion_th) == (12.0, 0.35, False, 0.05, 30, 0.3, 0.02))
+ cfg.adaptive_threshold.min_motion_th) == (12.0, 0.35, True, 0.05, 30, 0.3, 0.02))
up = [line for line in spy.lines if line.startswith("lidar odometry up")]
check("start() logs 'lidar odometry up (kiss-icp, ...' once (the launcher greps this prefix)",
len(up) == 1 and up[0].startswith("lidar odometry up (kiss-icp,") and up[0].endswith("-> world"),
@@ -241,6 +241,21 @@ check("start() logs 'lidar odometry up (kiss-icp, ...' once (the launcher greps
# --- B. roundtrip 73 deg --------------------------------------------------------
+print("A2. sweep_times: when each point of a revolution was taken")
+ang = np.radians(np.arange(0, 360, 2.0))
+rev = np.stack([2.0 * np.cos(ang), 2.0 * np.sin(ang), np.zeros_like(ang)], 1)
+st = LO.sweep_times(rev)
+check("a full revolution in bearing order: 0 at the first point, 1 at the last, monotonic",
+ abs(st[0]) < 1e-9 and abs(st[-1] - 1.0) < 1e-9 and np.all(np.diff(st) >= 0), f"{st[:3]} .. {st[-3:]}")
+check("half way round the sweep -> about 0.5", abs(st[len(st) // 2] - 0.5) < 0.02, f"{st[len(st) // 2]:.3f}")
+rev_cw = rev[::-1]
+st_cw = LO.sweep_times(rev_cw)
+check("the other way round (clockwise): still 0 first, 1 last", abs(st_cw[0]) < 1e-9 and abs(st_cw[-1] - 1.0) < 1e-9 and np.all(np.diff(st_cw) >= 0))
+check("a revolution with a gap (points 0-170 deg only) keeps the fraction of the bearing covered",
+ abs(LO.sweep_times(rev[:86])[-1] - 1.0) < 1e-9 and abs(LO.sweep_times(rev[:86])[43] - 0.5) < 0.02)
+check("two points at the same bearing -> the point order", np.allclose(LO.sweep_times(np.array([[1.0, 0.0, 0.0], [1.0, 0.0, 0.0]])), [0.0, 1.0]))
+check("one point -> 0", LO.sweep_times(np.array([[1.0, 0.0, 0.0]])).tolist() == [0.0])
+
print("B. roundtrip: a revolution registered at (1.20, -0.70, +73.0 deg)")
TRUE = (1.20, -0.70, math.radians(73.0))
o = odometry(Kiss(*TRUE))
diff --git a/benches/bench_moss_adapter_cold.py b/benches/bench_moss_adapter_cold.py
index 2289427..c9d75e7 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 untouc
check(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 == 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(GD.min_pct == 50, f"the default floor is 50: {GD.min_pct}")
+check(twist_to_tracks(0.02, 0.0, GD) == (50, 50), f"default: a slow forward twist -> 50/50: {twist_to_tracks(0.02, 0.0, GD)}")
+check(twist_to_tracks(0.0, 0.2, GD) == (-50, 50), f"default: the planner's slowest pivot (0.2 rad/s) -> -50/+50 before pivot_tracks: {twist_to_tracks(0.0, 0.2, GD)}")
+check(twist_to_tracks(-0.02, 0.0, GD) == (-50, -50), "default: slow reverse -> -50/-50 (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 == 40, "MOSS_MIN_PCT unset -> 40 (measured floor: both tracks turn from 40 %)")
+check(MossGeometry.from_env().min_pct == 50, "MOSS_MIN_PCT unset -> 50 (measured floor 40 on a full battery, 10 of margin)")
# ── 8. the fake is the firmware: its own refusals ──────────────────────
print("8. fake firmware fidelity (Control.h)")
@@ -493,11 +493,14 @@ f9 = lambda: fw9 # noqa: E731
f9.is_mock = True
sa = MossBaseAdapter(dof=3, port_factory=f9, geometry=MossGeometry(track_m=0.30, mps_at_limit=0.15, max_pct=100, min_pct=0))
check(sa.connect() and sa.write_enable(True), "connected and armed on a fake with frozen encoders")
-t_start = time.monotonic()
-while time.monotonic() - t_start < STALL_S + 0.6 and not sa.stalled:
+from moss_dimos.moss_adapter import STALL_PUSH_PCT # noqa: E402
+t_start = time.monotonic(); pushed = False
+while time.monotonic() - t_start < 2 * STALL_S + 1.0 and not sa.stalled:
sa.write_velocities([0.06, 0.0, 0.0]) # 40 %, refreshed like a planner would
+ pushed = pushed or sa.target_pct == (STALL_PUSH_PCT, STALL_PUSH_PCT)
settle(0.1)
-check(sa.stalled and sa.stall_count == 1, f"stalled once after about {STALL_S:.0f} s of a held command: stalled {sa.stalled}, count {sa.stall_count}")
+check(pushed, f"frozen at 40 %: the guard first pushes at {STALL_PUSH_PCT} % for one window")
+check(sa.stalled and sa.stall_count == 1, f"still frozen at {STALL_PUSH_PCT} %: a stall, once (stalled {sa.stalled}, count {sa.stall_count})")
check(fw9.commands[-1] == "stop" and fw9.mode == OFF, f"'stop' was sent and the fake is OFF: last {fw9.commands[-1]!r}, mode {fw9.mode}")
check(sa.target_pct == (0, 0), "the command is dropped (no keepalive pushes on)")
doc = _tp(sa, 0.0)
@@ -529,7 +532,7 @@ for twist, label, want_stall in (([0.06, 0.0, 0.1], "left frozen at the lower co
sc = MossBaseAdapter(dof=3, port_factory=f11, geometry=MossGeometry(track_m=0.30, mps_at_limit=0.15, max_pct=100, min_pct=0))
sc.connect(); sc.write_enable(True)
t_start = time.monotonic()
- while time.monotonic() - t_start < STALL_S + 0.6 and not sc.stalled:
+ while time.monotonic() - t_start < 2 * STALL_S + 1.0 and not sc.stalled:
sc.write_velocities(twist); settle(0.1)
check((sc.stall_count == 1) == want_stall, f"{label} (count {sc.stall_count}, L/R {sc._want})")
sc.write_stop(); sc.disconnect()
diff --git a/benches/bench_moss_fly_gates_cold.py b/benches/bench_moss_fly_gates_cold.py
index 3368248..703329c 100644
--- a/benches/bench_moss_fly_gates_cold.py
+++ b/benches/bench_moss_fly_gates_cold.py
@@ -374,8 +374,8 @@ order = [first(log, "py tools/moss_preflight.py"), first(log, " run moss-dimos.m
check("order: preflight -> dimos run -> cockpit curl", -1 not in order and order == sorted(order), str(order))
check("gate 1 runs the preflight with --no-spin (battery + disarmed read) and saves it",
any("--no-spin" in ln and "--save" in ln for ln in ran(log, "py tools/moss_preflight.py")))
-check("one launch: --rerun-open none --nerf-speed 0.5 run moss-dimos.moss-nav --daemon",
- len(run_l) == 1 and "--rerun-open none --nerf-speed 0.5 run moss-dimos.moss-nav --daemon" in run_l[0],
+check("one launch: --rerun-open none --nerf-speed 0.7 run moss-dimos.moss-nav --daemon",
+ len(run_l) == 1 and "--rerun-open none --nerf-speed 0.7 run moss-dimos.moss-nav --daemon" in run_l[0],
run_l[0][:140] if run_l else "none")
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",
diff --git a/moss_dimos/costmap2d.py b/moss_dimos/costmap2d.py
index 92a9719..12cbc53 100644
--- a/moss_dimos/costmap2d.py
+++ b/moss_dimos/costmap2d.py
@@ -131,7 +131,9 @@ def _env_float(name: str, default: float, lo: float, hi: float) -> float:
RESOLUTION_M = 0.05
GRID_SPAN_M = 24.0 # world-fixed square, centred on the first pose
-OCCUPIED_AT = 2 # two hits from two places = an obstacle
+OCCUPIED_AT = int(round(_env_float("MOSS_OCCUPIED_AT", 1, 1, 10))) # hits before a cell is an obstacle. 1: the first sighting
+ # counts (the planner reacts within one revolution; a passer-by is carved back within a second).
+ # 2 = the cautious rule, a wall only from two places 10 cm apart (MOSS_OCCUPIED_AT=2)
# The layers are int8: the ceiling stays within 127, and at OCCUPIED_AT or above
# (below it nothing could ever become a wall); the floor stays within [-128, 0].
HIT_CAP = int(round(_env_float("MOSS_HIT_CAP", 10, OCCUPIED_AT, 127))) # ceiling: no cell gets more certain than this.
@@ -140,9 +142,9 @@ HIT_CAP = int(round(_env_float("MOSS_HIT_CAP", 10, OCCUPIED_AT, 127))) # c
# nothing sees it any more.
FREE_FLOOR = int(round(_env_float("MOSS_FREE_FLOOR", -3, -128, 0))) # floor: no cell gets more "free" than this.
# A floor nearer 0 lets a new obstacle on long-seen floor become a wall in fewer hits.
-NEW_VIEWPOINT_M = 0.10 # a hit counts only if the rover moved this much since the cell's last hit
+NEW_VIEWPOINT_M = _env_float("MOSS_NEW_VIEWPOINT_M", 0.05, 0.0, 1.0) # a hit counts only if the rover moved this much since the cell's last hit
LIDAR_Z_TOL_M = 1e-6 # lidar returns sit at EXACTLY the profile's lidar_height_m: the tag survives the float32 round trip to 5 nm (see lidar_returns)
-PUBLISH_EVERY = 5 # one grid every 5 revolutions (~2 Hz at 10 Hz). A 24 m grid is ~230 kB and every
+PUBLISH_EVERY = int(round(_env_float("MOSS_PUBLISH_EVERY", 2, 1, 20))) # one grid every N revolutions (2 = 5 Hz at 10 Hz). A 24 m grid is ~230 kB and every
# subscriber (planner, explorer, recorder, cockpit) decodes each one; the map
# QUALITY does not depend on this rate (the odometry gives it).
RAY_MAX_M = _env_float("MOSS_RAY_MAX_M", 4.0, 0.0, GRID_SPAN_M) # rays are carved (misses) up to this range only:
diff --git a/moss_dimos/lidar_odometry.py b/moss_dimos/lidar_odometry.py
index 0f2df97..5212f12 100644
--- a/moss_dimos/lidar_odometry.py
+++ b/moss_dimos/lidar_odometry.py
@@ -95,6 +95,24 @@ def _se2(dx: float, dy: float, dyaw: float) -> np.ndarray:
return np.array([[c, -s, 0.0, dx], [s, c, 0.0, dy], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])
+def sweep_times(pts: np.ndarray) -> np.ndarray:
+ """When, within one revolution, each point was taken: 0 for the first, 1 for
+ the last, from the unwrapped bearing of the points in scan order (the C1
+ publishes a revolution in sweep order; its bearing runs one way round). A
+ revolution whose bearings do not progress (fewer than a few degrees of span)
+ falls back to the point order. kiss-icp's deskew moves each point by that
+ fraction of the motion prior, so a scan bent by a fast pivot comes straight."""
+ n = len(pts)
+ if n < 2:
+ return np.zeros(n)
+ ang = np.unwrap(np.arctan2(pts[:, 1], pts[:, 0]))
+ span = ang[-1] - ang[0]
+ if abs(span) < math.radians(5.0):
+ return np.linspace(0.0, 1.0, n)
+ t = (ang - ang[0]) / span
+ return np.clip(t, 0.0, 1.0)
+
+
def split_floor_and_obstacles(bx: np.ndarray, by: np.ndarray, bz: np.ndarray,
floor_z: np.ndarray, cell_m: float = 0.05) -> tuple[np.ndarray, np.ndarray]:
"""Masks (obstacle, floor) over base-frame depth points.
@@ -129,7 +147,7 @@ class LidarOdometry(Module):
def __init__(self, max_range_m: float = 12.0, min_range_m: float = 0.35,
voxel_size_m: float = 0.05, initial_threshold_m: float = 0.3,
- gyro_axis: str = "-y", use_gyro_prior: bool = True,
+ gyro_axis: str = "-y", use_gyro_prior: bool = True, deskew: bool = True,
world_frame: str = "world",
base_frame: str = "base_link", lidar_frame: str = "lidar_link",
log_every_s: float = 2.0, **kwargs: Any) -> None:
@@ -142,6 +160,7 @@ class LidarOdometry(Module):
# yaw_rate = -gyro.y. A camera mounted upside down flips the sign.
self.gyro_axis = gyro_axis
self.use_gyro_prior = use_gyro_prior
+ self.deskew = deskew # kiss-icp straightens each revolution by the motion prior (sweep_times): a full-power pivot bends a 10 Hz scan by 25 degrees
self.world_frame, self.base_frame, self.lidar_frame = world_frame, base_frame, lidar_frame
self.log_every_s = log_every_s
# dimOS pickles module instances into their worker: no lock, no native
@@ -175,7 +194,7 @@ class LidarOdometry(Module):
cfg = KISSConfig()
cfg.data.max_range = self.max_range_m
cfg.data.min_range = self.min_range_m
- cfg.data.deskew = False
+ cfg.data.deskew = self.deskew
cfg.mapping.voxel_size = self.voxel_size_m
cfg.mapping.max_points_per_voxel = 30
# kiss-icp defaults are tuned for cars (2 m initial threshold)
@@ -361,7 +380,7 @@ class LidarOdometry(Module):
with self._lock:
k = self._kiss
prior = self._prior_delta()
- frame = k.preprocessor.preprocess(thick, np.zeros(len(thick)), prior)
+ frame = k.preprocessor.preprocess(thick, np.tile(sweep_times(pts), 3) if self.deskew else np.zeros(len(thick)), prior)
source, frame_down = k.voxelize(frame)
sigma = k.adaptive_threshold.get_threshold()
initial_guess = np.asarray(k.last_pose) @ prior
diff --git a/moss_dimos/moss_adapter.py b/moss_dimos/moss_adapter.py
index edf72b0..f2c0221 100644
--- a/moss_dimos/moss_adapter.py
+++ b/moss_dimos/moss_adapter.py
@@ -60,7 +60,7 @@ 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, measured
MOSS_MAX_PCT percent ceiling, <= the firmware's 100
- 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 kept
+ MOSS_MIN_PCT static-friction floor in percent (0 = off, default 50: measured 40 on a full battery, 10 of margin for the sag): a non-zero track command below it is raised to it, sign kept
MOSS_TICKS_PER_M encoder ticks per metre of track travel, measured
MOSS_TURN_GAIN turn authority vs forward speed (teleop_speeds), 0.5..4, default 2
MOSS_RAMP_MS "UP DOWN" sent as 'ramp UP DOWN' after connect (while pulsing, unset = "1 1")
@@ -107,6 +107,8 @@ STALL_S = 1.0 # every commanded track frozen for this long = ST
# something (no bumper on MOSS: the encoders are the bumper)
STALL_MIN_TICKS = 20 # ticks over STALL_S that count as motion (a track at 40 % makes ~800 per second)
STALL_WINDOW_S = 2.0 # how long the tick history is kept for the comparison
+STALL_PUSH_PCT = 75 # before a stall below this command becomes a contact, the tracks get one window at this
+ # percent: a half-full battery sags and a track at the floor just creeps, which is not a wall
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 alone
@@ -213,7 +215,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 measure
max_pct: int = FIRMWARE_MAX_PCT
ticks_per_m: float | None = None # None = no encoder calibration yet
- 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 %
+ min_pct: int = 50 # static-friction floor: a non-zero track command below this percent is raised to it (sign kept). 0 = off. MOSS_MIN_PCT. 50 on MOSS: both tracks turn from 40 % on a full battery, and a half-full one sags under load, so 10 % of margin
@classmethod
def from_env(cls) -> "MossGeometry":
@@ -338,6 +340,8 @@ class MossBaseAdapter:
self._drive_since: float | None = None # when the current non-zero command started
self._stalled = False # True from a stall until the next accepted command
self._stall_count = 0 # stalls since connect (telemetry_payload, the coordinator's bump)
+ self._pushing: tuple[int, int] | None = None # the command being pushed harder before a contact is declared
+ self._push_origin: tuple[int, int] | None = None # the commander's own pair while the push runs (its repeats keep the push)
# the mapping geometry: when pulsing, the static-friction floor becomes the duty floor of the pulses
self._map_geometry = replace(self._geometry, min_pct=pulse_min_pct()) if self._pulse_n else self._geometry
self._last_logged = None
@@ -576,6 +580,11 @@ class MossBaseAdapter:
want = pivot_tracks(twist_to_tracks(vx, wz, self._map_geometry), self._pivot_pct)
if want != (0, 0) and not self._enabled:
return False
+ if self._pushing is not None:
+ if want == self._push_origin:
+ want = self._pushing # the commander repeats itself: the push goes on, and is what is sent
+ else:
+ self._pushing = self._push_origin = None # a new order: the push is over
left, right = self._slice(want)
ok = self._drive(left, right)
if ok:
@@ -702,6 +711,7 @@ class MossBaseAdapter:
stalled_l = want_l != 0 and abs(l_new - l_old) < STALL_MIN_TICKS
stalled_r = want_r != 0 and abs(r_new - r_old) < STALL_MIN_TICKS
if not (stalled_l or stalled_r):
+ self._pushing = self._push_origin = None
return False
# Both commanded tracks frozen = the rover pushes against something. One track frozen
# while the other turns is a contact only when the frozen track was commanded at least
@@ -712,6 +722,21 @@ class MossBaseAdapter:
frozen_cmd, moving_cmd = (abs(want_l), abs(want_r)) if stalled_l else (abs(want_r), abs(want_l))
if frozen_cmd < moving_cmd:
return False
+ # Frozen below STALL_PUSH_PCT: push harder for one more window before calling it a
+ # contact (the tracks creep at the floor on a sagging battery). The pushed command
+ # keeps each track's sign; a track at 0 stays at 0.
+ if max(abs(want_l), abs(want_r)) < STALL_PUSH_PCT and self._pushing is None:
+ push = (0 if want_l == 0 else (STALL_PUSH_PCT if want_l > 0 else -STALL_PUSH_PCT),
+ 0 if want_r == 0 else (STALL_PUSH_PCT if want_r > 0 else -STALL_PUSH_PCT))
+ self._pushing = push
+ self._push_origin = (want_l, want_r)
+ self._want = push
+ self._drive_since = now
+ self._tick_hist = self._tick_hist[-1:]
+ _log().info(f"MOSS base: tracks frozen at L={want_l:+d}% R={want_r:+d}% - pushing at {STALL_PUSH_PCT} % for "
+ f"{STALL_S:.0f} s before calling it a contact")
+ return False
+ self._pushing = self._push_origin = None
self._send("stop")
self._stall_count += 1
self._stalled = True
diff --git a/tools/moss-fly.sh b/tools/moss-fly.sh
index eb204e8..fe7befd 100755
--- a/tools/moss-fly.sh
+++ b/tools/moss-fly.sh
@@ -73,7 +73,7 @@ export MOSS_CAMERA="${MOSS_CAMERA:-1}"
# open ground. The other explorer knobs (MOSS_GOAL_MAX_M, MOSS_EXPLORE_DISTANCE_EXP)
# keep their code defaults: see docs/cockpit.md
export MOSS_EXPLORE_RADIUS_M="${MOSS_EXPLORE_RADIUS_M:-4}"
-NERF_SPEED="${MOSS_NERF_SPEED:-0.5}"
+NERF_SPEED="${MOSS_NERF_SPEED:-0.7}" # the planner's speed scale: 0.5 kept the tracks at the edge of their floor on a sagging battery
COCKPIT_PORT="${MOSS_COCKPIT_PORT:-8904}"
PREFLIGHT_JSON="$MOSS_STATE_DIR/preflight.json" # served by the cockpit as /preflight.json
if [ "${MOCK:-0}" = "1" ]; then export MOSS_MOCK_BUS=1; fi