GubiLabsAcademy

MODULE 11 / DIGITAL WORKSHOP

Your first physics laboratory

Create an isolated Python environment, run a small physics model, and separate simulation from its window. Start with one controllable joint so every number has a physical meaning.

90–150 min6 lab steps3 knowledge checks In progress

By the end, you can…

  • Create and verify an isolated simulation environment
  • Load a model and save measured motion
  • Explain model, state, time step and viewer
BRING WITH YOU

Python and terminal basics

Joints and coordinate frames

EXPLORE THE PROCESSA digital robot is built from evidence.
STEP 1

Physical robot

Measure lengths, mass, joint axes, mounting offsets and materials. Record uncertainty.

The process loops: measurements improve the model. Exporting a mesh supplies shape, but does not automatically supply correct joints, inertia or control settings.
01

A simulator is a calculator that advances time

Think of a simulation as a sequence of questions. Where is the arm now? How fast is it moving? Which forces act on it? Given a short interval of time, where will it be next? MuJoCo repeats that calculation. A rendered window lets you watch the answers, but the calculation can run without a window. That is why a graphics error and a physics error need different investigations.

The model describes the machine and settings: the hinge axis, link mass, geometry and allowed torque. The state contains values that change, such as angle, speed and simulation time. In Python, MjModel stores the compiled model and MjData stores the evolving state. Resetting the state does not install a different model. Editing an XML file does not change a model already loaded into memory; reload it.

02

Keep the course environment separate

A virtual environment is a folder containing a Python interpreter link and installed packages for this project. It avoids making another application depend on the versions used by this lesson. Use Python 3.12 for the demonstrated package combination. Keep the lesson files beside .venv, not inside it. You can recreate the environment from a dependency list; your experiments and notes are the valuable files.

The course uses MuJoCo 3.3.7 to stay aligned with the BDX-R audit. Version numbers are part of an experiment, not decoration. A newer release may be useful later, but first make one known combination work. Download the listed files into a course-labs folder. A browser may append .txt to a Python file; confirm that its real extension is .py.

03

Read the hinge before running it

Open hinge.xml in a text editor. A world contains a floor and a visual stand. The arm is a rigid body carrying a capsule with mass 0.2 kg. Its hinge rotates around the local Y axis. The motor accepts torque, limited to ±1 N·m in this teaching model. The support stand is visual-only for contact, so it does not fight the arm at the pivot. These are deliberately small teaching values, not RobStride operating limits.

The numerical run starts at −0.5 rad and requests +0.5 rad. Gravity pulls the hanging link downward. A proportional-and-damping controller supplies torque toward the target. Expect motion, a transient response and a final error; a position request is not an instruction that teleports the arm. We will explain the remaining error in the control lesson.

04

Two clocks and one honest observation

Simulation time advances by the model time step, 0.002 seconds here. Wall-clock time is the time you wait. A four-second numerical experiment may finish much faster than four seconds; the viewer deliberately paces it so a person can follow. Neither the frame rate nor your monitor refresh rate defines the physics step.

Write down what you expect before opening the result. A graph preserves small overshoots that your eyes may miss. A screenshot proves a window appeared; a CSV records measured values. Keep both kinds of evidence when they answer different questions.

In the Python program, mujoco.mj_step(model, data) performs one physics update using the configured time step. Here, one call advances simulated time by 0.002 seconds; 2,000 calls advance it by four seconds. Drawing a frame is a separate operation. The program may calculate several physics updates between visible frames without changing the size of each physics step.

WORDS YOU NOW KNOW

State
The changing quantities that describe the simulation now.
Time step
The simulated duration advanced by one physics update.
Headless
Running a calculation without opening a rendered window.

YOUR CALL

Finished with this module?

0 of 6 lab steps checked. 0 of 3 questions answered. You decide when the module is complete. Revisiting or editing it will not change your decision.

You can reopen it later. Checking every box will not automatically complete it.

Go to the source

Primary references for this module. Use the version and hardware revision named in the lesson.

MuJoCo Python and viewer guidePython virtual environmentsDownload hinge modelDownload hinge experimentDownload graph toolDownload requirements