๐Ÿ“š Alvik lessons

Lesson 3 of 9 ยท about 20 minutes

๐Ÿš€ Smooth moves

The robot ramps: it speeds up gently and slows down quicker. And it stops by itself if the remote goes quiet.

๐Ÿงฐ You need

๐Ÿค– Open the remote ๐ŸŽฎ Pretend robot

โ–ถ๏ธ Do it

  1. Push the stick fully forward. Watch ๐Ÿ’จ climb to 8 cm/s without a jerk.
  2. Let go. It stops faster than it started.
  3. Press ๐Ÿš€ Turbo: top speed is now 13 cm/s.
  4. Nudge the stick a tiny bit. Nothing happens: that is the dead zone.

๐Ÿ” How it works

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)

Draw the ramp

Dotted: what the stick asks for. Solid: what the robot does.

If the remote goes quiet

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

๐Ÿงช Try this

โœ๏ธ Change it

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.