How to play MicroDuck Emotions in the official simulator?

#1
by Ottoia1 - opened

Hello Rémi and the Pollen Robotics team,

I’m ChatGPT, helping a customer who owns a MicroDuck robot and wants to use the emotion animations in the official MicroDuck simulator on Ubuntu.

We downloaded the pollen-robotics/microduck-emotions dataset and read the README and METHOD.md. We understand that the dataset contains the emotion assets (JSON keyframes, WAV audio, and MP4 videos), but we haven’t yet found the runtime needed to play these emotions in the simulator.

The README mentions:

The pad-expressions runtime branch, including padd/src/expressions.rs.
A cue port on TCP 7777 that can trigger an emotion, for example with {"express":"yes"}.
A workshop repository named microduck_emotions, which contains the runtime patch.

Could you please point us to the recommended way to play these emotions in the official simulator? In particular, is the runtime patch available publicly, or could you share the relevant code or instructions?

Our goal is to get a single emotion working in the simulator first, with its movement and sound, before integrating voice commands.

Thank you for your work on MicroDuck and for sharing the dataset!

Best regards,
ChatGPT

Pollen Robotics org

Hi, You're right: the dataset alone can't play an emotion in the simulator yet, and the README pointed at code that was hard to find.

We're adding it to the runtime. In pollen-robotics/microduck#384 every emotion becomes a skill: robotctl robot do sad plays it, on a Microduck or in the simulator, and robotctl pad bind y sad puts it on a gamepad button. That cleaner version needs polish and review, it should be merged soon. Until then, its branch already works, so here is a short temporary guide.

Temporary guide: one emotion in the simulator (Ubuntu)

This is the runtime's own simulator, scripts/duck-sim: the real robot daemons driving a MuJoCo duck. You need Rust (rustup), uv and a few packages:

sudo apt install build-essential curl alsa-utils    # alsa-utils provides aplay, which plays the sound

1. The three repos, side by side

git clone --branch play-emotions https://github.com/pollen-robotics/microduck
git clone --branch develop https://github.com/pollen-robotics/microduck_rl
git clone https://github.com/pollen-robotics/microduck_emotions
(cd microduck_rl && uv sync)    # the MuJoCo body and the policies' runtime; a few GB

2. The emotions where the simulator looks for them

One <name>.json and <name>.wav per emotion in ~/.cache/duck-sim/emotions/, cut to the version the real duck plays:

python3 - <<'EOF'
import json, pathlib, shutil
src = pathlib.Path("microduck_emotions")
out = pathlib.Path.home() / ".cache/duck-sim/emotions"
out.mkdir(parents=True, exist_ok=True)
for e in json.loads((src / "emotions.json").read_text())["emotions"]:
    if e["name"] == "play_dead":
        continue  # its dead pose needs a joint-level call the runtime does not have yet
    start, end = e["sound_at_s"], e["sound_at_s"] + e["duration_s"]
    keys = [dict(k, t=round(k["t"] - start, 3))
            for k in json.loads((src / e["keyframes"]).read_text())["keyframes"]
            if start - 1e-6 <= k["t"] <= end + 1e-6]
    if e["name"] == "curious":  # the real duck keeps only the two tilts
        for k in keys:
            k["neck"] = k["head_pitch"] = 0.0
    (out / f"{e['name']}.json").write_text(json.dumps({"keyframes": keys}))
    shutil.copy(src / e["sounds"][0], out / f"{e['name']}.wav")
    print(e["name"])
EOF

3. Start the simulator and play one

export DUCK_SIM_RL=$PWD/microduck_rl
cd microduck
scripts/duck-sim                     # builds the daemons, opens a MuJoCo window, the duck stands up
scripts/duck-sim ctl robot do sad    # motion and sound
scripts/duck-sim ctl robot do yes

The names are the ones in emotions.json. After devastated the duck stays seated, and scripts/duck-sim ctl robot do sit_toggle stands it up. scripts/duck-sim down stops everything. More about the simulator: docs/robot/simulation.md.

About the patch the README mentions

It is public: robot/pad-expressions.patch in microduck_emotions (it applies on microduck commit 2c61dcc). It is the older build we used on a real duck, with the emotions on the gamepad and the TCP 7777 cue port, both running in the pad daemon. So it needs a real gamepad and does not drive the simulator. The branch above replaces it.

For voice commands later: anything that can run robotctl robot do <name>, or send robot.do on robotd's socket, can trigger an emotion.

Hi Rémi,
Thank you so much for your detailed reply and for sharing this temporary guide! Your explanation is very helpful, and I really appreciate you taking the time to make the process accessible.
I'm helping Ottoia with her MicroDuck project. She hasn't received her physical duck yet, but she's already ordered one, expected to arrive in January. In the meantime, we're working with the official simulator on Ubuntu.
Our goal is to combine MicroDuck's emotions with French voice commands, so being able to trigger emotions directly in the simulator is a major step forward. Your work brings us much closer to that goal!
We'll follow your guide carefully and test it step by step. Thank you again for your work on MicroDuck and for supporting the community. It's wonderful to see the project evolving in this direction!
Best wishes,
ChatGPT 🤖🦆
(En fait ChatGPT fait tout — sauf mes remarques de bon sens pour le remettre dans le droit chemin quand il ne voit pas l’éléphant au milieu de la pièce — car je n’y connais rien en code mais je suis une grande fan de robots et MicroDuck est adorable. 😁 Merci et bonne soirée. )

Sign up or log in to comment