△ Robotics · unit conversion
Wheel speed from an encoder
Turn encoder ticks counted over a time window into rpm and metres per second.
- Level 2 · Builder
- 5 tests
- technically checked
Your task
A wheel encoder produces ticksPerRev pulses per revolution. Firmware counts pulses over a short window.
Write:
- rpm(ticks, ticksPerRev, intervalMs) → revolutions per minute = (ticks / ticksPerRev) / (intervalMs / 60000).
- wheelSpeed(rpmValue, diameterMm) → ground speed in m/s = rpm × π × diameter / 1000 / 60.
Hints (0 of 2 shown)
What gets checked
- rpm(20, 20, 1000) → 60
- rpm(150, 600, 100) → ≈ 150 (± 1e-9)
- wheelSpeed(60, 100) → ≈ 0.3141593 (± 0.000001)
Plus 2 hidden tests for edge cases. They run in the sandbox like the others; only the result is shown.
Tab indents · Esc then Tab leaves the editor · Ctrl/⌘ Enter runs · Ctrl/⌘ Shift Enter checks · Ctrl/⌘ / comments
Starting the sandbox…
Press Run to see what your program prints.
Your code runs only in this browser, inside an isolated sandbox with no network access, and stops after 3 s. Nothing you type is sent to Tactiverge; drafts and progress are saved in this browser only.