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

gamepad: no deadman by default, the sticks drive (MOSS_PAD_DEADMAN=r1 brings the held button back); launcher, flight check and docs follow; blueprints bench on the measured 0.32 m/s plateau

metroxd1bf892e0bb6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4143472..b351c36 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
Hardware revisions. Dates are when it was real, not when it was planned.
+- **24 October 2026, no deadman on the pad.** A small tracked rover at walking pace does not need a held button: a stick out of its deadzone drives, centred sticks stop (0.5 s of zeros, then silence); the neutral-first trust gate and the firmware's 300 ms stop stay. `MOSS_PAD_DEADMAN=r1` (or an SDL button number) in `robot.env` brings the held button back. Launcher, flight check and docs follow.
- **11 October 2026, dimOS software moves into this repository** (`moss_dimos`): base, lidar odometry, map, planner, explorer, gamepad, recorder, flight check, launcher, cockpit. dimOS itself stays an outside dependency, installed from git ([Software.md](Software.md)).
- **10 October 2026, first drive at the gamepad.** The V0.5 rover, arm mounted, driven on the floor from a gamepad through dimOS: forward, reverse, turns, pivots. What it took and what it showed:
- Firmware `qtpy-mdd3a-v3` on the QT Py ESP32-S3 (`firmware/MOSS_QTPY_MDD3A/`): the 25 % commissioning limit is gone, full stick is 100 % PWM (at 25 % the loaded tracks did not move at all); left track direction fixed in the firmware, encoder counts follow; `ramp UP DOWN` sets the rise and fall slopes live; a build switch for the Cytron MDD10A (PWM + DIR) next to the MDD3A build; the board names its driver in the banner and the telemetry. Host test updated.
diff --git a/Software.md b/Software.md
index 2c6f63e..cd3d3fd 100644
--- a/Software.md
+++ b/Software.md
@@ -27,7 +27,7 @@ To reflash the QT Py, from the root of the checkout: build the images with `ardu
| Module | Role |
|---|---|
| `moss_adapter.py`, `moss_mock.py` | the tracked-base adapter (twist to track percent, keepalive inside the firmware's 300 ms deadman) and a fake firmware for runs without motors |
-| `gamepad.py` | the pad: twist behind a deadman, slew-limited, sized to the base |
+| `gamepad.py` | the pad: twist from the sticks (no deadman by default), slew-limited, sized to the base |
| `c1_serial.py`, `rplidar_c1.py` | the RPLidar C1 driver and its dimOS module |
| `lidar_odometry.py` | the pose, from the lidar (kiss-icp) |
| `costmap2d.py` | the 2D map the planner and the cockpit read |
@@ -72,7 +72,7 @@ MOCK=1 tools/moss-fly.sh map # fake motor board, no motor; the lidar mu
tools/moss-teleop.sh # the pad only: gates, then moss-gamepad
```
-Pad on the dimOS path: hold R1 to drive (the deadman), left stick forward and back, right stick to turn, R2 boost. Release R1 and the tracks stop.
+Pad on the dimOS path: left stick forward and back, right stick to turn, R2 boost; centre the sticks and the tracks stop. No deadman by default (`MOSS_PAD_DEADMAN=r1` in `robot.env` brings the held R1 back).
Every gate refuses rather than guesses, with the fix on the same line: a stack already up, a missing board, a port held by another program, a mute firmware, a battery at the BMS floor, a lidar that does not spin. Nothing moves by itself: in `map` only the pad drives; in `explore` the planner moves on a goal or once exploration is armed. The firmware stops the tracks 300 ms after the last command, whatever happens above it.
diff --git a/benches/bench_gamepad_cold.py b/benches/bench_gamepad_cold.py
index 8807a26..3ec2d32 100644
--- a/benches/bench_gamepad_cold.py
+++ b/benches/bench_gamepad_cold.py
@@ -76,14 +76,17 @@ check("pygame" not in sys.modules, "mapping is testable with pygame unimported")
check((LIN, ANG) == (0.45, 0.8), f"ceilings: {LIN} m/s, {ANG} rad/s")
# The pad contract as literals: every press below goes through
# gp.DEADMAN_BUTTON, so without these a moved constant would still pass.
-check(gp.DEADMAN_BUTTON == 7,
- f"deadman = R1 = SDL button 7 on the MOSS pad (moss_pi's L1 is a different path): {gp.DEADMAN_BUTTON}")
+check(gp.DEADMAN_BUTTON is None,
+ f"no deadman by default: the sticks drive (MOSS_PAD_DEADMAN=r1 brings R1 back): {gp.DEADMAN_BUTTON}")
# the pad on its USB cable is an Xbox 360 pad to the kernel (xpad): R1 = button 5, right stick X = axis 3,
# triggers at rest = -1 on axes 2 and 5 (measured: js1 initial state axes 2 and 5 at -32767, sticks at 0)
-check(gp.pad_layout({}) == {"deadman": 7, "axis_right_x": 2, "axis_r2": 5}, "default layout = android (7, 2, 5)")
-check(gp.pad_layout({"MOSS_PAD_LAYOUT": "xinput"}) == {"deadman": 5, "axis_right_x": 3, "axis_r2": 5}, "xinput layout = (5, 3, 5)")
-check(gp.pad_layout({"MOSS_PAD_LAYOUT": "xinput", "MOSS_PAD_DEADMAN": "4"}) == {"deadman": 4, "axis_right_x": 3, "axis_r2": 5}, "one-value override wins")
-check(gp.pad_layout({"MOSS_PAD_LAYOUT": "nope", "MOSS_PAD_AXIS_R2": "x"}) == {"deadman": 7, "axis_right_x": 2, "axis_r2": 5}, "unknown layout / bad number -> android")
+check(gp.pad_layout({}) == {"deadman": None, "axis_right_x": 2, "axis_r2": 5}, "default layout = android, no deadman (None, 2, 5)")
+check(gp.pad_layout({"MOSS_PAD_LAYOUT": "xinput"}) == {"deadman": None, "axis_right_x": 3, "axis_r2": 5}, "xinput layout = (None, 3, 5)")
+check(gp.pad_layout({"MOSS_PAD_LAYOUT": "xinput", "MOSS_PAD_DEADMAN": "4"}) == {"deadman": 4, "axis_right_x": 3, "axis_r2": 5}, "MOSS_PAD_DEADMAN=4 -> that SDL button")
+check(gp.pad_layout({"MOSS_PAD_DEADMAN": "r1"})["deadman"] == 7 and gp.pad_layout({"MOSS_PAD_LAYOUT": "xinput", "MOSS_PAD_DEADMAN": "R1"})["deadman"] == 5
+ and gp.pad_layout({"MOSS_PAD_DEADMAN": "none"})["deadman"] is None and gp.pad_layout({"MOSS_PAD_DEADMAN": "x"})["deadman"] is None,
+ "MOSS_PAD_DEADMAN=r1 -> the layout's R1 (7 android, 5 xinput); none / unparseable -> no deadman")
+check(gp.pad_layout({"MOSS_PAD_LAYOUT": "nope", "MOSS_PAD_AXIS_R2": "x"}) == {"deadman": None, "axis_right_x": 2, "axis_r2": 5}, "unknown layout / bad number -> android")
check(gp.pad_index({}) == 0 and gp.pad_index({"MOSS_PAD_INDEX": "1"}) == 1 and gp.pad_index({"MOSS_PAD_INDEX": "-3"}) == 0, "MOSS_PAD_INDEX: 0 by default, clamped at 0")
check((gp.AXIS_LEFT_X, gp.AXIS_LEFT_Y, gp.AXIS_RIGHT_X, gp.AXIS_R2) == (0, 1, 2, 5),
"strafe = left X (axis 0), throttle = left Y (axis 1), turn = right X (axis 2), boost = R2 (axis 5)")
@@ -307,11 +310,28 @@ check(all(close(t.linear.x, 0.0) for t in published[-10:]) if published else Tru
js.pad.axes = [0.0, 0.0, 0.0, 0.0, 0.0, -1.0]
check(wait_for(lambda: spy.count("axes seen at neutral") == 1, 3.0),
"sticks at rest -> trust earned (logged once)")
+# 2a. NO DEADMAN (the default): a stick out of its deadzone drives, centred sticks stop
+n_rest = len(published)
+time.sleep(0.3)
+check(len(published) == n_rest, f"trusted, sticks at rest, no deadman -> nothing published ({len(published) - n_rest} messages)")
+js.pad.axes = [0.0, -1.0, 0.0, 0.0, 0.0, -1.0]
+check(wait_for(lambda: published and close(published[-1].linear.x, LIN), 3.0),
+ f"no deadman + stick forward -> vx = {LIN} m/s CEILING, no button held (got {published[-1].linear.x if published else None})")
+js.pad.axes = [0.0, 0.0, 0.0, 0.0, 0.0, -1.0]
+check(wait_for(lambda: close(published[-1].linear.x, 0.0), 3.0), "sticks back to centre -> zeros published (the brake window)")
+time.sleep(pad_module.brake_s + 0.3)
+n_silent = len(published)
+time.sleep(0.3)
+check(len(published) == n_silent and close(published[-1].linear.x, 0.0),
+ f"then SILENCE: no message after the brake window with the sticks centred ({len(published) - n_silent} extra)")
+# From here on the bench drives the OPTIONAL deadman (MOSS_PAD_DEADMAN=r1 -> R1 = SDL button 7 on the
+# MOSS pad): the module reads gp.DEADMAN_BUTTON on every tick, so the switch takes effect at once.
+gp.DEADMAN_BUTTON = 7
# deadman NOT held: still zeros even with a deflected stick
js.pad.axes = [0.0, -1.0, 0.0, 0.0, 0.0, -1.0]
time.sleep(0.3)
check(all(close(t.linear.x, 0.0) for t in published[-5:]),
- "stick forward WITHOUT the deadman held -> still zeros")
+ "deadman on, NOT held, stick forward -> still zeros")
# deadman held -> motion, CLAMPED at the ceiling
js.pad.buttons[gp.DEADMAN_BUTTON] = 1
check(wait_for(lambda: published and close(published[-1].linear.x, LIN), 3.0),
diff --git a/benches/bench_moss_blueprints_cold.py b/benches/bench_moss_blueprints_cold.py
index 0ba00e0..27224be 100644
--- a/benches/bench_moss_blueprints_cold.py
+++ b/benches/bench_moss_blueprints_cold.py
@@ -459,14 +459,15 @@ check("moss-gamepad: twist_command -> cmd_vel and tele_cmd_vel -> cmd_vel (direc
gk = atom(pad_bp, "GamepadTeleop").kwargs
g = MossGeometry.from_env()
lin, ang = teleop_speeds(g)
-check("moss-gamepad: stick scale = the base's: 0.45 m/s, 6.7669 rad/s (default geometry)",
- close(gk.get("linear_speed"), 0.45) and close(gk.get("angular_speed"), 2.0 * 2.0 * 0.45 / 0.266)
+V = g.mps_at_limit # the measured plateau at 100 % (moss_adapter.MossGeometry), not a literal
+check(f"moss-gamepad: stick scale = the base's: {V} m/s, {2.0 * 2.0 * V / 0.266:.4f} rad/s (default geometry)",
+ close(gk.get("linear_speed"), V) and close(gk.get("angular_speed"), 2.0 * 2.0 * V / 0.266)
and (gk.get("linear_speed"), gk.get("angular_speed")) == (lin, ang),
f"{gk.get('linear_speed')} m/s, {gk.get('angular_speed')} rad/s")
env_d = gk.get("envelope")
-check("moss-gamepad: the envelope rides as a plain dict: linear 0.45, lever 0.133, rim 1.35",
+check(f"moss-gamepad: the envelope rides as a plain dict: linear {V}, lever 0.133, rim {3.0 * V:.2f}",
isinstance(env_d, dict) and env_d == teleop_envelope(g)
- and close(env_d["lever"], 0.133) and close(env_d["rim"], 1.35), f"{env_d}")
+ and close(env_d["lever"], 0.133) and close(env_d["rim"], 3.0 * V), f"{env_d}")
os.environ["MOSS_MPS_AT_LIMIT"] = "0.30"
slow = atom(mb.build_moss_gamepad(), "GamepadTeleop").kwargs
os.environ.pop("MOSS_MPS_AT_LIMIT")
diff --git a/docs/base.md b/docs/base.md
index ab6f311..1681609 100644
--- a/docs/base.md
+++ b/docs/base.md
@@ -16,7 +16,9 @@ $ tools/moss-teleop.sh stop # stack down (the firmware deadman stopped the
$ MOCK=1 tools/moss-teleop.sh # same stack on the fake firmware, no motor
```
-Pad (a shanwan receiver in Android mode): **R1 held = deadman** (SDL button 7),
+Pad (a shanwan receiver in Android mode): **no deadman**, a stick out of its
+deadzone drives and centred sticks stop (`MOSS_PAD_DEADMAN=r1` brings a held
+button back: R1 is SDL button 7 on this pad, 5 on its USB cable),
left stick up/down = forward/back, right stick left/right = turn, R2 = boost
(capped at `MOSS_MAX_PCT`). The stick scale comes from the base's envelope
(`teleop_speeds`: full stick = `MOSS_MPS_AT_LIMIT`, full turn = a pivot at that
diff --git a/docs/cockpit.md b/docs/cockpit.md
index 4be9145..f1ef03e 100644
--- a/docs/cockpit.md
+++ b/docs/cockpit.md
@@ -323,7 +323,7 @@ Other variables:
| `PROOF_S` | how long `tools/moss-fly.sh` waits for the stack to prove itself in its log, 120 s by default |
| `MOSS_MOCK_BUS=1` | the fake firmware, no motors (`MOCK=1` on the launchers sets it) |
| `MOSS_STATE_DIR` | the state directory, `~/.local/state/moss` by default: recordings, the saved flight check |
-| `MOSS_BRAKE_S` | how long the pad sends zeros after the deadman is released, 0.5 s by default, 0 to 1.0 s |
+| `MOSS_BRAKE_S` | how long the pad sends zeros after the sticks return to centre (or the optional deadman is released), 0.5 s by default, 0 to 1.0 s |
| `MOSS_TURN_GAIN` | turn authority against forward speed on the pad, 2 by default, 0.5 to 4 ([base.md](base.md)) |
| `MOSS_OCCUPIED_AT` | how many hits a costmap cell needs to be a wall, 2 by default, 1 to 10: two places at least `MOSS_NEW_VIEWPOINT_M` apart, never one spot, so somebody standing next to a parked rover never walls it in. 1 makes the first sighting a wall: a faster block, and every passer-by a wall |
| `MOSS_NEW_VIEWPOINT_M` | how far the rover must move before the same cell takes another hit, 0.10 m by default, 0 to 1 |
diff --git a/moss_dimos/blueprints.py b/moss_dimos/blueprints.py
index eef6c71..64be7ea 100644
--- a/moss_dimos/blueprints.py
+++ b/moss_dimos/blueprints.py
@@ -16,8 +16,8 @@ costs the coordinator class and the two side effects below, nothing more.
Nothing here moves the robot by itself:
* moss-gamepad and moss-nav have no planner and no explorer: the pad drives
- the coordinator directly (tele_cmd_vel -> cmd_vel), and only while its
- deadman is held.
+ the coordinator directly (tele_cmd_vel -> cmd_vel), and only while a
+ stick is out of its deadzone (no deadman by default, MOSS_PAD_DEADMAN).
* moss-explore's explorer starts only on Bool(True) on `explore_cmd`
(tools/explore_ctl.py start, the cockpit), and the planner moves only
toward a goal on `goal_request` / `clicked_point`. MovementManager
diff --git a/moss_dimos/gamepad.py b/moss_dimos/gamepad.py
index aa0ee6b..b34571d 100644
--- a/moss_dimos/gamepad.py
+++ b/moss_dimos/gamepad.py
@@ -11,13 +11,16 @@ Mapping (standard dual-stick):
The tracked base ignores vy (moss_adapter); it is still published, so the
same module drives a holonomic base unchanged.
-Publishes ONLY while the deadman (R1) is held, plus a brake of zeros right
-after it is released - 0.5 s by default, up to 1.0 s with MOSS_BRAKE_S - then
+Publishes ONLY while a stick is out of its deadzone - there is no deadman
+by default: a small tracked rover at walking pace does not need a held button,
+and MOSS_PAD_DEADMAN=r1 (or an SDL button number) brings one back - plus a
+brake of zeros right after the sticks return to centre (or the optional
+deadman is released) - 0.5 s by default, up to 1.0 s with MOSS_BRAKE_S - then
silence (see BRAKE_S and resolve_brake_s). A pad lying at rest owns nothing,
so the same stack can explore on its own while the pad is plugged in.
-Pressing the deadman again ends that brake window on the spot
-(BRAKE_CANCEL_ON_DEADMAN), but only on a tick that is trusted and about to
-publish - see the worker.
+Moving a stick again (or pressing the deadman again) ends that brake window
+on the spot (BRAKE_CANCEL_ON_DEADMAN), but only on a tick that is trusted and
+about to publish - see the worker.
Wiring in this package's blueprints (moss_dimos.blueprints):
moss-gamepad, moss-nav tele_cmd_vel is REMAPPED to cmd_vel: direct
@@ -70,21 +73,34 @@ RESCAN_PERIOD_S = 2.0 # how often we re-scan SDL for a pad
# The pad's LAYOUT depends on how it shows up: the MOSS pad on its 2.4 GHz dongle in Android mode
# (2563:0526) is the default; the same pad on its USB cable enumerates as an Xbox 360 pad (045e:028e,
# kernel xpad), where R1 is button 5, the right stick X is axis 3 and the triggers are axes 2 and 5.
-# MOSS_PAD_LAYOUT=android|xinput picks a set; MOSS_PAD_DEADMAN / MOSS_PAD_AXIS_RIGHT_X / MOSS_PAD_AXIS_R2
-# override one value each; MOSS_PAD_INDEX picks the SDL joystick when several are plugged (the mute
-# dongle is usually index 0). All read once at import.
+# MOSS_PAD_LAYOUT=android|xinput picks a set; MOSS_PAD_AXIS_RIGHT_X / MOSS_PAD_AXIS_R2 override one
+# value each; MOSS_PAD_DEADMAN adds a held button (none by default: r1 = the layout's R1, or an SDL
+# button number); MOSS_PAD_INDEX picks the SDL joystick when several are plugged (the mute dongle is
+# usually index 0). All read once at import.
PAD_LAYOUTS = {
- "android": {"deadman": 7, "axis_right_x": 2, "axis_r2": 5},
- "xinput": {"deadman": 5, "axis_right_x": 3, "axis_r2": 5},
+ "android": {"r1": 7, "axis_right_x": 2, "axis_r2": 5},
+ "xinput": {"r1": 5, "axis_right_x": 3, "axis_r2": 5},
}
+DEADMAN_OFF = ("", "none", "off", "no") # MOSS_PAD_DEADMAN values that mean: no deadman
-def pad_layout(env: Mapping[str, str] | None = None) -> dict[str, int]:
- """The button / axis numbers in force: a named layout, then one-value overrides. Pure."""
+def pad_layout(env: Mapping[str, str] | None = None) -> dict[str, int | None]:
+ """The button / axis numbers in force: a named layout, then one-value overrides. Pure.
+ "deadman" is None by default (the sticks drive); MOSS_PAD_DEADMAN=r1 is the layout's R1,
+ an integer is that SDL button, none / off / empty is no deadman."""
e = os.environ if env is None else env
name = (e.get("MOSS_PAD_LAYOUT") or "android").strip().lower()
- out = dict(PAD_LAYOUTS.get(name, PAD_LAYOUTS["android"]))
- for key, var in (("deadman", "MOSS_PAD_DEADMAN"), ("axis_right_x", "MOSS_PAD_AXIS_RIGHT_X"), ("axis_r2", "MOSS_PAD_AXIS_R2")):
+ base = PAD_LAYOUTS.get(name, PAD_LAYOUTS["android"])
+ out: dict[str, int | None] = {"deadman": None, "axis_right_x": base["axis_right_x"], "axis_r2": base["axis_r2"]}
+ raw = (e.get("MOSS_PAD_DEADMAN") or "").strip().lower()
+ if raw == "r1":
+ out["deadman"] = base["r1"]
+ elif raw not in DEADMAN_OFF:
+ try:
+ out["deadman"] = int(raw)
+ except ValueError:
+ pass
+ for key, var in (("axis_right_x", "MOSS_PAD_AXIS_RIGHT_X"), ("axis_r2", "MOSS_PAD_AXIS_R2")):
raw = (e.get(var) or "").strip()
if raw:
try:
@@ -146,7 +162,7 @@ CLAMP_ANGULAR_RADS = 0.8
# passes its own envelope, sized to the tracks (moss_adapter.teleop_envelope).
DEFAULT_LEVER_M = 0.50 # m of rim speed per rad/s of rotation
DEFAULT_RIM_MS = 0.45 # max rim speed however the sticks are mixed
-DEADMAN_BUTTON = _LAYOUT["deadman"] # R1: SDL button 7 on the 2563:0526 pad in Android mode (5 on the cable, xinput). Held = commands allowed; released = zeros, always
+DEADMAN_BUTTON = _LAYOUT["deadman"] # None = no deadman, the sticks drive (default). MOSS_PAD_DEADMAN=r1: SDL button 7 on the 2563:0526 pad in Android mode, 5 on the cable (xinput). Held = commands allowed; released = zeros, always
BRAKE_S = 0.5 # how long the zeros keep flowing after the deadman is
# released - then TOTAL SILENCE until it is held again.
# dimOS's MovementManager reads ANY tele_cmd_vel message,
@@ -286,6 +302,13 @@ def axes_neutral(ax0: float, ax1: float, ax2: float, deadzone: float) -> bool:
return abs(ax0) < deadzone and abs(ax1) < deadzone and abs(ax2) < deadzone
+def sticks_active(ax0: float, ax1: float, ax2: float, deadzone: float) -> bool:
+ """True when a drive axis is out of its deadzone. Without a deadman this IS
+ the "command present" condition: the exact complement of axes_neutral, so
+ an inactive tick is a tick whose twist would have been zero anyway."""
+ return not axes_neutral(ax0, ax1, ax2, deadzone)
+
+
def axes_to_twist(ax0: float, ax1: float, ax2: float, ax5: float,
cfg: TeleopConfig) -> tuple[float, float, float]:
"""Raw SDL axis values -> (vx m/s, vy m/s, wz rad/s).
@@ -405,11 +428,18 @@ class GamepadTeleop(Module):
trusted = False # neutral-first trust gate
prev_vx = prev_vy = 0.0 # slew-limiter state
brake_until = 0.0 # publish zeros until this instant, then shut up
- prev_deadman = False # to see the RISING edge of the deadman
+ prev_active = False # to see the RISING edge of a command (stick out, or deadman pressed)
waiting_logged = False
- logger.info("gamepad brake window: %.2f s of zeros after the deadman is "
- "released, then silence (cancel-on-press: %s)",
- self.brake_s, BRAKE_CANCEL_ON_DEADMAN)
+ if DEADMAN_BUTTON is None:
+ logger.info("gamepad: no deadman - a stick out of its deadzone drives, centred sticks stop "
+ "(MOSS_PAD_DEADMAN=r1 brings the held button back)")
+ else:
+ logger.info("gamepad: deadman = SDL button %d, held to drive", DEADMAN_BUTTON)
+ logger.info("gamepad brake window: %.2f s of zeros after the sticks return to centre%s, "
+ "then silence (cancel-on-press: %s)",
+ self.brake_s,
+ "" if DEADMAN_BUTTON is None else " or the deadman is released",
+ BRAKE_CANCEL_ON_DEADMAN)
try:
while not self._stop_event.is_set():
if pad is None:
@@ -429,13 +459,16 @@ class GamepadTeleop(Module):
pygame.event.pump()
axes = (_axis(pad, AXIS_LEFT_X), _axis(pad, AXIS_LEFT_Y),
_axis(pad, AXIS_RIGHT_X), _axis(pad, AXIS_R2))
- deadman = bool(pad.get_button(DEADMAN_BUTTON)) if pad.get_numbuttons() > DEADMAN_BUTTON else False
+ if DEADMAN_BUTTON is None:
+ deadman = True # no held button required
+ else:
+ deadman = bool(pad.get_button(DEADMAN_BUTTON)) if pad.get_numbuttons() > DEADMAN_BUTTON else False
if pygame.joystick.get_count() <= self.joystick_index:
raise pygame.error("joystick disappeared")
except pygame.error as exc:
pad = None
trusted = False
- prev_deadman = False # a pad that is gone holds nothing
+ prev_active = False # a pad that is gone holds nothing
# ... and it holds no RAMP either. The slew state must die
# with the pad: otherwise a pad that vanished for one read
# while driving at the ceiling comes back with 0.45 m/s of
@@ -453,8 +486,9 @@ class GamepadTeleop(Module):
if not trusted:
if axes_neutral(axes[0], axes[1], axes[2], self.cfg.deadzone):
trusted = True
- logger.info("Gamepad axes seen at neutral - commands now trusted "
- "(hold the deadman button to drive)")
+ logger.info("Gamepad axes seen at neutral - commands now trusted (%s)",
+ "move a stick to drive" if DEADMAN_BUTTON is None
+ else "hold the deadman button to drive")
else:
if time.monotonic() < brake_until:
self._publish(0.0, 0.0, 0.0)
@@ -477,11 +511,16 @@ class GamepadTeleop(Module):
# to 1 (0.011 s). BRAKE_S exists to REPEAT the stop order on a
# latest-only bus; the cancel may therefore only run on a tick
# that is itself about to publish a command - i.e. here.
- brake_until = brake_window_after_press(brake_until, deadman,
- prev_deadman)
- prev_deadman = deadman
- # DEADMAN: no held button, no motion - ever.
- if not deadman:
+ # A COMMAND IS PRESENT when the optional deadman is held (always, when there
+ # is none) AND, without a deadman, a stick is out of its deadzone: a pad lying
+ # at rest publishes nothing either way.
+ active = deadman and (DEADMAN_BUTTON is not None
+ or sticks_active(axes[0], axes[1], axes[2], self.cfg.deadzone))
+ brake_until = brake_window_after_press(brake_until, active,
+ prev_active)
+ prev_active = active
+ # NO COMMAND (sticks centred, or the optional deadman released): no motion - ever.
+ if not active:
# Releasing also resets the slew state: the ramp restarts
# from rest, so a re-press with the sticks centred cannot
# replay the last driven speed.
diff --git a/tools/moss-fly.sh b/tools/moss-fly.sh
index bfefbfb..64e5ba1 100755
--- a/tools/moss-fly.sh
+++ b/tools/moss-fly.sh
@@ -17,7 +17,7 @@
# tools/moss-teleop.sh stays the pad-only launcher.
#
# Every gate REFUSES rather than guesses, with the fix on the same line.
-# Nothing moves by itself: in `map` only the pad drives (deadman held); in
+# Nothing moves by itself: in `map` only the pad drives (a stick out of its deadzone); in
# `explore` the planner moves only on a goal or once exploration is armed
# (EXPLORE=1 here, or the cockpit's button). The firmware stops the tracks
# 300 ms after the last command whatever happens up here.
@@ -393,7 +393,7 @@ fi
echo "== READY: moss-dimos.$BP =="
if [ "$BP" = "moss-nav" ]; then
- echo " pad: hold R1 (deadman), left stick forward/back, right stick turn - the map builds as you drive"
+ echo " pad: left stick forward/back, right stick turn (no deadman) - the map builds as you drive"
elif [ "${EXPLORE:-0}" != "1" ]; then
echo " exploration NOT armed: the cockpit's 'Start exploration', or a goal click on its map"
fi
diff --git a/tools/moss-teleop.sh b/tools/moss-teleop.sh
index 920bee4..e628bdd 100755
--- a/tools/moss-teleop.sh
+++ b/tools/moss-teleop.sh
@@ -14,8 +14,9 @@
# Every gate REFUSES rather than guesses: a stack already up,
# no pad, no board, a port held by a bench, a mute firmware, a battery at the
# BMS floor - each is a refusal with the fix on the same line. Nothing moves
-# until the deadman is held AND a stick leaves the deadzone; the stack can
-# stay up with the pad on the table.
+# until a stick leaves the deadzone (no deadman by default; MOSS_PAD_DEADMAN=r1
+# in robot.env brings the held button back); the stack can stay up with the pad
+# on the table.
set -u
cd "$(dirname "$0")/.." || exit 1
# robot.env: what THIS robot is (MOSS_DRIVER, MOSS_PAD_LAYOUT, measured numbers), next to the
@@ -139,7 +140,11 @@ if [ $OK_BASE != 1 ] || [ $OK_PAD != 1 ] || [ $OK_TRUST != 1 ]; then
fi
echo "== 5/5 YOU CAN DRIVE (base connected, pad seen at neutral by the stack, layout ${MOSS_PAD_LAYOUT:-android}) =="
-echo " deadman = R1 (right shoulder) held the whole time"
+if [ -n "${MOSS_PAD_DEADMAN:-}" ] && [ "${MOSS_PAD_DEADMAN}" != "none" ]; then
+ echo " deadman = MOSS_PAD_DEADMAN (${MOSS_PAD_DEADMAN}) held the whole time; release = 0.5 s of zeros then silence"
+else
+ echo " no deadman: a stick out of its deadzone drives, centred sticks = 0.5 s of zeros then silence"
+fi
echo " left stick up/down = forward/back right stick left/right = turn R2 = boost (capped at ${MOSS_MAX_PCT} %)"
-echo " release R1 = 0.5 s of zeros then silence; the firmware stops 300 ms after the last drive"
+echo " the firmware stops 300 ms after the last drive"
echo " stop: tools/moss-teleop.sh stop watch: tools/moss-teleop.sh log"
diff --git a/tools/moss_preflight.py b/tools/moss_preflight.py
index 5b372e6..e0504eb 100755
--- a/tools/moss_preflight.py
+++ b/tools/moss_preflight.py
@@ -480,7 +480,7 @@ def pad_verdict(name: str, init_axes, layout: str) -> tuple[bool, str]:
return False, f"{name}: an Xbox 360 pad to the kernel (the pad on its cable), MOSS_PAD_LAYOUT is {lay}: set MOSS_PAD_LAYOUT=xinput in robot.env"
if "shanwan" in n and lay == "xinput":
return False, f"{name}: the dongle in Android mode, MOSS_PAD_LAYOUT is xinput: set MOSS_PAD_LAYOUT=android in robot.env"
- return True, f"{name} alive, layout {lay} (deadman = R1)"
+ return True, f"{name} alive, layout {lay}"
# ── helpers ────────────────────────────────────────────────────────────────