By Kevin McAleer, 6 Minutes
Page last updated November 24, 2026

Your duck’s parts all work. Now we make them agree with each other. The policy was trained on a perfect simulated duck, with a level IMU and every joint exactly at zero. Your real duck is a little different, and this lesson measures those differences so the software can correct them.
The BNO055 calibrates itself as it moves. We help it along by moving the robot through lots of orientations, then save the result so it doesn’t have to start from scratch every time.
cd scripts/
python calibrate_imu.py
Slowly rotate the duck in every direction: tilt it forward and back, roll it side to side, turn it around and hold it still in a few positions. The script reports four calibration levels. Keep going until it shows [3,3,3,3] and Calibrated = True.
The script saves a file called imu_calib_data.pkl. Copy it into the runtime package folder, mini_bdx_runtime/mini_bdx_runtime/. From the scripts folder:
cp imu_calib_data.pkl ../mini_bdx_runtime/mini_bdx_runtime/
Your duck’s personal settings live in a JSON file in your home folder. Start from the example in the runtime repo. Go back up to the Open_Duck_Mini_Runtime folder (cd .. from scripts), then:
cp example_config.json ~/duck_config.json
Open it with nano ~/duck_config.json. It holds three kinds of setting:
| Setting | What it does |
|---|---|
| Expression feature flags | Turn the eye LEDs, projector, speaker, antennas and ears on or off. Switch off anything you didn’t fit |
imu_upside_down |
Tells the runtime how your IMU is mounted |
| Joint offsets | Small corrections for each joint, which you’ll find in step 3 |
The assembly guide prefers the IMU flipped along its X axis. If you mounted it that way, set imu_upside_down to match. If you mounted it the other way up, set it the other way. Check example_config.json and the runtime README for exactly how the setting is written.
This one setting matters a lot. With the wrong imu_upside_down setting, the gait oscillates badly. The policy thinks the body is tilting the wrong way, corrects for it, and makes things worse. If your duck ever wobbles wildly, check this first.
When you fitted the servo horns in lesson 4, they landed close to zero, but not exactly. The offsets fix that in software.
First, hang the robot so both feet are off the ground. A loop of string around the body, or a stand, both work. Then, from the Open_Duck_Mini_Runtime folder:
cd scripts/
python find_soft_offsets.py
The script unlocks one motor at a time. You move that joint by hand into the right position, and it locks it again and records the offset. Work through every joint.
| Check | Good |
|---|---|
| Chassis | Level, or the nose slightly up |
| Legs and feet, seen from the side | Symmetric, left matching right |
| Foot switches | On a flat table, both click at the same time |
| Head | Level, or slightly up |
The foot switch check is a great test. Lower the duck onto a flat table. If one foot clicks before the other, one leg is longer than the other, and you need to adjust its offsets.
Put the offsets the script finds into the joint offsets in ~/duck_config.json, if the script doesn’t write them for you. Check the runtime README for how your version handles it.
Now for a proud moment. From the runtime repo, run:
python turn_on.py
This puts the duck into its standing pose with torque on. All 14 servos hold their positions. Look at it from the front and the side. Does it stand straight? Does it look like the good pose in the table above? If not, go back to step 3 and adjust.
If turn_on.py isn’t where you are, check the runtime README for its location on the v2 branch.
~/duck_config.json.Problem: The IMU calibration never reaches [3,3,3,3]. Solution: Move more slowly, and include some still holds in different positions. Why: Each part of the sensor calibrates from a different kind of movement.
Problem: The duck leans to one side when standing.
Solution: Run find_soft_offsets.py again and check the legs are symmetric from the side.
Why: A small offset error in a hip or ankle shows up as a lean.
Problem: One foot switch clicks long before the other. Solution: Adjust the offsets of that leg until both click together. Why: The policy uses the foot switches to know when each foot is down, so they need to agree.
Quick quiz 1 of 3
What does the IMU calibration script need to show before you save the data?
Quick quiz 2 of 3
Your duck’s gait oscillates badly. What should you check first?
Quick quiz 3 of 3
How should the robot be set up while you run find_soft_offsets.py?
Comments