Genesis-Embodied-AI/genesis-world · error · ValueError
center must have shape (3,)
Error message
center must have shape (3,)
What it means
A radial force field validates its center argument: np.asarray(center) must have shape exactly (3,). Any other shape raises this ValueError during construction, before the field is added to the scene.
Source
Thrown at genesis/engine/force_fields.py:110
The direction of the wind. Will be normalized.
strength: float
The strength of the wind.
radius: float
The radius of the cylinder.
center: array_like, shape=(3,)
The center of the cylinder.
"""
def __init__(self, direction=(1, 0, 0), strength=1.0, radius=1, center=(0, 0, 0)):
super().__init__()
direction = np.array(direction)
if direction.shape != (3,):
raise ValueError("direction must have shape (3,)")
center = np.array(center)
if center.shape != (3,):
raise ValueError("center must have shape (3,)")
self._center = center
self._direction = direction / np.linalg.norm(direction)
self._strength = strength
self._radius = radius
self._direction_qd = qd.Vector(self._direction, dt=gs.qd_float)
self._center_qd = qd.Vector(self._center, dt=gs.qd_float)
self._acc_qd = qd.Vector(self._direction * self._strength, dt=gs.qd_float)
@qd.func
def _get_acc(self, pos, vel, t, i):
# distance to the center of the cylinder pointing in the direction of the wind
dist = (pos - self._center_qd).cross(self._direction_qd).norm()
acc = self._acc_qd
if dist > self._radius:
acc = qd.Vector.zero(gs.qd_float, 3)
return accView on GitHub (pinned to 56e4aa5d82)
Solutions
- Pass a flat 3-element position: center=[0.5, 0, 1.0]
- Flatten or reshape incoming arrays to (3,) before passing
- Add a shape assertion in config-loading code for field positions
Example fix
# before field = RadialForceField(strength=1.0, radius=1, center=np.array([[0], [0], [1]])) # after field = RadialForceField(strength=1.0, radius=1, center=[0, 0, 1])
Defensive patterns
Strategy: validation
Validate before calling
center = np.ravel(center) assert center.shape == (3,), 'center must be a flat 3-vector' field = RadialForceField(strength=1.0, radius=1, center=center)
Type guard
def is_vec3(x) -> bool:
return np.asarray(x).shape == (3,)
Try / catch
try:
field = RadialForceField(center=center, radius=1)
except ValueError as e:
raise ValueError(f'invalid center {center!r}: {e}') from e
Prevention
- Write positions as explicit 3-element lists in configs
- Flatten coordinates coming from planners that use 2D points
When it happens
Trigger: Passing center=[0,0] or [0,0,0,0], a scalar, or a (3,1)/(1,3) array to RadialForceField(center=...).
Common situations: Placing an attractor/repeller field at a 2D point from a top-down planner, loading center coordinates from JSON with a missing component, or passing a column vector.
Related errors
- direction must have shape (3,)
- position must have shape (3,)
- probe_arc_spacing must be positive, got {arc_spacing}
- Python module 'uipc' is required by IPCCoupler but is not in
- `morph` in hybrid entity should be either URDF or Mesh
AI-assisted analysis of Genesis-Embodied-AI/genesis-world@56e4aa5d82 (2026-08-28).
Data as JSON: /api/errors/90388c8ae536f5e9.
Report an issue: GitHub.