MOSS: a small, mostly 3D-printed litter-picking rover. Cleaner streets, one maker at a time.
Python
MOSS: build log, concept, BOM, data rules, media (concept V2.3.1 + build update 17/09), software scaffold derived from vector-dimos (gamepad teleop, differential-drive kinematics, cold tests)
metroxd6d958cf7340
diff --git a/.gitignore b/.gitignorenew file mode 100644index 0000000..4337700--- /dev/null+++ b/.gitignore@@ -0,0 +1,8 @@+__pycache__/+*.pyc+*.egg-info/+.venv/+.env+recordings/+*.f3d+*.f3zdiff --git a/LICENSE b/LICENSEnew file mode 100644index 0000000..d645695--- /dev/null+++ b/LICENSE@@ -0,0 +1,202 @@++ Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.diff --git a/NOTICE b/NOTICEnew file mode 100644index 0000000..038126c--- /dev/null+++ b/NOTICE@@ -0,0 +1,9 @@+MOSS — a small, mostly 3D-printed litter-picking rover+Copyright 2026 Laurent Genoud (Show Robotics), Hua Hin, Thailand.++Code: Apache License, Version 2.0 (see LICENSE).+Hardware design files and documentation (docs/, hardware/, media/): CC BY 4.0.++moss_dimos/gamepad.py is derived from vector-dimos (https://github.com/metrox-eth/vector-dimos),+Copyright 2026 Laurent Genoud, Apache-2.0, itself an external blueprint for dimOS+(https://github.com/dimensionalOS/dimos), Copyright 2025 Dimensional Inc., Apache-2.0.diff --git a/README.md b/README.mdnew file mode 100644index 0000000..b8fdf45--- /dev/null+++ b/README.md@@ -0,0 +1,43 @@+# MOSS++Cleaner streets, one maker at a time.++MOSS is a small, mostly 3D-printed litter-picking rover: tracked base, a collection bin, and an arm derived from the SO-101 with a NormaCore parallel gripper. Target parts cost: 500 to 700 USD plus a Jetson (before tax and shipping, labour and tools excluded). The goal is a design any maker can print, build, improve, and run where they live.++This repository is the build log, the design files as they become real, and the software as it gets written. It started on 15 September 2026. Nothing here is finished; everything here is real.++++## Status (17 September 2026)++- Printed: two flexible tracks (TPU 95A), the collection bin and its top cover (PLA).+- Printing: the main chassis (PETG), inner side rails, cross spacers, motor brackets.+- On the bench: Jetson Orin Nano 8 GB, Intel RealSense depth camera, Waveshare controller board, 2 × Cytron MD10C R3 motor drivers, 2 × geared motors with encoders, fuse holder, converter, interface modules.+- Ordered: steel shafts (5/6/8 mm), bearings (608, 626), shaft collars, 6 mm couplings, M3 and M4 fasteners.+- Software: a scaffold derived from [vector-dimos](https://github.com/metrox-eth/vector-dimos) (gamepad teleop and differential-drive kinematics, cold-tested, not yet run on the rover).+- CAD: designed in Fusion 360; STL and STEP exports will land in `hardware/` as each part is validated by a real print.++## Plan++1. Print, build, and run the base on a real roadside, teleoperated with a gamepad on [dimOS](https://github.com/dimensionalOS/dimos).+2. Mount the arm and gripper; collect teleop demonstrations in the LeRobot dataset format.+3. Train a first pick-up policy on pooled data. The first video of an autonomous pick will be exactly that: autonomous, or it will not be posted.+4. Publish the design and the build documentation so others can build their own.++## Data++Teleop data recorded by MOSS builders is meant to be pooled and open, so the shared model gets better with every robot. Details and the rules we propose are in [docs/data.md](docs/data.md).++## Layout++- `docs/` concept, build log, bill of materials, data, roadmap, software notes.+- `hardware/` design files (coming as parts are validated).+- `moss_dimos/` software scaffold (dimOS modules).+- `media/` videos and images of the concept and the build.+- `tests/` cold tests (no hardware needed).++## License++Code under Apache-2.0. Hardware files and documentation under CC BY 4.0. See `NOTICE`.++Built in public by [@metrox_eth](https://x.com/metrox_eth).diff --git a/docs/bom.md b/docs/bom.mdnew file mode 100644index 0000000..a5ba967--- /dev/null+++ b/docs/bom.md@@ -0,0 +1,36 @@+# Bill of materials (work in progress)++Target: 500 to 700 USD in parts plus a Jetson, before tax and shipping. Prices are not listed yet; they will be once the first unit is complete and the list is stable.++## Printed parts+| Part | Material | Printer used | Status |+|---|---|---|---|+| Track (×2) | TPU 95A | Bambu Lab P1S | printed |+| Collection bin | PLA | Bambu Lab H2S | printed |+| Top cover | PLA | H2S | printed |+| Main chassis | PETG | H2S | printing |+| Inner side rails (×2) | PETG | P1S | printing |+| Cross spacers (×4) | PETG | P1S | printing |+| Outer side rail | PETG | P1S | next plate |+| Motor brackets (×2) | PETG | P1S | next plate |++## Electronics+- Jetson Orin Nano 8 GB (brain)+- Intel RealSense depth camera+- Waveshare controller board+- 2 × Cytron MD10C R3 motor drivers+- 2 × geared DC motors with encoders+- Fuse holder, DC converter, interface modules++## Mechanical hardware+- Steel shafts 5 / 6 / 8 mm (cut to length)+- Bearings 608 and 626 (625 also in stock)+- Shaft collars 5 / 6 / 8 mm+- Rigid couplings 6 mm to 6 mm+- Fasteners M3 and M4++## Arm+- SO-101 derived arm (6 DoF)+- NormaCore parallel gripper++diff --git a/docs/build_log.md b/docs/build_log.mdnew file mode 100644index 0000000..7f580b8--- /dev/null+++ b/docs/build_log.md@@ -0,0 +1,17 @@+# Build log++## 2026-09-15+Concept video V2.3.1 published. Target parts cost stated: 500 to 700 USD plus a Jetson.++## 2026-09-16+First prints started on two printers: the collection bin (PLA, Bambu Lab H2S) and a flexible track (TPU 95A, Bambu Lab P1S). Both finished the same evening.++++## 2026-09-17+Two tracks, the bin and its top cover are done. The main chassis is printing in PETG on the H2S; the inner side rails and cross spacers on the P1S. Next plate: one outer side rail and two motor brackets. Shafts, bearings, collars, couplings and fasteners ordered.+++++Video: `media/video/MOSS_build_update_20260917.mp4`.diff --git a/docs/concept.md b/docs/concept.mdnew file mode 100644index 0000000..468cb48--- /dev/null+++ b/docs/concept.md@@ -0,0 +1,15 @@+# Concept++MOSS is a litter-picking rover for sidewalks, roadsides and parks: small enough to print, cheap enough to build several, useful enough to keep.++++- Tracked base (two motors with encoders, differential drive), printed tracks in TPU.+- Collection bin on top, emptied by hand at the end of a run.+- Arm derived from the SO-101 (6 DoF, open source) with a NormaCore parallel gripper.+- Brain: Jetson Orin Nano 8 GB; perception: an Intel RealSense depth camera.+- Software: dimOS for navigation and teleop, LeRobot for data and policies.++The criterion we use for success: pick up more litter with less technology. Every added part has to earn its place against a person with a bag.++Concept video (V2.3.1, 15 September 2026): `media/video/MOSS_V2_3_1_20260915.mp4` (concept simulation, scripted robot; not a demo of a working policy).diff --git a/docs/data.md b/docs/data.mdnew file mode 100644index 0000000..0418a3f--- /dev/null+++ b/docs/data.md@@ -0,0 +1,12 @@+# Data++What we want is a robot that works. Data is how it gets there.++Proposed rules for MOSS builders:++1. Teleop demonstrations are recorded in the LeRobot dataset format, with the same camera names on every robot, so datasets can be pooled without rework.+2. Pooled datasets are published under an open license on Hugging Face. Anyone can train on them.+3. Each builder keeps the right to do what they want with their own recordings, including selling them. The pooled copy stays open.+4. The first policy trained on pooled data is evaluated on real litter, on a real roadside, and the numbers are published whether they are good or not.++The camera layout and the recording tooling will be fixed in this repository before the first pooled dataset exists.diff --git a/docs/roadmap.md b/docs/roadmap.mdnew file mode 100644index 0000000..2bf429f--- /dev/null+++ b/docs/roadmap.md@@ -0,0 +1,8 @@+# Roadmap++- **Now**: print and assemble the base; validate each printed part on the real thing.+- **Next**: first roadside run, teleoperated with a gamepad through dimOS; first recordings.+- **Then**: mount the arm and gripper; collect pick-up demonstrations; publish the first pooled dataset.+- **Later**: first policy; first autonomous pick on video; kits so the first hundred builders do not have to source parts themselves.++No dates. Each step is posted when it is real.diff --git a/docs/software.md b/docs/software.mdnew file mode 100644index 0000000..b282b32--- /dev/null+++ b/docs/software.md@@ -0,0 +1,9 @@+# Software notes++MOSS runs on dimOS. The software here starts as a scaffold derived from vector-dimos, the external dimOS blueprint written for VECTOR (a mecanum rover on the same Jetson Orin Nano 8 GB).++What carries over as is: gamepad teleop publishing a Twist, the rig/onboard split over zenoh, the recording tooling.++What changes: VECTOR is holonomic (mecanum), MOSS is a differential-drive tracked rover. The strafe axis of the pad is ignored, and the motor layer is two Cytron MD10C drivers with encoder feedback instead of RS485 servo drives. `moss_dimos/diffdrive.py` holds the kinematics; the driver module is not written yet.++Everything in `moss_dimos/` is cold-tested only until the base runs.diff --git a/hardware/README.md b/hardware/README.mdnew file mode 100644index 0000000..85932c3--- /dev/null+++ b/hardware/README.md@@ -0,0 +1,3 @@+# Hardware++Design in Fusion 360. STL and STEP files will be added here part by part, each one after it has been printed and fitted on the real robot. Until then, the photos in `media/` and the list in `docs/bom.md` are the reference.diff --git a/media/images/build_02_first_parts_20260917.jpg b/media/images/build_02_first_parts_20260917.jpgnew file mode 100644index 0000000..c80f5baBinary files /dev/null and b/media/images/build_02_first_parts_20260917.jpg differdiff --git a/media/images/build_03_electronics_20260917.jpg b/media/images/build_03_electronics_20260917.jpgnew file mode 100644index 0000000..e0d9996Binary files /dev/null and b/media/images/build_03_electronics_20260917.jpg differdiff --git a/media/images/build_04_structure_20260917.jpg b/media/images/build_04_structure_20260917.jpgnew file mode 100644index 0000000..45a95d2Binary files /dev/null and b/media/images/build_04_structure_20260917.jpg differdiff --git a/media/images/build_05_hardware_ordered_20260917.jpg b/media/images/build_05_hardware_ordered_20260917.jpgnew file mode 100644index 0000000..bcafca0Binary files /dev/null and b/media/images/build_05_hardware_ordered_20260917.jpg differdiff --git a/media/images/concept_01_concept_v2_3_1.jpg b/media/images/concept_01_concept_v2_3_1.jpgnew file mode 100644index 0000000..6103cebBinary files /dev/null and b/media/images/concept_01_concept_v2_3_1.jpg differdiff --git a/media/images/concept_02_pickup_v2_3_1.jpg b/media/images/concept_02_pickup_v2_3_1.jpgnew file mode 100644index 0000000..3ceb9c2Binary files /dev/null and b/media/images/concept_02_pickup_v2_3_1.jpg differdiff --git a/media/images/concept_03_target_v2_3_1.jpg b/media/images/concept_03_target_v2_3_1.jpgnew file mode 100644index 0000000..65f6aa4Binary files /dev/null and b/media/images/concept_03_target_v2_3_1.jpg differdiff --git a/media/video/MOSS_V2_3_1_20260915.mp4 b/media/video/MOSS_V2_3_1_20260915.mp4new file mode 100644index 0000000..84cf6edBinary files /dev/null and b/media/video/MOSS_V2_3_1_20260915.mp4 differdiff --git a/media/video/MOSS_build_update_20260917.mp4 b/media/video/MOSS_build_update_20260917.mp4new file mode 100644index 0000000..cbca7edBinary files /dev/null and b/media/video/MOSS_build_update_20260917.mp4 differdiff --git a/moss_dimos/__init__.py b/moss_dimos/__init__.pynew file mode 100644index 0000000..89245b7--- /dev/null+++ b/moss_dimos/__init__.py@@ -0,0 +1 @@+"""moss_dimos - dimOS modules for the MOSS litter-picking rover (scaffold)."""diff --git a/moss_dimos/diffdrive.py b/moss_dimos/diffdrive.pynew file mode 100644index 0000000..dac515d--- /dev/null+++ b/moss_dimos/diffdrive.py@@ -0,0 +1,42 @@+"""Differential-drive kinematics for MOSS (tracked base, two motors).++Pure functions, no hardware, no dimOS import: cold-testable anywhere.++Convention: vx forward in m/s, wz counter-clockwise in rad/s, track_width in m+(distance between the two track centrelines). Left/right speeds in m/s at the+track. vy is accepted and ignored: a tracked rover cannot strafe.+"""+from __future__ import annotations++from dataclasses import dataclass+++@dataclass(frozen=True)+class DiffDriveConfig:+ track_width_m: float = 0.30+ max_track_speed_mps: float = 0.6+++def twist_to_tracks(vx: float, wz: float, cfg: DiffDriveConfig, vy: float = 0.0) -> tuple[float, float]:+ """Twist -> (left, right) track speeds in m/s, scaled to stay within the limit.++ Scaling (not clipping) keeps the turn radius when a command is too fast:+ a full-speed forward plus a turn slows both tracks together instead of+ flattening the turn.+ """+ del vy # no strafe on tracks+ half = 0.5 * cfg.track_width_m+ left = vx - wz * half+ right = vx + wz * half+ peak = max(abs(left), abs(right))+ if peak > cfg.max_track_speed_mps > 0:+ k = cfg.max_track_speed_mps / peak+ left, right = left * k, right * k+ return left, right+++def tracks_to_twist(left: float, right: float, cfg: DiffDriveConfig) -> tuple[float, float]:+ """(left, right) track speeds -> (vx, wz). Inverse of twist_to_tracks when unscaled."""+ vx = 0.5 * (left + right)+ wz = (right - left) / cfg.track_width_m+ return vx, wzdiff --git a/moss_dimos/gamepad.py b/moss_dimos/gamepad.pynew file mode 100644index 0000000..9e4a211--- /dev/null+++ b/moss_dimos/gamepad.py@@ -0,0 +1,486 @@+"""Gamepad teleop for MOSS - derived from vector-dimos/gamepad.py (Apache-2.0).++MOSS is a differential-drive tracked rover: the strafe axis (vy) published here is+ignored downstream by moss_dimos.diffdrive. Everything else (deadman, brake window,+hot-plug, headless SDL) is the VECTOR behaviour, unchanged and cold-tested there.+Not yet run on MOSS hardware.+"""+from __future__ import annotations++from dataclasses import dataclass+import os+import threading+import time+from typing import Any++# SDL picks its drivers at import time, so this has to run before "import+# pygame" (which happens lazily in the worker thread below). setdefault, not+# assignment: an operator who exports SDL_VIDEODRIVER=x11 keeps their display.+os.environ.setdefault("SDL_VIDEODRIVER", "dummy")+os.environ.setdefault("SDL_AUDIODRIVER", "dummy")+os.environ.setdefault("PYGAME_HIDE_SUPPORT_PROMPT", "1") # no banner in daemon logs++from dimos.core.core import rpc+from dimos.core.module import Module+from dimos.core.stream import Out+from dimos.msgs.geometry_msgs.Twist import Twist+from dimos.msgs.geometry_msgs.Vector3 import Vector3+from dimos.utils.logging_config import setup_logger++logger = setup_logger()++DEFAULT_LINEAR_SPEED = 0.6 # m/s at full stick+DEFAULT_ANGULAR_SPEED = 1.2 # rad/s at full stick+DEFAULT_DEADZONE = 0.32+DEFAULT_RATE_HZ = 50.0+DEFAULT_BOOST = 2.0+RESCAN_PERIOD_S = 2.0 # how often we re-scan SDL for a pad++# SDL axis indices on a standard dual-stick pad (DS4/DS5, Xbox, 8BitDo).+AXIS_LEFT_X = 0+AXIS_LEFT_Y = 1+AXIS_RIGHT_X = 2 # MEASURED 27/08 15h21: right-stick X sweeps axis 2 full travel on this pad/mode (axis 3 is its vertical leakage - the random rotation)+AXIS_R2 = 5+++@dataclass(frozen=True)+class TeleopConfig:+ """Speed envelope for :func:`axes_to_twist` - no pygame, no module."""++ linear_speed: float = DEFAULT_LINEAR_SPEED+ angular_speed: float = DEFAULT_ANGULAR_SPEED+ deadzone: float = DEFAULT_DEADZONE+ boost_multiplier: float = DEFAULT_BOOST+++def apply_deadzone(value: float, deadzone: float) -> float:+ """Hard deadzone: below the threshold the axis reads zero.++ No rescaling of the remaining travel - a stick just past the deadzone+ gives a small command, which is what you want for fine positioning.+ """+ return 0.0 if abs(value) < deadzone else value+++# Absolute ceilings, applied LAST, regardless of config or boost. Born of the+# 27/08 13h42 runaway: a fresh xboxdrv delivered full-deflection uninitialised+# axes straight into tele_cmd_vel (priority channel, no guard anywhere) and+# the rover left at 1200 W. No teleop output may ever exceed these.+CLAMP_LINEAR_MS = 0.45+SLEW_LINEAR_MS2 = 0.6 # max change of linear command per second: full stick+ # reaches the ceiling in ~0.75 s instead of one step -+ # the mecanum wheelspin fix, on top of the 400 ms ZLAC+ # ramps the adapter writes (the era tuning)+CLAMP_ANGULAR_RADS = 0.8+# Mecanum wheels ADD the commands: rim speed = |vx| + |vy| + (Lx+Ly)|wz|.+# Felt on the very first piloted lap (2026-08-27): mixing stick and rotation+# made the rover suddenly take off - each axis was under its own clamp while the+# wheels ran near double. Envelope = the fastest single-stick feel (0.45).+MECANUM_LEVER_M = 0.50 # Lx+Ly: half wheelbase 0.27 + half track 0.23 (54x46 cm chassis)+WHEEL_ENVELOPE_MS = 0.45 # max rim speed however the sticks are mixed+DEADMAN_BUTTON = 7 # MEASURED 2026-08-27: the chosen deadman button was pressed 21x -> index 7 (shanwan pad, Android mode). 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,+ # zeros included, as "a human is driving": it cancels the+ # nav goal and mutes nav_cmd_vel for tele_cooldown_sec+ # (1.0 s). A pad at rest publishing 50 Hz of zeros+ # therefore killed exploration for good (28/08 audit).+ # 0.5 s < 1.0 s: the brake is seen, then autonomy gets+ # the bus back and the two coexist.+# NOTE (2026-08-27): when this pad's radio dies mid-drive (sleep, battery -+# observed on a piloted lap), the rover STOPS cleanly - observed behaviour, no+# radio watchdog needed. Revisit ONLY if a radio death ever leaves a non-zero+# command running.+++# ── 2026-09-13: metrox's two complaints from the 30/08 piloted lap ──────────+# (docs/notes_etabli.md, his words) :+# "transitions de commandes pas propres : relacher un stick puis le remettre+# vite -> lag / collision de commandes"+# "inertie teleop excessive : stick lache -> le rover glisse encore ~1,5 m"+# One constant per button. Restoring the 2026-09-12 flight is one line each:+# BRAKE_CANCEL_ON_DEADMAN = False, and brake_s left alone (0.5 s).++BRAKE_CANCEL_ON_DEADMAN = True+# A new deadman press CANCELS whatever is left of the brake window, on its+# RISING EDGE (brake_until = 0.0). From that instant the brake path cannot emit+# one more zero, however long the window was.+#+# MEASURED on the cold bench 2026-09-13, BEFORE this change, at 50 Hz with+# BRAKE_S = 0.5 s and the deadman re-pressed 0.200 s after the release: the+# module already published the stick command from the first tick after the+# press (+0.213 s -> 0.012 m/s, one slew step) and no zero after it. So this+# does NOT change the default flight, and it is NOT the cure for the felt lag+# (that one is the slew restarting from rest: 0.6 m/s2 = 0.75 s to the ceiling).+# What it buys is the right to LENGTHEN the zero window (brake_s below) without+# a stale zero from the release ever chasing a fresh command down the bus -+# which is precisely what the anti-inertia button wants to do.+# False = the 12/09 behaviour exactly: the window always runs to its end.++# The length of that window is now a knob, not a literal. 0.5 s is the value+# flown since 28/08 (see BRAKE_S); the anti-inertia trial raises it towards+# 1.0 s so the drives keep being TOLD to stop for longer instead of falling+# silent and free-wheeling. dimOS builds this module from a blueprint with no+# arguments of ours, so the environment is the operator's only lever:+# VECTOR_BRAKE_S=1.0 tools/fly.sh GAMEPAD=1 REPOSITIONNE=1+BRAKE_S_ENV = "VECTOR_BRAKE_S"+BRAKE_S_MAX = 1.0+# Why the ceiling is 1.0 and not more - the cost, in seconds, not a story.+# dimOS's MovementManager treats ANY tele_cmd_vel message, zeros included, as+# "a human is driving": _on_teleop cancels the nav goal on EVERY message and+# _on_nav refuses to forward nav_cmd_vel until tele_cooldown_sec = 1.0 s has+# passed since the LAST teleop message (movement_manager.py, re-read+# 2026-09-13). So every release mutes autonomy for brake_s + 1.0 s: 1.5 s+# today, 2.0 s at this ceiling. That number IS the justification.+# TWO CLAIMS THAT USED TO STAND HERE AND WERE FALSE (adversarial review,+# 2026-09-13) - written down so nobody rebuilds on them:+# 1. "above the ceiling a pad at rest would mute exploration FOR GOOD". No:+# whatever brake_s is, the zeros STOP at brake_s (see the worker loop) and+# autonomy comes back 1.0 s later. "For good" was the pre-28/08 module,+# which published 50 Hz of zeros for ever. The ceiling is prudence about+# the 2 s above, not a cliff.+# 2. "in the GAMEPAD=1 blueprint the gamepad IS the commander (direct drive+# to cmd_vel, no nav), so the cost there is zero". That describes+# `vector-dimos.gamepad` (blueprints.py remaps tele_cmd_vel -> cmd_vel).+# tools/fly.sh runs `vector-dimos.explore`, where GAMEPAD=1 only ADDS this+# module with NO remapping (nav_blueprints.py): the pad publishes on+# tele_cmd_vel and MovementManager IS in the path. The cost on the flight+# metrox actually runs is 2.0 s, not zero.++BRAKE_UNTIL_STOPPED = False+# ASKED FOR on 2026-09-13, and NOT implemented on purpose - here is why, so+# nobody re-opens it blind. The idea: keep publishing zeros until the wheels+# actually read below BRAKE_STOP_RPM, capped at BRAKE_STOP_MAX_S, then silence.+# It needs wheel-speed feedback INSIDE this module, and this module has none:+# GamepadTeleop declares exactly one stream, `tele_cmd_vel: Out[Twist]`, and it+# runs in its own forkserver worker. The RPM feedback is read by+# VectorBaseAdapter (adapter.read_velocities) in the COORDINATOR's process,+# and nothing publishes it anywhere this module could subscribe to. Wiring it+# would mean: a new Out on the coordinator, a new In here, a blueprint+# remapping, and a new failure mode (feedback stops arriving -> the brake never+# ends -> the pad mutes autonomy for ever) - i.e. new machinery inside an armed+# chain, which is the one thing the 27/08 incident says not to do.+# THE FALLBACK IS brake_s ABOVE: a longer window of zeros, no new plumbing, one+# environment variable. Setting this flag True changes nothing but a warning.+BRAKE_STOP_RPM = 5.0 # kept as the spec of the day we do wire feedback+BRAKE_STOP_MAX_S = 2.0 # ...and its safety cap, so silence always comes+++def resolve_brake_s(brake_s: float | None = None,+ env: dict | None = None) -> float:+ """How long zeros keep flowing after the deadman is released, in seconds.++ Pure, cold-testable. Precedence: explicit argument > VECTOR_BRAKE_S >+ BRAKE_S (0.5 s, the 28/08 value). Out-of-range values are CLAMPED to+ [0.0, BRAKE_S_MAX] and logged; unparseable text falls back to BRAKE_S,+ loudly - a mistyped knob gives yesterday's flight, never a random one.+ """+ raw: float | None = None if brake_s is None else float(brake_s)+ if raw is None:+ text = (os.environ if env is None else env).get(BRAKE_S_ENV, "")+ text = text.strip() if isinstance(text, str) else ""+ if text:+ try:+ raw = float(text)+ except ValueError:+ logger.warning("%s=%r is not a number - brake window stays at "+ "%.2f s", BRAKE_S_ENV, text, BRAKE_S)+ raw = None+ if raw is None:+ return BRAKE_S+ value = max(0.0, min(BRAKE_S_MAX, raw))+ if value != raw:+ logger.warning("brake window %.2f s is outside [0.0, %.2f] s - clamped "+ "to %.2f s (above the ceiling a released pad mutes "+ "dimOS autonomy for good; see BRAKE_S_MAX)",+ raw, BRAKE_S_MAX, value)+ return value+++def brake_window_after_press(brake_until: float, deadman: bool,+ prev_deadman: bool) -> float:+ """The brake deadline this tick keeps - pure, cold-testable.++ RISING edge of the deadman (released -> held) cancels the window by+ returning 0.0, which is always in the past: the brake path can no longer+ publish. Anything else returns the window untouched - in particular a+ deadman simply HELD, because every driving tick re-arms the window itself+ and that one must live its full brake_s after the next release.++ With BRAKE_CANCEL_ON_DEADMAN = False this is the identity function, i.e.+ exactly the 2026-09-12 flight.+ """+ if BRAKE_CANCEL_ON_DEADMAN and deadman and not prev_deadman:+ return 0.0+ return brake_until+++def slew(prev: float, target: float, dt: float) -> float:+ """Rate-limit a linear command - pure, cold-testable."""+ step = SLEW_LINEAR_MS2 * dt+ return max(prev - step, min(prev + step, target))+++def clamp_twist(vx: float, vy: float, wz: float) -> tuple[float, float, float]:+ """The last gate before the bus - pure, cold-testable. Per-axis clamps,+ then the mecanum wheel envelope: translation and rotation ADD at the rim,+ so a mixed command is scaled down proportionally (the feel is preserved,+ the top speed is not exceeded)."""+ lim = CLAMP_LINEAR_MS+ vx = max(-lim, min(lim, vx))+ vy = max(-lim, min(lim, vy))+ wz = max(-CLAMP_ANGULAR_RADS, min(CLAMP_ANGULAR_RADS, wz))+ rim = abs(vx) + abs(vy) + MECANUM_LEVER_M * abs(wz)+ if rim > WHEEL_ENVELOPE_MS:+ k = WHEEL_ENVELOPE_MS / rim+ vx, vy, wz = vx * k, vy * k, wz * k+ return (vx, vy, wz)+++def axes_neutral(ax0: float, ax1: float, ax3: float, deadzone: float) -> bool:+ """True when every drive axis rests inside the deadzone - the trust gate:+ a pad (or a userspace driver) must be SEEN at neutral once before a single+ non-zero command is believed. Uninitialised axes never pass this."""+ return abs(ax0) < deadzone and abs(ax1) < deadzone and abs(ax3) < deadzone+++def axes_to_twist(ax0: float, ax1: float, ax3: float, ax5: float,+ cfg: TeleopConfig) -> tuple[float, float, float]:+ """Raw SDL axis values -> (vx m/s, vy m/s, wz rad/s).++ Pure function - the whole mapping lives here so it is testable without a+ pad, a display, or pygame.++ SDL reports stick up and stick left as NEGATIVE, while the robot frame is+ x forward / y left / wz counter-clockwise, hence the three sign flips:+ ax0 left stick X -> vy (stick left = -1 -> strafe left, +y)+ ax1 left stick Y -> vx (stick up = -1 -> forward, +x)+ ax3 right stick X -> wz (stick right = +1 -> clockwise, -wz)+ ax5 R2 -> boost when > 0 (trigger rests at -1)++ Boost multiplies the linear axes only: rotation stays at its capped rate,+ because a spin fast enough to be useful is already fast enough to hurt.+ """+ boost = cfg.boost_multiplier if ax5 > 0.0 else 1.0+ vx = -apply_deadzone(ax1, cfg.deadzone) * cfg.linear_speed * boost+ vy = -apply_deadzone(ax0, cfg.deadzone) * cfg.linear_speed * boost+ wz = -apply_deadzone(ax3, cfg.deadzone) * cfg.angular_speed+ return clamp_twist(vx, vy, wz)+++class GamepadTeleop(Module):+ """pygame.joystick teleop. Outputs Twist on tele_cmd_vel."""++ dedicated_worker = True++ tele_cmd_vel: Out[Twist]++ def __init__(self, linear_speed: float = DEFAULT_LINEAR_SPEED,+ angular_speed: float = DEFAULT_ANGULAR_SPEED,+ deadzone: float = DEFAULT_DEADZONE,+ rate_hz: float = DEFAULT_RATE_HZ,+ boost_multiplier: float = DEFAULT_BOOST,+ joystick_index: int = 0, brake_s: float | None = None,+ **kwargs: Any) -> None:+ super().__init__(**kwargs)+ self.cfg = TeleopConfig(linear_speed=linear_speed,+ angular_speed=angular_speed,+ deadzone=deadzone,+ boost_multiplier=boost_multiplier)+ self.rate_hz = rate_hz+ self.joystick_index = joystick_index+ # 2026-09-13: None -> BRAKE_S (0.5 s), or VECTOR_BRAKE_S. Resolved HERE,+ # at construction, so the value is fixed and logged once for a flight -+ # not re-read per tick.+ self.brake_s = resolve_brake_s(brake_s)+ self._stop_event = threading.Event()+ self._thread: threading.Thread | None = None++ # @rpc is not decoration for its own sake: Module.start/stop carry it,+ # and an override that drops it falls out of the class's rpcs table.+ # dimOS then proxies the call by pickling the module across the worker+ # pipe, which dies on our threading.Event ('cannot pickle _thread.lock').+ @rpc+ def start(self) -> None:+ super().start()+ self._stop_event.clear()+ self._thread = threading.Thread(target=self._worker,+ name="vector-gamepad", daemon=True)+ self._thread.start()++ @rpc+ def stop(self) -> None:+ self._stop_event.set()+ if self._thread is not None:+ self._thread.join(timeout=2.0)+ super().stop()++ def _publish(self, vx: float, vy: float, wz: float) -> None:+ self.tele_cmd_vel.publish(Twist(+ linear=Vector3(x=vx, y=vy, z=0.0),+ angular=Vector3(x=0.0, y=0.0, z=wz)))++ def _acquire(self, pygame: Any) -> Any:+ """Re-scan SDL for the pad. Returns an initialised joystick or None."""+ try:+ pygame.event.pump() # let SDL process hotplug events+ pygame.joystick.quit() # full re-scan: SDL caches the device+ pygame.joystick.init() # list from the last init()+ if pygame.joystick.get_count() <= self.joystick_index:+ return None+ pad = pygame.joystick.Joystick(self.joystick_index)+ pad.init()+ return pad+ except pygame.error as exc:+ logger.debug("Gamepad scan failed: %s", exc)+ return None++ # Named _worker, NOT _loop: dimOS's Module keeps its asyncio event+ # loop in self._loop, which would shadow the method and make the+ # thread target the event loop object.+ def _worker(self) -> None:+ try:+ import pygame+ except ImportError:+ logger.error("pygame is not installed - gamepad teleop is off "+ "(pip install 'vector-dimos[gamepad]')")+ return++ pygame.init() # dummy video/audio drivers: works with no display+ pygame.joystick.init()+ period = 1.0 / self.rate_hz+ pad = None+ trusted = False # neutral-first trust gate (13h42 runaway)+ 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 (2026-09-13)+ waiting_logged = False+ if BRAKE_UNTIL_STOPPED:+ # Declared, never wired - see the constant. Say so at every start+ # rather than let an operator believe in a brake that is not there.+ logger.warning("BRAKE_UNTIL_STOPPED=True is INERT: this module has "+ "no wheel-speed feedback (see the constant). The "+ "brake window stays at %.2f s - raise it with %s.",+ self.brake_s, BRAKE_S_ENV)+ 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)+ try:+ while not self._stop_event.is_set():+ if pad is None:+ pad = self._acquire(pygame)+ if pad is None:+ if not waiting_logged:+ logger.info("waiting for gamepad (index %d)",+ self.joystick_index)+ waiting_logged = True+ self._stop_event.wait(RESCAN_PERIOD_S)+ continue+ waiting_logged = False+ trusted = False # every (re)connection re-earns trust at neutral+ logger.info("Gamepad connected: %s - waiting to see the sticks at NEUTRAL "+ "before trusting a single command", pad.get_name())+ try:+ 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 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+ # ... and it holds no RAMP either (2026-09-13, adversarial+ # bench). prev_vx/prev_vy were reset on the deadman RELEASE+ # path only, so a pad that vanished for one read while+ # driving at the ceiling came back with 0.45 m/s of slew+ # state: the first trusted tick, STICKS AT NEUTRAL, published+ # +0.438 m/s and the rover left on its own for ~0.75 s -+ # the exact 28/08 replay the release path was written to+ # kill. The trust gate does not catch it: neutral axes+ # satisfy the gate, and the danger is inside this module.+ prev_vx = prev_vy = 0.0+ self._publish(0.0, 0.0, 0.0) # one zero Twist, then wait+ logger.warning("Gamepad lost (%s) - back to waiting", exc)+ continue+ # TRUST GATE (the 13h42 runaway): until the sticks have been+ # SEEN at neutral once, this pad's words are worth nothing.+ 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)")+ else:+ if time.monotonic() < brake_until:+ self._publish(0.0, 0.0, 0.0)+ time.sleep(period)+ continue+ # BRAKE CANCEL (2026-09-13, metrox 30/08 "collision de+ # commandes"): the RISING edge of the deadman ends the brake+ # window there and then, so not one zero left over from the+ # release can still go out behind the commands of the new+ # press. Rising edge, not "held": a window re-armed by a tick+ # that DROVE (below) must keep its own life.+ # Set BRAKE_CANCEL_ON_DEADMAN = False to fly the 12/09 way.+ #+ # ORDER MATTERS, and it was WRONG for a few hours on 2026-09-13+ # (caught by an adversarial cold bench, fixed the same day):+ # these two lines used to sit ABOVE the trust gate. On any pad+ # that has not yet earned trust - i.e. after EVERY reconnection,+ # and after every one-tick read glitch, which is exactly when+ # the rover is rolling with nobody commanding it - a deadman+ # press cancelled the brake window while the untrusted path+ # could publish NOTHING to replace it. Measured on that bench:+ # a single missed read at 0.45 m/s took the zeros published+ # after the dropout from 25 (to 0.486 s) down 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, below the gate.+ brake_until = brake_window_after_press(brake_until, deadman,+ prev_deadman)+ prev_deadman = deadman+ # DEADMAN: no held button, no motion - ever.+ if not deadman:+ # 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 (28/08 audit: 0.44 m/s for+ # ~0.75 s, sticks at rest).+ prev_vx = prev_vy = 0.0+ # BRAKE THEN SILENCE (see BRAKE_S / self.brake_s): zeros for+ # brake_s after the last command, then not one message until+ # the deadman is held again - a released pad must not mute+ # autonomy.+ if time.monotonic() < brake_until:+ self._publish(0.0, 0.0, 0.0)+ time.sleep(period)+ continue+ vx, vy, wz = axes_to_twist(*axes, self.cfg)+ vx = slew(prev_vx, vx, period)+ vy = slew(prev_vy, vy, period)+ prev_vx, prev_vy = vx, vy+ # envelope AFTER the slew too: while vx decays and wz is+ # instant, the mix could transiently exceed the rim ceiling+ vx, vy, wz = clamp_twist(vx, vy, wz)+ self._publish(vx, vy, wz)+ brake_until = time.monotonic() + self.brake_s+ time.sleep(period)+ finally:+ try:+ self._publish(0.0, 0.0, 0.0)+ except Exception: # stream already torn down: nothing to do+ logger.debug("no zero Twist on shutdown", exc_info=True)+ pygame.joystick.quit()+ pygame.quit()+++def _axis(pad: Any, index: int) -> float:+ """Axis value, or 0.0 when this pad has no such axis.++ Pads differ (some report 4 axes, not 6). A missing R2 must read as "no+ boost", not throw the loop into the reconnect path on every tick.+ """+ if index >= pad.get_numaxes():+ return 0.0+ return float(pad.get_axis(index))diff --git a/pyproject.toml b/pyproject.tomlnew file mode 100644index 0000000..5f5aa75--- /dev/null+++ b/pyproject.toml@@ -0,0 +1,15 @@+[project]+name = "moss-dimos"+version = "0.0.1"+description = "MOSS litter-picking rover: dimOS modules (scaffold)"+readme = "README.md"+license = {text = "Apache-2.0"}+requires-python = ">=3.10"+dependencies = ["numpy"]++[project.optional-dependencies]+gamepad = ["pygame>=2.6"]+test = ["pytest"]++[tool.setuptools]+packages = ["moss_dimos"]diff --git a/scripts/git-pre-push-prive.sh b/scripts/git-pre-push-prive.shnew file mode 100755index 0000000..a6824ca--- /dev/null+++ b/scripts/git-pre-push-prive.sh@@ -0,0 +1,33 @@+#!/usr/bin/env bash+# git-pre-push-prive.sh — LE VERROU « privé = local uniquement » (metrox 04/09/2026 13h28 :+# « il faut blinder ça pour que ça n'arrive plus, les trucs privés ça devrait être en local uniquement »).+# Installé comme .git/hooks/pre-push dans les dépôts qui portent du privé. Il refuse TOUT push, sauf+# ALLOW_PUSH=1 explicite ET aucun fichier de la liste privée dans la plage poussée.+# Né du palais poussé sur GitHub par la boucle RSI (20-27/05/2026, découvert le 02/09).+set -u+REPO="$(git rev-parse --show-toplevel)"+case "$REPO" in+ */memory) echo "✗ pre-push : le PALAIS ne se pousse JAMAIS, nulle part (règle absolue)." >&2; exit 1;;+esac+PRIVE_RE='^(CURRENT\.md|TODO\.md|PRIVE.*|prive/|_perime/CURRENT_|_perime/ORDRES_|docs/charte_magicien|docs/love_first|docs/dossier_showrobotics|docs/astra_|docs/vita_camping|docs/discord_recon|docs/dossier_pitch|docs/journal|docs/reves|docs/reveils|docs/.*prive|.*secrets\.env|.*\.env$|infra/wg0)'+if [ "${ALLOW_PUSH:-0}" != "1" ]; then+ echo "✗ pre-push refusé : ce dépôt porte du privé (CURRENT, TODO, journaux, recon). Un push demande" >&2+ echo " ALLOW_PUSH=1 explicite ET une plage sans fichier privé. Le hors-site du privé = backup chiffré, pas GitHub." >&2+ exit 1+fi+# plage poussée : lit stdin (local_ref local_sha remote_ref remote_sha)+Z=0000000000000000000000000000000000000000+while read -r lref lsha rref rsha; do+ [ "$lsha" = "$Z" ] && continue+ if [ "$rsha" = "$Z" ]; then+ # branche neuve chez le distant : TOUT l'arbre part -> on regarde tout l'arbre+ hits=$(git ls-tree -r --name-only "$lsha" 2>/dev/null | grep -E "$PRIVE_RE" | head -5)+ else+ hits=$(git diff --name-only "$rsha..$lsha" 2>/dev/null | grep -E "$PRIVE_RE" | head -5)+ fi+ if [ -n "$hits" ]; then+ echo "✗ pre-push refusé : la plage $rref contient du privé :" >&2; echo "$hits" | sed 's/^/ /' >&2; exit 1+ fi+done+echo "pre-push : ALLOW_PUSH=1, aucun fichier privé dans la plage - push autorisé" >&2+exit 0diff --git a/tests/test_diffdrive_cold.py b/tests/test_diffdrive_cold.pynew file mode 100644index 0000000..6210443--- /dev/null+++ b/tests/test_diffdrive_cold.py@@ -0,0 +1,32 @@+"""Cold tests: known inputs -> known outputs, in physical units."""+import math++from moss_dimos.diffdrive import DiffDriveConfig, tracks_to_twist, twist_to_tracks++CFG = DiffDriveConfig(track_width_m=0.30, max_track_speed_mps=0.6)+++def test_straight_ahead_both_tracks_equal():+ assert twist_to_tracks(0.4, 0.0, CFG) == (0.4, 0.4)+++def test_spin_in_place_opposite_tracks():+ left, right = twist_to_tracks(0.0, 2.0, CFG) # 2 rad/s, half width 0.15 -> 0.3 m/s+ assert math.isclose(left, -0.3) and math.isclose(right, 0.3)+++def test_roundtrip_73_percent_of_a_turn():+ vx, wz = 0.25, 0.73+ left, right = twist_to_tracks(vx, wz, CFG)+ back_vx, back_wz = tracks_to_twist(left, right, CFG)+ assert math.isclose(back_vx, vx) and math.isclose(back_wz, wz)+++def test_over_limit_is_scaled_not_clipped_keeps_ratio():+ left, right = twist_to_tracks(1.0, 2.0, CFG) # raw: 0.7 / 1.3 -> peak 1.3 > 0.6+ assert math.isclose(max(abs(left), abs(right)), 0.6)+ assert math.isclose(right / left, 1.3 / 0.7)+++def test_strafe_is_ignored():+ assert twist_to_tracks(0.2, 0.0, CFG, vy=0.9) == twist_to_tracks(0.2, 0.0, CFG)diff --git a/tests/test_gamepad_import_cold.py b/tests/test_gamepad_import_cold.pynew file mode 100644index 0000000..2b3cce8--- /dev/null+++ b/tests/test_gamepad_import_cold.py@@ -0,0 +1,12 @@+"""The derived gamepad module must at least import and expose its pure helpers (no pad, no dimOS run)."""+import importlib++import pytest+++def test_gamepad_module_imports_or_skips_without_dimos():+ try:+ mod = importlib.import_module("moss_dimos.gamepad")+ except ModuleNotFoundError as e: # dimos / pygame absent on a cold box+ pytest.skip(f"optional dependency missing: {e.name}")+ assert hasattr(mod, "axes_to_twist")