Jul 2023  

Browser-based robot dog simulator

I’m continuing to learn about robot simulation, and the next step is simulating a real robot, rather than a simplified platform.

I’ve chosen a quadruped (Unitree A1) for the next demo. First step is to load robot description from the official repository, using urdf-loaders library. Next, robot’s links and joints can be created in rapier.js physics engine for simulation and added to a three.js scene for visualization. For each loaded robot body part, we need to create:

Physics model connected with joints works well for inverse kinematics, when some of the model’s parts positions are set with 3d controls. We set positions of robot’s torso ans feet, and the rest of the parts and joints poses are then computed based on the physics simulation. Interactive demo is shown below. Let’s call this the control model.

Inverse kinematics can be used to drive another robot model, which actually simulates robot’s body dynamics. Let’s call this simulation model. This model’s parts poses are are not constrained, and are controlled by setting joints motors/angles. Angles values are obtained from measuring angles between body parts of the control model.

Next demo shows 2 models, control model on the left and simulation model on the right. Control model can be interactively manipulated, and it sets the pose of the simulation model, which is a proper physics/dynamics model.

The whole project is ~800 LOC, which is quite compact for a realistic 3d robot simulator. I do believe that existing robotics simulators are frequently over-engineered, and it looks that some parts of a simulator can be simplified by relying on WebGL and WASM.

Next, implementing a motion controller.