PDF

Make a Wobbly Pet Robot with LEGO SPIKE Prime (Age 15)

Goal: design, build and program a small "wobbly" pet (inspired by wobbledogs.com) using the LEGO Education SPIKE Prime set. The robot should move with a cute, oscillating (wobble) gait, react a little to sensors (e.g., move when someone is near or wag a tail), and be stable enough to not fall over.

Overview — step by step

  1. Plan the mechanics: body, legs, joints, center of gravity.
  2. Choose parts (SPIKE Prime elements + any extra Technic parts you have).
  3. Build a simple frame that holds the Hub and motors securely.
  4. Design compliant (springy) leg joints or use controlled motor-driven legs for wobble.
  5. Program a wobble motion (mathematical sinusoidal motion or short motor swings) in Python or Scratch.
  6. Test and tune amplitude, frequency and balance. Add sensors for interaction.

Parts list (from SPIKE Prime set)

  • 1x SPIKE Prime Hub (brain)
  • 1–2x Large Motors — use for leg movement (or one motor per side)
  • 1x Medium Motor — for tail wag or head tilt
  • 1x Color/Distance sensor — for "eyes" or proximity trigger
  • Technic beams, liftarms, axle pins, connectors — to make body, legs and joints
  • Rubber bands or flex axles (optional) — to give springy compliance to joints

Mechanical design tips

  • Make a low, wide body so the center of gravity is low — this helps stability during wobble.
  • Use 2 motors for left/right leg actuation if you want controlled walking, or use one motor that drives an off-center cam to create a wobble in all legs.
  • For a cute wobble, you can either:
    • Active wobble: motors move legs through small angular oscillations (precise but uses motor control).
    • Passive wobble: legs are on springy joints (rubber band or flexible connector) and a motor gently nudges the body -> legs wobble naturally.
  • Feet: use slightly larger contact areas (plates) so the robot doesn't dig into the surface and slide unpredictably.
  • Test the build by gently pushing it — observe whether it returns or tips. Adjust width and weight distribution.

Programming ideas — how to make a wobble

There are two simple approaches to program a wobble motion:

1) Sinusoidal (smooth) position control — conceptual

Make the leg motor follow an angle that changes with time like: angle(t) = center + amplitude * sin(2π * frequency * t). This creates a smooth back-and-forth wobble.

2) Simple two-step swing (easier)

Alternate the motor between +amp and -amp every short interval (e.g., 0.25–0.5 s). This is easier to implement and often looks playful.

Example MicroPython (conceptual) for SPIKE Prime

Below is a clear, commented example that implements a sinusoidal wobble using one large motor attached to a leg joint and a medium motor to wag a tail. Exact motor method names can differ by SPIKE firmware version — check your SPIKE API docs. Treat this as a correct algorithm; adapt run/start methods to your environment if needed.

from spike import PrimeHub, Motor, MotorPair, ColorSensor
import math, time

hub = PrimeHub()
leg_motor = Motor('A')      # large motor driving leg/cam
tail_motor = Motor('B')     # medium motor for tail wag
eye = ColorSensor('C')      # used as a proximity/trigger sensor (or distance if available)

# Parameters you can tune
amplitude_deg = 25        # degrees, how much each swing rotates (try 15-40)
frequency_hz = 0.7        # wobble cycles per second (try 0.5-1.5)
sample_dt = 0.04         # seconds between updates

start_time = time.time()

try:
    while True:
        t = time.time() - start_time
        # Smooth sinusoidal angle
        angle = amplitude_deg * math.sin(2 * math.pi * frequency_hz * t)

        # Command the motor to go to this approximate angle.
        # Depending on your SPIKE API you may use run_for_degrees(delta, speed) or run_to_position(angle)
        # Option A (if API supports absolute positions):
        # leg_motor.run_to_position(angle, speed=30)

        # Option B (approximate delta using current position):
        current = leg_motor.get_position()      # if available
        delta = angle - current
        leg_motor.run_for_degrees(delta, speed=30)

        # Tail wag synced to wobble (fast small wag)
        tail_angle = 20 * math.sin(4 * math.pi * frequency_hz * t)  # faster frequency for tail
        # set using similar commands
        # tail_motor.run_to_position(tail_angle, speed=40)

        # Simple sensor interaction: if something is near (color sensor reading changes), increase wobble
        if eye.get_reflected_light() < 30:   # heuristics — adjust to your lighting
            amplitude_deg = 40
            frequency_hz = 1.0
        else:
            amplitude_deg = 25
            frequency_hz = 0.7

        time.sleep(sample_dt)

except KeyboardInterrupt:
    # stop motors neatly
    leg_motor.stop()
    tail_motor.stop()

Notes on the code:

  • Replace run_to_position / run_for_degrees / get_position calls with the actual functions from your SPIKE Prime Python API version. If get_position isn't available, you can keep a software-approximate position variable and integrate motor commands.
  • Start with small amplitude and low frequency and increase until it looks cute but stable.

Tuning tips and troubleshooting

  • If it tips forward or sideways: widen the base, lower the motor/HUB, add weight to the bottom (a heavy beam or battery pack location).
  • If wobble is weak: increase amplitude or add a cam that converts small motor rotation into larger leg displacement (mechanical advantage).
  • If motors stall: reduce torque by lowering amplitude or use a slower speed setting. Check for friction in joints — add bushings or remove unnecessary friction points.
  • If you want smoother motion but your API doesn’t support absolute position control: run short degree steps frequently (small delta moves) to approximate a continuous path.

Ideas to extend

  • Make the pet respond to a person approaching (distance sensor) by increasing excitement: larger amplitude and faster tail wag.
  • Use the Hub’s IMU to detect taps or shakes and make the pet react (jump or spin).
  • Create personality modes: sleepy (slow, tiny wobble), playful (fast, big wobble), shy (stay still until sensed).
  • Attach small decorations or printable faces to customize appearance (inspired by wobbledogs.com).

Final notes

Start simple: make a stable chassis and a single oscillating joint. Get the motion working in code, then improve the mechanics and add sensors. Keep experimenting with amplitude, frequency and the physical joints — the combination of soft mechanics and simple control often makes the cutest, most lifelike wobbles.

Want me to sketch a specific motor wiring diagram or give a step-by-step parts layout for a particular SPIKE Prime build you already made? Tell me which motor ports you used and a photo or description of your current build and I’ll provide exact motor code and tweaks.


Ask a followup question

Loading...