Configure the Robot and Sensors#

Start by exploring how Microduck’s joints move. Then configure the robot in robot.py and place it on flat ground with contact sensors.

How the Microduck Robot Moves#

The interactive diagram below shows Microduck in its nominal pose, with its 14 controlled joints labeled.

Open the CAD explorer in a separate window.

The Joint Names#

The policy controls 14 Dynamixel XL330 servos, small motors with built-in gears that drive each joint.

Group

Joint names, in action order

Motion

Left leg

left_hip_yaw, left_hip_roll, left_hip_pitch, left_knee, left_ankle

Turn the hip, move it sideways, swing the leg, bend the knee, and pitch the ankle

Neck and head

neck_pitch, head_pitch, head_yaw, head_roll

Nod the neck/head, turn the head, and tilt it sideways

Right leg

right_hip_yaw, right_hip_roll, right_hip_pitch, right_knee, right_ankle

Corresponding right-leg motions

Microduck’s geometry, joints, and physics properties come from a Universal Scene Description (USD) file. The joint order in Microduck’s USD file starts with the right leg. The policy’s servo order starts with the left leg. You’ll use MICRODUCK_JOINT_NAMES and preserve_order=True to make that mapping explicit. The walking asset has no mouth servo. In the optional exercise, you’ll use head_yaw to turn the robot’s head.

Follow an Action Through the Motor#

An action changes a joint’s target angle. The position controller compares that target with the measured angle, as described in Actions and Commands. The BAM motor model simulates the response to the controller, including friction, electrical limits, battery voltage, and delayed commands. Physics then determines the resulting motion and contact.

BamMotorCfg uses the m6 model with fitted parameters from the Rhoban BAM project. The Microduck asset configuration contains the values you’ll use in this lesson.

Where Did These Numbers Come From?

BAM’s identification workflow shows how to fit these parameters. Attach a known pendulum load, run prescribed motions, and record joint position, velocity, and control signals. The fitting routine adjusts model parameters so simulated trajectories match the recordings. Validate the fitted model against measurements not used for fitting. See Closing the Reality Gap for how system identification connects measured behavior to simulation.

The configuration models a 7.4 V nominal supply, a 6.5–8.2 V range, and a 3–6 physics-step command delay. At 0.005 seconds per physics step, that delay is 15–30 ms. The optional backlash variant adds passive hinges to model looseness in the gearbox. The core lessons use the regular walking asset.

Connect the Motor Model#

Open microduck/robot.py. Each action asks a servo to move to a target angle. The BAM model determines the torque the servo applies to reach it. Start by importing the fitted XL330 motor settings and enabling BAM in Newton.

Append to robot.py:

import isaaclab.sim as sim_utils
from isaaclab.assets import ArticulationCfg
from isaaclab.utils.assets import ISAACLAB_NUCLEUS_DIR
from isaaclab_newton.sim.schemas import NewtonArticulationCfg

from isaaclab_tutorial.tasks.velocity.config.microduck.bam import install
from isaaclab_tutorial.tasks.velocity.config.microduck.bam.bam_cfg import BamActuatorCfg
from isaaclab_tutorial.tasks.velocity.config.microduck.bam.xl330 import XL330_MOTOR_CFG

install()
How Does a Target Angle Reach the Servo?

Look in bam/xl330.py for the values fitted to the XL330 motors. You’ll use them to configure the servos in robot.py. bam/bam.py computes motor effort, and bam/integration.py connects it to Newton’s MJWarp solver. The velocity task’s mdp/actions.py and mdp/commands.py define the terms you’ll use in control.py.

These files are adapted for Isaac Lab 3 from the pinned Microduck example.

Build Your Robot Configuration#

In robot.py, assemble the walking robot using the fitted motor coefficients you imported from bam/xl330.py.

Set the Servo Order#

Add the 14 names from the joint table. Their position in this list determines which motor each action controls. For example, head_yaw is at index 7.

Append to robot.py:

MICRODUCK_JOINT_NAMES = [
    "left_hip_yaw",
    "left_hip_roll",
    "left_hip_pitch",
    "left_knee",
    "left_ankle",
    "neck_pitch",
    "head_pitch",
    "head_yaw",
    "head_roll",
    "right_hip_yaw",
    "right_hip_roll",
    "right_hip_pitch",
    "right_knee",
    "right_ankle",
]

Set the Standing Pose#

Read the nominal joint angles in radians. The signs follow each joint’s axis in the USD: matching left and right poses use opposite signs for several leg joints. The expression .*hip_yaw sets both hip-yaw joints to zero.

These values become the reference pose for position actions. Later, use_default_offset=True will add this pose to each action before applying the modeled encoder-bias correction.

Append to robot.py:

STANDING_JOINT_POS = {
    ".*hip_yaw": 0.0,
    "left_hip_roll": -0.0873,
    "right_hip_roll": 0.0873,
    "left_hip_pitch": -0.4579,
    "right_hip_pitch": 0.4579,
    "left_knee": -0.0049,
    "right_knee": 0.0049,
    "left_ankle": 0.4530,
    "right_ankle": -0.4530,
    "neck_pitch": 0.3491,
    "head_pitch": 0.3491,
    "head_yaw": 0.0,
    "head_roll": 0.0,
}

Configure the Servos#

One actuator group controls all 14 XL330 motors. joint_names_expr selects joints whose names do not start with passive_; gearbox-play hinges remain passive in the optional backlash asset. motor reuses the supplied fit’s electrical and friction coefficients. You set the controller gain, battery conditions, and command delay around that fit.

Append to robot.py:

SERVOS_CFG = BamActuatorCfg(
    joint_names_expr=["^(?!passive_).*"],
    motor=XL330_MOTOR_CFG,
    kp_fw=200.0,
    vin=7.4,
    vin_range=(6.5, 8.2),
    vin_drop_gain_range=(0.0, 0.2),
    vin_min=6.0,
    min_delay=3,
    max_delay=6,
)
Read the Servo Settings
  • Controller: kp_fw=200.0 sets the firmware position gain used by BAM.

  • Supply: vin sets the nominal voltage and vin_range sets the range of starting voltages. vin_drop_gain_range varies how much the voltage drops under load. vin_min sets how low it can go.

  • Timing: min_delay and max_delay set the command delay in physics steps. At the course’s 0.005-second step, 3–6 steps mean 15–30 ms.

Assemble the Articulation#

Combine the USD file, initial state, and actuators in ArticulationCfg. The initial root position is in meters, and joint_vel={".*": 0.0} starts every joint at rest. soft_joint_pos_limit_factor=0.9 defines the soft joint limits used by the learning task. Contact sensing and self-collision use the colliders enabled in the walking asset.

Append to robot.py:

MICRODUCK_CFG = ArticulationCfg(
    spawn=sim_utils.UsdFileCfg(
        usd_path=f"{ISAACLAB_NUCLEUS_DIR}/Robots/PollenRobotics/MicroDuck/microduck_walk.usd",
        activate_contact_sensors=True,
        articulation_props=NewtonArticulationCfg(self_collision_enabled=True),
    ),
    init_state=ArticulationCfg.InitialStateCfg(
        pos=(0.0, 0.0, 0.125),
        joint_pos=STANDING_JOINT_POS,
        joint_vel={".*": 0.0},
    ),
    soft_joint_pos_limit_factor=0.9,
    actuators={"servos": SERVOS_CFG},
)

Before encoder-bias correction, what target angle does a zero action request for left_ankle? What about head_yaw? Use the pose dictionary and the action-offset rule.

Check the Configuration#

From the repository root, run the three tests for policy joint order, the walking USD asset, and the servo model and command delay.

uv run pytest -q tests/test_microduck_robot.py

Look for 3 passed. If the joint-order test reports right_hip_yaw at index 0 where it expected left_hip_yaw, your list starts with the right leg, as the USD does. Use the policy action order in the joint table to correct MICRODUCK_JOINT_NAMES, then rerun the tests.

Put the Duck on a Flat Plane#

Put the Microduck on a flat ground and add a light so you can see it. Use contact sensors to tell when the feet or body touch the ground and how long each foot stays in the air. Add a second sensor to catch the feet bumping into each other.

Tip

Try building the scene yourself or open Our Solution below.

This uses the same scene-configuration pattern introduced in From Configuration to Runtime. Start with the imports and skeleton below. Replace each MISSING placeholder with its configuration, keeping the attribute names so later tasks can find them. If you leave any fields unfinished, the configuration check lists them when you create the scene.

Append to scene.py, then fill in the missing fields:

from dataclasses import MISSING

import isaaclab.sim as sim_utils
from isaaclab.assets import ArticulationCfg, AssetBaseCfg
from isaaclab.scene import InteractiveSceneCfg
from isaaclab.sensors import ContactSensorCfg
from isaaclab.sim.spawners.materials import RigidBodyMaterialBaseCfg
from isaaclab.terrains import TerrainImporterCfg
from isaaclab.utils.configclass import configclass

from isaaclab_tutorial.tasks.velocity.config.microduck.robot import MICRODUCK_CFG


@configclass
class DuckSceneCfg(InteractiveSceneCfg):
    terrain: TerrainImporterCfg      = MISSING  # Add a shared flat plane.
    robot: ArticulationCfg           = MISSING  # Place your Microduck in each environment
    contact_forces: ContactSensorCfg = MISSING  # Trunk/foot contact and foot air time.
    self_collision: ContactSensorCfg = MISSING  # Contact between the two feet.
    sky_light: AssetBaseCfg          = MISSING  # Illuminate the scene.

    def __post_init__(self):
        self.validate()  # Report unfinished fields before the scene is used.
Need a Hint?
  • Terrain: Use TerrainImporterCfg with terrain_type="plane", prim_path="/World/ground", and collision_group=-1 so the ground is shared across environments. Use RigidBodyMaterialBaseCfg for physics_material, with static and dynamic friction both set to 1.0, and set debug_vis=False.

  • Robot: Use MICRODUCK_CFG.replace(...) to set prim_path="{ENV_REGEX_NS}/Robot". This creates a robot path for each environment while retaining the configuration in robot.py.

  • Contacts: Configure both fields with ContactSensorCfg. For contact_forces, use history_length=3, track_air_time=True, and prim_path="{ENV_REGEX_NS}/Robot/Geometry/trunk_base(/.*/(ankle_left|ankle_right))?" to select the trunk and feet. For self_collision, use prim_path="{ENV_REGEX_NS}/Robot/Geometry/trunk_base/.*/ankle_left" and filter_prim_paths_expr=["{ENV_REGEX_NS}/Robot/Geometry/trunk_base/.*/ankle_right"] to select contact between the feet. These paths select USD bodies; the joint names used for actions select actuated degrees of freedom.

  • Light: Use AssetBaseCfg at prim_path="/World/skyLight" with a sim_utils.DomeLightCfg as its spawn configuration. Our solution uses intensity 750.0 and color (0.9, 0.9, 0.9).

Our Solution

Compare your work with the solution below. To use it, replace the skeleton in scene.py, keeping the license header and module description.

import isaaclab.sim as sim_utils
from isaaclab.assets import AssetBaseCfg
from isaaclab.scene import InteractiveSceneCfg
from isaaclab.sensors import ContactSensorCfg
from isaaclab.sim.spawners.materials import RigidBodyMaterialBaseCfg
from isaaclab.terrains import TerrainImporterCfg
from isaaclab.utils.configclass import configclass

from isaaclab_tutorial.tasks.velocity.config.microduck.robot import MICRODUCK_CFG


@configclass
class DuckSceneCfg(InteractiveSceneCfg):
    terrain = TerrainImporterCfg(
        prim_path="/World/ground",
        terrain_type="plane",
        collision_group=-1,
        physics_material=RigidBodyMaterialBaseCfg(static_friction=1.0, dynamic_friction=1.0),
        debug_vis=False,
    )
    robot = MICRODUCK_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot")
    contact_forces = ContactSensorCfg(
        prim_path="{ENV_REGEX_NS}/Robot/Geometry/trunk_base(/.*/(ankle_left|ankle_right))?",
        history_length=3,
        track_air_time=True,
    )
    self_collision = ContactSensorCfg(
        prim_path="{ENV_REGEX_NS}/Robot/Geometry/trunk_base/.*/ankle_left",
        filter_prim_paths_expr=["{ENV_REGEX_NS}/Robot/Geometry/trunk_base/.*/ankle_right"],
    )
    sky_light = AssetBaseCfg(
        prim_path="/World/skyLight",
        spawn=sim_utils.DomeLightCfg(intensity=750.0, color=(0.9, 0.9, 0.9)),
    )

Your completed scene defines the ground, robot, contact sensors, and lighting. The walking asset’s sole colliders let contact_forces measure ground contact and self_collision detect contact between the feet. Air time measures how long a foot has been off the ground.

Next, define how actions reach the motors. You’ll connect the scene to an environment in the next lesson, then see it in motion when you run simple agents.

Define Actions and Commands#

Define the action configuration in control.py. scale=1.0 makes each action a joint-angle offset in radians; use_default_offset=True adds it to the nominal pose. preserve_order=True keeps the servo order listed above. The position action also accounts for encoder bias, a modeled offset in the joint-angle reading. It uses the same offset as the observation model.

Append to control.py:

from isaaclab.utils.configclass import configclass

from isaaclab_tutorial.tasks.velocity.mdp.actions import BiasedJointPositionActionCfg
from isaaclab_tutorial.tasks.velocity.mdp.commands import MicroDuckVelocityCommandCfg, UniformPoseDeltaCommandCfg

from isaaclab_tutorial.tasks.velocity.config.microduck.robot import MICRODUCK_JOINT_NAMES


@configclass
class ActionsCfg:
    """Action specifications for the MDP."""

    joint_pos = BiasedJointPositionActionCfg(
        asset_name="robot", joint_names=MICRODUCK_JOINT_NAMES, preserve_order=True, scale=1.0, use_default_offset=True
    )

A command describes the requested behavior. Add the velocity, head, and body-pose commands to the same file. We’ll initially hold these requests at zero for the balance task, then enable the sampled ranges when we introduce walking.

Append to control.py:

@configclass
class CommandsCfg:
    """Command specifications for the MDP."""

    base_velocity = MicroDuckVelocityCommandCfg(
        asset_name="robot",
        resampling_time_range=(3.0, 8.0),
        rel_standing_envs=0.02,
        rel_forward_envs=0.2,
        rel_turn_in_place_envs=0.15,
        debug_vis=True,
        ranges=MicroDuckVelocityCommandCfg.Ranges(
            lin_vel_x=(-0.4, 0.4), lin_vel_y=(-0.3, 0.3), ang_vel_z=(-1.0, 1.0)
        ),
    )
    head_pose = UniformPoseDeltaCommandCfg(
        resampling_time_range=(2.0, 5.0), ranges=((-0.05, 0.05), (-0.05, 0.05), (-0.07, 0.07), (-0.015, 0.015))
    )
    # Retained in the deployed observation vector, although body-pose reward is disabled.
    body_pose = UniformPoseDeltaCommandCfg(
        resampling_time_range=(2.0, 5.0),
        ranges=((-0.005, 0.005), (-0.005, 0.005), (-0.005, 0.005), (-0.05, 0.05), (-0.05, 0.05), (-0.05, 0.05)),
    )

The three velocity values request forward speed, sideways speed, and yaw rate (turning speed). The four head values correspond to neck_pitch, head_pitch, head_yaw, and head_roll. Keeping all command fields preserves the supplied policy’s input layout throughout the course.

Separate Policy Inputs From Training Information#

The actor chooses actions from 61 inputs. During training, the critic uses 76 inputs to estimate future return. Select a signal below to trace where it goes, then select each network to see how its input count adds up.

Choose what reaches the actor explicitly in ObservationsCfg.PolicyCfg. For the underlying ideas, revisit States and Observations and Actor and Critic.

Check Your Understanding#

Why can the critic learn from privileged simulation data, such as foot-contact forces, even if the real Microduck cannot measure those values? Explain why the actor’s IMU-like inputs need different treatment if the robot has no IMU.

Compare Your Answer

The critic uses extra information to estimate future rewards during training. The deployed actor chooses actions without the critic, so those critic-only measurements can stay in simulation.

The actor still needs the angular-velocity and projected-gravity values it was trained to use. A robot without an IMU must supply suitable estimates from its available sensors, or you must redesign the actor’s observations and retrain and evaluate the policy for that hardware.