Locomotion, Humanoids, and Navigation › Body Dynamics and Terrain Interaction
World Models HandbookAll chapters Locomotion, Humanoids, and Navigation › Body Dynamics and Terrain InteractionOne section · Sections in this chapter2 / 8 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
A typical legged robot has a floating base with six local configuration coordinates: three for position and three for orientation. Joint torques do not directly actuate those coordinates; gravity and external contact forces affect base motion. This differs from the fixed-base arm examples in the previous chapter, though mobile manipulators can also have moving bases. Inverse kinematics can propose a pose, but dynamic feasibility still depends on contact, torque, and friction limits.
The equations of motion for a floating-base robot with joints describe the balance of inertial forces against actuation and contact forces. The floating-base rigid-body dynamics in standard form are:
where:
- is a local coordinate representation of base pose plus joint angles; three orientation coordinates require a local chart.
- is the mass matrix, coupling joint and base accelerations.
- is the Coriolis and centrifugal force vector.
- is the gravity force vector.
- selects the actuated joints, so applies joint torques and nothing to the six unactuated base degrees of freedom.
- is the set of currently active contacts, is the contact Jacobian, and is the contact force at contact .
- is the generalized force induced by contact , including a wrench on the floating base.
The left-hand side of the equation collects inertial, velocity-dependent, and gravitational terms. On the right, applies commanded joint torques, while represents generalized contact forces, including forces on the floating base. Contact forces are not independent commands in this formulation: they must be feasible consequences of motion, geometry, and contact constraints.
The important observation is that the base has no actuation term in the right-hand side: joint torques act on it only through the limbs and their contacts. Gravity still accelerates the center of mass in flight, and active contact forces can accelerate and rotate the base. Locomotion uses joints to push the ground so that the ground pushes back in a direction that moves the robot toward its goal. You must also respect actuator torque limits, joint velocity limits, and the available friction at each contact, or the base motion you plan will not be achievable. These limits separate a mathematically valid trajectory from one the hardware can execute, and they reappear throughout the whole-body control section below.
Two things follow. First, the base motion is not directly commanded; it emerges from gravity, internal body motion, and contact. A world model of locomotion must account for contact forces as well as joint angles. Second, if no contact is active, the robot is in free flight and . Joint motion can reorient the torso relative to the limbs, as in the "falling cat" effect. But internal torques cannot accelerate the whole-body center of mass. With gravity as the only external force, that center of mass follows a ballistic trajectory; its linear momentum changes under gravity, not under internal actuation.
The falling-cat intuition is worth dwelling on because it recurs across the whole chapter. A gymnast who has left the ground cannot accelerate her center of mass upward using only internal motion, but she can twist her limbs to reorient her torso. In the same way, a legged robot in the flight phase of a hop can tuck or extend its legs to change its orientation for landing, but it cannot steer its center-of-mass trajectory without an external force. For the vertical hopper below, flight is simple ballistic motion; predicting a full robot's free-flight orientation and landing configuration can still be difficult. Stance adds large, state-dependent contact forces, so splitting predictions by contact mode is useful.
Another structural feature is that legged locomotion often has distinct contact modes. Touchdown, liftoff, and slip can change the applicable force law; a rigid impact may reset velocity, whereas a compliant-contact model can change forces continuously. A predictor may need both within-mode dynamics and the timing of transitions. The consequences of mistiming depend on the model and task: a wrong contact mode can produce a large rollout error, but neither a discontinuous state jump nor error growth is inevitable.
Consider a one-dimensional vertical hopper, the simplest instructive example. Let be the height of the body, its vertical velocity, and the terrain height at horizontal position . The dynamics switch between two modes: ballistic flight under gravity, and stance with a compliant ground reaction force. Written as a piecewise law:
where:
-
: the height of the body, with its vertical acceleration.
-
: the gravitational acceleration.
-
: the body mass.
-
: the toy spring-damper force in stance, given by .
-
: the terrain height at horizontal position .
-
: the ground stiffness, and : the ground damping. The transition rules are equally important:
-
Flight stance when and .
-
Stance flight when in this toy's hysteretic mode rule.
This simple system illustrates gravity, a terrain-dependent force, event-triggered mode switches, and a trajectory shaped by switch timing. It is deliberately not a physically exact unilateral contact model: the unclamped spring-damper can briefly pull downward while the mode remains stance, whereas a real ground contact cannot pull the foot toward the surface. Extending to a biped also requires multiple contacts, surface normals, friction, impact handling, and active joint torques. The hopper isolates the hybrid timing problem without claiming to capture every difficulty of locomotion.
To build intuition for the one-dimensional case, note that the flight mode is a simple kinematic equation whose solution is a parabola, and the stance mode is a mass-spring-damper system:
where:
- : the inertial force on the body.
- : the gravitational force.
- : the elastic restoring force from the compliant ground, proportional to how far the body has compressed below the terrain height .
- : the damping force opposing vertical velocity.
In this toy, a state-dependent guard switches between flight and stance, so the trajectory is piecewise smooth and guard timing matters. Near a transition, a small height or velocity error can select the wrong mode. The resulting rollout then uses the wrong force law until its mode estimate is corrected; its error may be substantial, but its magnitude and direction depend on the trajectory. Guard accuracy and within-mode accuracy both matter, and neither is universally the dominant engineering problem.
A hybrid dynamical system is a system whose state evolves continuously within each of several modes, with discrete jumps or mode switches triggered by state-dependent events (guards). Locomotion, grasping, and many contact-rich manipulation tasks are hybrid; the events (footstrike, liftoff, slip) are often the hard part of the prediction problem.
Terrain as a Latent Variable
Here is where locomotion world models differ most sharply from generic sequence models. The transition function depends on variables such as terrain height and friction that are not part of the robot's proprioceptive state. The robot senses terrain through a camera, LiDAR, a depth sensor, or proprioceptive feedback when its feet make contact. Predictions over terrain it has not yet stepped on are inherently uncertain. Put differently, the hopper's rollouts above assumed the terrain function was known; in reality is one of the quantities the robot must estimate, and it changes from one part of the world to the next.
We can make this formal by writing the environment as a partially observable process. Let denote the terrain parameters (per cell: height, slope, friction, compliance), the robot's physical state, and its observations. A latent-parameter model has a transition law conditioned on terrain and an observation law conditioned on both state and terrain:
where:
- : terrain parameters (per-cell height, slope, friction, compliance) that are fixed but unknown
- : robot's physical state (base pose, joint angles, velocities)
- : control action (joint torques or desired joint positions)
- : observation (proprioceptive sensors and exteroceptive sensors such as camera or LiDAR)
The controller maintains a belief over terrain, in the sense of the posterior introduced in the filtering sections. A landing's impact and resulting body motion can be informative; between contacts, exteroceptive sensing can also update the belief. This is the belief-state framework from Part II, Ch 2: Bayesian Filtering and Belief States, applied to terrain alongside robot-state estimation. Here is fixed but unknown over the modeled region; is robot pose, joints, and velocities; is a commanded torque or joint target. The conditional transition may itself be deterministic or stochastic. Even if it is deterministic for a fixed , marginalizing over makes the controller's prediction uncertain. A controller can plan against a nominal terrain estimate or average over belief samples; the nominal MPC formulation below illustrates the former. In practice terrain and body state are often estimated jointly: a footstep on an unexpectedly soft patch informs both the surface model and the body's velocity estimate.
The terrain remains uncertain even when the robot's pose is well estimated. If terrain were fully observed, one could append it to the robot state and recover a standard MDP. The latent-parameter framing clarifies what each observation contributes: contact measurements are local and direct but can be distorted by slip or compliance; exteroception covers terrain ahead but depends on visibility and geometry. An estimator can combine both, updating its local surface estimate after contact while using cameras or depth sensors to anticipate terrain ahead.
We can see a toy belief over terrain narrowing as observations arrive. In the following synthetic measurement model, each contact supplies an independent, unbiased Gaussian observation of one fixed local height. With the stipulated flat prior, posterior standard deviation is after observations. Real contacts can be biased or correlated, so they need not follow this curve.
## Fixed-seed synthetic posterior over a single terrain-height parameter.
## The measurement noise is Gaussian with standard deviation 0.12; with a flat prior,
## the posterior mean is the running sample mean and the posterior std is
## 0.12 / sqrt(n) by construction. No randomness is used at plot time.
rng_belief = np.random.default_rng(0)
true_h = 0.35
n_obs = np.arange(1, 26)
belief_obs = true_h + rng_belief.normal(0.0, 0.12, size=n_obs.size)
post_mean = np.cumsum(belief_obs) / n_obs
post_std = 0.12 / np.sqrt(n_obs)
The practical lesson is conditional. Ignoring uncertainty in a terrain estimate can make a predicted step overconfident; omitting task-relevant terrain information can increase transition error or hide useful foothold choices. Neither outcome follows for every controller or gait. Perceptive locomotion systems can combine proprioceptive feedback with exteroceptive information about terrain ahead, as in Miki et al.'s quadruped work below. Their sensing and control update rates depend on the implementation; both information streams can contribute to feedback and prediction.
Learned Terrain Reference Models
There is a middle ground between a full physics-based simulator and an end-to-end neural network. Some systems learn a terrain-related latent from recent proprioceptive history and condition a policy on it. Such an encoder approximates information in a terrain belief , although its latent need not be a calibrated posterior. Lee et al. (2020), "Learning Quadrupedal Locomotion over Challenging Terrain" trained a proprioceptive student policy with a temporal convolutional network over observation history, supervised by a privileged teacher. Miki et al., 2022, "Learning robust perceptive locomotion for quadrupedal robots in the wild" combined proprioception with exteroceptive height samples from an elevation map constructed from onboard sensor data; an attention-based recurrent belief encoder learned how to use imperfect perception. Miki et al. did not learn the elevation map itself in the policy. These examples show different ways to condition locomotion on inferred terrain information, not a single explicit probabilistic world-model architecture.
Such architectures can separate an estimator from a policy, making the interface inspectable when it is explicitly defined. A history encoder may infer terrain-related properties from joint and body measurements, commands, and contact responses; which signals are useful depends on the sensors and actions. Similar histories can arise on different surfaces, and terrain can change within an episode, so an inferred latent is not automatically an identifiable or calibrated terrain parameter.
When terrain is not directly observable but affects a trajectory, explicit parameter estimation and recurrent history encoding are two options; exteroceptive sensing and hybrid estimators add others. An explicit estimate can be easier to inspect and calibrate, while a recurrent latent can retain useful history without a hand-specified terrain variable. Neither has a general advantage in data efficiency or failure rate. Those properties need comparison on the intended robot, sensor suite, and terrain.
The tradeoff can be read as a choice of where uncertainty lives. Explicit estimation keeps the terrain posterior separate and lets the planner propagate it forward, whereas recurrent absorption pushes the uncertainty into the hidden state, which is harder to inspect but avoids hand-designing a terrain model. Which choice is better depends on what you intend to do with the uncertainty. If you plan to plan conservatively, an explicit posterior that can be queried for a confidence bound is invaluable. If you only need a policy that acts well, an absorbed hidden state may be all you need, and the representational freedom it allows can be an advantage rather than a liability.
Let us make the hybrid, terrain-dependent dynamics concrete by simulating the simple 1D hopper. The simulator below uses a fixed two-millisecond explicit step and a spring-damper guard rule. We do not establish numerical convergence or model a rigid impact; the goal is to expose mode structure, not to match a production simulator.
import matplotlib.pyplot as plt
import numpy as np
## Physical constants for the 1D hopper
g = 9.81
m = 1.0
k = 200.0
b = 5.0
def terrain_height(x, a1=0.10, a2=0.05, w1=4.0, w2=1.3):
"""Rolling, mildly irregular terrain."""
return a1 * np.sin(2 * np.pi * x / w1) + a2 * np.sin(2 * np.pi * x / w2)
def simulate_hopper(
x0, z0, vz0, vx0, terrain_fn=terrain_height, dt=0.002, steps=3000
):
"""Simulate a 1D hopper: ballistic in flight, spring-damper in stance."""
xs = np.zeros(steps)
zs = np.zeros(steps)
vzs = np.zeros(steps)
phases = np.zeros(steps, dtype=int) # 0 = flight, 1 = stance
x, z, vz = x0, z0, vz0
phase = 0
x_c = x0 # horizontal position of the current foot contact
for t in range(steps):
xs[t], zs[t], phases[t] = x, z, phase
vzs[t] = vz
if phase == 0: # flight
vz_next = vz - g * dt
z_next = z + vz_next * dt
x_next = x + vx0 * dt
ground_next = terrain_fn(x_next)
if z_next <= ground_next and vz_next <= 0:
phase = 1
x_c = x_next
x = x_next
z = ground_next
# Retain impact velocity for the compliant spring to decelerate.
vz = vz_next
else:
x, z, vz = x_next, z_next, vz_next
else: # stance
ground = terrain_fn(x_c)
F = -k * (z - ground) - b * vz
vz_next = vz + (-g + F / m) * dt
z_next = z + vz_next * dt
if z_next > ground + 1e-3:
phase = 0
x = x_c + vx0 * dt
z, vz = z_next, vz_next
else:
z, vz = z_next, vz_next
return xs, zs, vzs, phasesThe simulator is a compact illustration of the flight–stance switch, not a complete contact model. It tracks body height, vertical velocity, and an integer mode flag. Flight applies gravity and constant horizontal drift, then tests for a descending touchdown. Stance applies a spring-damper force referenced to terrain height at the latched contact and tests for liftoff after crossing a small height threshold. These programmed guards control the toy's mode changes; full legged-robot dynamics require more state, constraints, and impact handling.
We now run a single trajectory from fixed initial conditions. The compliant-contact model retains downward velocity at touchdown, so its spring can return some energy before liftoff; damping dissipates energy across subsequent contacts.
xs, zs, vzs, phases = simulate_hopper(
x0=0.0, z0=0.6, vz0=0.0, vx0=1.5, steps=4000
)
ground = terrain_height(xs)
t_array = np.arange(len(xs)) * 0.002We can visualize the trajectory against the terrain, shading the intervals where the foot is in contact. The plot cell consumes the arrays computed above and does no simulation itself.

The plot makes the hybrid structure visible, though this particular run spends most of its sampled steps in stance. The short flight segments trace shallow parabolic arcs; during stance the trajectory bends as the compliant spring pushes against the ground. Contact state and impact velocity influence the next apex; a whole-body controller can also change the subsequent stance response. This hybrid behavior can be modeled as a switched system, where the mode variable (0 = flight, 1 = stance) determines which dynamics govern the state evolution, so that each mode contributes its own dynamics and the guard condition selects which one is active at each instant. The value of is itself a prediction target because the world model has to know when the next touchdown or liftoff will occur.
The same trajectory can be read in state space rather than in time. Coloring height–velocity samples by mode shows how this run moves through flight and stance; the programmed guards, not separation in this projection, determine when the active mode changes.

Notice how much the terrain function enters even this one-dimensional model. Its stance force depends on displacement relative to terrain height at the contact, so height error changes the predicted force and acceleration. A full legged robot can have similar coupling at its active contacts; joint terrain and body-state estimation is one possible response, not a requirement for every controller.