{"record":{"id":"90388c8ae536f5e9","repo":"Genesis-Embodied-AI/genesis-world","slug":"center-must-have-shape-3","errorCode":null,"errorMessage":"center must have shape (3,)","messagePattern":"center must have shape \\(3,\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"genesis/engine/force_fields.py","lineNumber":110,"sourceCode":"        The direction of the wind. Will be normalized.\n    strength: float\n        The strength of the wind.\n    radius: float\n        The radius of the cylinder.\n    center: array_like, shape=(3,)\n        The center of the cylinder.\n    \"\"\"\n\n    def __init__(self, direction=(1, 0, 0), strength=1.0, radius=1, center=(0, 0, 0)):\n        super().__init__()\n\n        direction = np.array(direction)\n        if direction.shape != (3,):\n            raise ValueError(\"direction must have shape (3,)\")\n\n        center = np.array(center)\n        if center.shape != (3,):\n            raise ValueError(\"center must have shape (3,)\")\n\n        self._center = center\n        self._direction = direction / np.linalg.norm(direction)\n        self._strength = strength\n        self._radius = radius\n\n        self._direction_qd = qd.Vector(self._direction, dt=gs.qd_float)\n        self._center_qd = qd.Vector(self._center, dt=gs.qd_float)\n        self._acc_qd = qd.Vector(self._direction * self._strength, dt=gs.qd_float)\n\n    @qd.func\n    def _get_acc(self, pos, vel, t, i):\n        # distance to the center of the cylinder pointing in the direction of the wind\n        dist = (pos - self._center_qd).cross(self._direction_qd).norm()\n        acc = self._acc_qd\n        if dist > self._radius:\n            acc = qd.Vector.zero(gs.qd_float, 3)\n        return acc","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/Genesis-Embodied-AI/genesis-world/blob/56e4aa5d82bdb83f2e532e4cc364cb69527acb06/genesis/engine/force_fields.py#L92-L128","documentation":"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.","triggerScenarios":"Passing center=[0,0] or [0,0,0,0], a scalar, or a (3,1)/(1,3) array to RadialForceField(center=...).","commonSituations":"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.","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"],"exampleFix":"# before\nfield = RadialForceField(strength=1.0, radius=1, center=np.array([[0], [0], [1]]))\n# after\nfield = RadialForceField(strength=1.0, radius=1, center=[0, 0, 1])","handlingStrategy":"validation","validationCode":"center = np.ravel(center)\nassert center.shape == (3,), 'center must be a flat 3-vector'\nfield = RadialForceField(strength=1.0, radius=1, center=center)\n","typeGuard":"def is_vec3(x) -> bool:\n    return np.asarray(x).shape == (3,)\n","tryCatchPattern":"try:\n    field = RadialForceField(center=center, radius=1)\nexcept ValueError as e:\n    raise ValueError(f'invalid center {center!r}: {e}') from e\n","preventionTips":["Write positions as explicit 3-element lists in configs","Flatten coordinates coming from planners that use 2D points"],"tags":["genesis","force-field","validation","shape-mismatch"],"backgroundTag":"argument-shape-validation","analyzedSha":"56e4aa5d82bdb83f2e532e4cc364cb69527acb06","analyzedAt":"2026-08-28T15:15:07.922Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}