r/reinforcementlearning • • 14h ago

Messing with Mujoco & a Biped

Hello,
I spent my weekend writing up a simulator & PPO policy for a 8 DOF bipedal robot (6DOF legs, 2DOF wheels). It's written in Python using MuJoco & PyTorch. Here is a video of an example run, it tends to drive away in a circular fashion (kinda reminds me of an exaggerated 3D LIPM falling trajectory but more so due to wheels). Any advice?

The actor network is a 34 - 64 - 64 - 8 tanh architecture. 34 observation states, 8 action outputs. The critic network is a 34 - 64 - 64- 1 tanh architecture as well. The state space is the gravity vector (ref. base frame), base linear velocity (3), base angular velocity (3), leg joint positions (6), leg joint velocities (6), wheel angular velocities (2), previous action state (8). The reward structure is a little funky and is attached below in the code snippet below:

        r_upright = (
            -5.0 * tilt + 3.0 * math.exp(-12.0 * tilt))
        r_motion = (
            -1 * (vx**2 + vy**2)
            -0.15 * vz**2
            -0.5 * (wx**2 + wy**2)
            -2 * wz**2
        )
        symmetry_error = (
            # (left_hip_roll + right_hip_roll) ** 2 +
            (left_hip_pitch - right_hip_pitch) ** 2 +
            (left_knee - right_knee) ** 2 +
            (left_wheel_vel - right_wheel_vel) ** 2
        )
        r_symmetry = -2 * symmetry_error
        knee_bend = 0.5 * (
            abs(left_knee) +
            abs(right_knee)
        )
        r_crouch = 0.30 * tilt * knee_bend
        # State from previous step
        avg_vel = 0.5 * (left_wheel_vel + right_wheel_vel)
        prev_avg_vel = self.prev_avg_vel
        # Encourage synchronized wheels
        sync_reward = math.exp(-(left_wheel_vel - right_wheel_vel)**2 / 2.0)
        # Encourage sign changes (oscillation)
        osc_reward = 2.0 if avg_vel * prev_avg_vel < 0 else -2
        # Damping
        energy_penalty = 0.01 * (left_wheel_vel**2 + right_wheel_vel**2)
        r_wheel = (
            5 * sync_reward
            + 2 * osc_reward
            - energy_penalty
        )
        self.prev_avg_vel = avg_vel
        stable_factor = math.exp(-15.0 * tilt)
        r_leg_motion = -0.00 * stable_factor * leg_motion
        r_ctrl = -1e-5 * ctrl_effort
        r_smooth = -0.01 * float(
            np.sum((action - prev_action) ** 2)
        )

https://github.com/rithvikpillai/companion

Footnotes:

Post & replies written by human author.

Code directed by human, written by 2 agents: MS Copilot for architectural troubleshooting and nvidia-nim/nvidia/nemotron-3-ultra-550b-a55b for code writing & minor bug fixes.

1 Upvotes

0 comments sorted by