MOSS: a small, mostly 3D-printed litter-picking rover. Cleaner streets, one maker at a time.
Python
firmware v3: MAX_PERCENT 100 (Laurent 10/10, first drive on the floor: 25 % never moved the tracks), ramp defaults 10/5 ms per %, banner from the constants; host test follows
openclawb4e1d1b262e9
diff --git a/firmware/MOSS_QTPY_MDD3A/Control.h b/firmware/MOSS_QTPY_MDD3A/Control.hindex 0f798ff..b7f9e55 100644--- a/firmware/MOSS_QTPY_MDD3A/Control.h+++ b/firmware/MOSS_QTPY_MDD3A/Control.h@@ -2,23 +2,24 @@// MOSS V0.4 control logic - same protocol as the V0.3 bench firmware (arm /// drive L R / stop / status / zero / test), plus a configurable ramp:// ramp UP DOWN milliseconds per 1 % of PWM, rise and fall separately-// The V0.3 ramp was fixed at 10 ms per percent (0 -> 25 % in 0.25 s), too-// abrupt for a rover carrying an arm. Defaults below: 0 -> 70 % in 2.1 s,-// 70 -> 0 in 1.05 s, to be tuned on the floor with the arm mounted.-// MAX_PERCENT stays a compile-time commissioning limit: raising it is a-// decision taken after mechanical tests, not a serial command.+// Defaults below: 0 -> 100 % in 1.0 s, 100 -> 0 in 0.5 s (10/10: the first+// drive on the floor with the arm mounted, Laurent: "100 %", the 25 % bench+// limit and the 30 ms rise never got the tracks moving); tune with "ramp".+// MAX_PERCENT stays a compile-time limit, not a serial command: 100 since+// 10/10 (the commissioning 25 % was the bench on blocks, 05/10); the host+// side caps lower with MOSS_MAX_PCT when it wants to.#include <stdint.h>#include <stdlib.h>#include <string.h>#include <errno.h>namespace moss {-constexpr int MAX_PERCENT = 25; // Commissioning limit; raise only after mechanical tests.+constexpr int MAX_PERCENT = 100; // Full PWM = the motors' rated 12 V (bench 05/10 was 25 %, raised 10/10).constexpr uint32_t COMMAND_TIMEOUT_MS = 300;constexpr uint32_t ARM_TIMEOUT_MS = 10000;constexpr uint32_t TEST_MS = 1000;-constexpr uint32_t RAMP_RISE_MS_DEFAULT = 30; // ms per 1 % up (0 -> 70 % in 2.1 s)-constexpr uint32_t RAMP_FALL_MS_DEFAULT = 15; // ms per 1 % down (70 -> 0 % in 1.05 s)+constexpr uint32_t RAMP_RISE_MS_DEFAULT = 10; // ms per 1 % up (0 -> 100 % in 1.0 s)+constexpr uint32_t RAMP_FALL_MS_DEFAULT = 5; // ms per 1 % down (100 -> 0 % in 0.5 s)constexpr uint32_t RAMP_MS_MIN = 1, RAMP_MS_MAX = 500;constexpr uint32_t REVERSE_DWELL_MS = 100; // at zero before changing directiondiff --git a/firmware/MOSS_QTPY_MDD3A/MOSS_QTPY_MDD3A.ino b/firmware/MOSS_QTPY_MDD3A/MOSS_QTPY_MDD3A.inoindex 590b7d2..aabd26c 100644--- a/firmware/MOSS_QTPY_MDD3A/MOSS_QTPY_MDD3A.ino+++ b/firmware/MOSS_QTPY_MDD3A/MOSS_QTPY_MDD3A.ino@@ -26,7 +26,7 @@ constexpr bool INVERT_LEFT = false, INVERT_RIGHT = false;constexpr float SHUNT_OHMS = 0.0f; // voltage only (see V0.3 README)constexpr uint32_t PWM_HZ = 20000;constexpr int PWM_BITS = 10;-constexpr const char* FW = "qtpy-mdd3a-v2";+constexpr const char* FW = "qtpy-mdd3a-v3";moss::Control control;moss::Ramp rampL, rampR;@@ -169,7 +169,8 @@ void setup() {attachInterrupt(ENC_R_A, encoderRight, CHANGE); attachInterrupt(ENC_R_B, encoderRight, CHANGE);Wire1.begin(SDA1, SCL1, 100000); Wire1.setTimeOut(5);inaConfigured = initIna();- sendLine("MOSS V0.4 firmware qtpy-mdd3a-v1; USB CDC 115200; limit 25%; ramp 30/15 ms per %; type status");+ { char banner[160]; snprintf(banner, sizeof(banner), "MOSS V0.4 firmware %s; USB CDC 115200; limit %d%%; ramp %lu/%lu ms per %%; type status",+ FW, moss::MAX_PERCENT, (unsigned long)control.rampRiseMs, (unsigned long)control.rampFallMs); sendLine(banner); }}void loop() {uint32_t now = millis();diff --git a/firmware/tests/control_v04_test.cpp b/firmware/tests/control_v04_test.cppindex a207321..aa0560d 100644--- a/firmware/tests/control_v04_test.cpp+++ b/firmware/tests/control_v04_test.cpp@@ -23,7 +23,7 @@ int main() {assert(cmd(c,"arm",330)==OK);assert(cmd(c,"drive 1 1",340)==OK);assert(cmd(c,"arm",350)==BUSY && c.mode==OFF);- const char* invalid[]={"drive 26 0","drive -26 0","drive 1 2 extra","drive 1",+ const char* invalid[]={"drive 101 0","drive -101 0","drive 1 2 extra","drive 1","drive nan 1","drive 1e2 0","drive 99999999999999999999 0","go","stop x","drive 1 1 x y","ramp 0 10","ramp 501 10","ramp 10","ramp a b"};for(auto s: invalid) {