Lesson 3 of 9 ยท about 20 minutes
The robot ramps: it speeds up gently and slows down quicker. And it stops by itself if the remote goes quiet.
About thirty times a second, the robot moves its speed a small step toward the speed you asked for.
dt is the time since the last step.
ACCEL = 30 # cm/s per second: how gently it speeds up
DECEL = 60 # cm/s per second: how quickly it slows down
linear = ramp(linear, want_linear, ACCEL * dt, DECEL * dt)
Dotted: what the stick asks for. Solid: what the robot does.
While you hold the stick, the page repeats its packet. If the robot hears nothing for 600 ms, it stops:
if stick != (0, 0) and ticks_diff(now, stick_at) > STICK_TIMEOUT_MS:
stick = (0, 0) # the page stopped talking: don't keep driving
In Arduino Lab for MicroPython, open remote_control.py on the robot, change
ACCEL = 30 to ACCEL = 8, save, and restart the robot. The update page
puts the original back; to keep changes, see lesson 9.