---
url: /dyad/stable/stdlib/MultibodyComponents/examples/tests.SphericalConstraintTest.md
description: >-
  Dyad tests.SphericalConstraintTest docs.  A body is connected to the world by
  the implicit SphericalConstraint (ball joint) at one end and pulled back to a
  fixed world point by a Spr...
---

# `tests.SphericalConstraintTest` {#tests.SphericalConstraintTest}

# Spherical Constraint (closed loop with a spring) {#Spherical-Constraint-closed-loop-with-a-spring}

A body is connected to the world by the implicit `SphericalConstraint` (ball joint) at one end and pulled back to a fixed world point by a `Spring` at the other end, forming a closed loop.

The constraint locks all three translations (the origins of the two frames coincide at the world origin) and transmits no torque, leaving the body free to rotate in all three directions about the constraint point. The body swings under gravity (along `-y`, acting on the offset center of mass) and the spring load.

The free body carries its own (absolute) Euler body coordinates as states, given concrete initial conditions `phi = [0, 0, 0]` and `phid = [0, 0, 0]`. The spherical constraint imposes no rotational constraint, so any orientation lies on the constraint manifold and the initialization is fully determined (cf. the `RevoluteConstraintTest` rationale for pinning the orientation).

## Usage {#Usage}

`MultibodyComponents.tests.SphericalConstraintTest()`

## Behavior {#Behavior}

## Source {#Source}

```dyad
"""
# Spherical Constraint (closed loop with a spring)

A body is connected to the world by the implicit `SphericalConstraint` (ball
joint) at one end and pulled back to a fixed world point by a `Spring` at the
other end, forming a closed loop.

The constraint locks all three translations (the origins of the two frames
coincide at the world origin) and transmits no torque, leaving the body free to
rotate in all three directions about the constraint point. The body swings under
gravity (along `-y`, acting on the offset center of mass) and the spring load.

The free body carries its own (absolute) Euler body coordinates as states, given
concrete initial conditions `phi = [0, 0, 0]` and `phid = [0, 0, 0]`. The
spherical constraint imposes no rotational constraint, so any orientation lies on
the constraint manifold and the initialization is fully determined (cf. the
`RevoluteConstraintTest` rationale for pinning the orientation).
"""
example component SphericalConstraintTest
  world = MultibodyComponents.World() {}
  constraint = MultibodyComponents.SphericalConstraint() {}
  body = MultibodyComponents.Body(m = 1, r_cm = [0.2, 0, 0], I_11 = 0.1, I_22 = 0.1, I_33 = 0.1, orientation_state = OrientationState.Euler(), sequence = [1, 2, 3], phi(initial = [0, 0, 0]), phid(initial = [0, 0, 0]), r_0(initial = missing), v_0(initial = missing)) {}
  rod = MultibodyComponents.FixedTranslation(r = [0.4, 0, 0], render = false) {}
  spring = MultibodyComponents.Spring(c = 20, s_unstretched = 0) {}
  mount = MultibodyComponents.FixedTranslation(r = [0.8, 0, 0.3], render = false) {}
relations
  connect(world.frame_b, constraint.frame_a) {}
  connect(constraint.frame_b, body.frame_a, rod.frame_a) {}
  connect(rod.frame_b, spring.frame_b) {}
  connect(world.frame_b, mount.frame_a) {}
  connect(mount.frame_b, spring.frame_a) {}
end
```

```dyad
"""
# Spherical Constraint (closed loop with a spring)

A body is connected to the world by the implicit `SphericalConstraint` (ball
joint) at one end and pulled back to a fixed world point by a `Spring` at the
other end, forming a closed loop.

The constraint locks all three translations (the origins of the two frames
coincide at the world origin) and transmits no torque, leaving the body free to
rotate in all three directions about the constraint point. The body swings under
gravity (along `-y`, acting on the offset center of mass) and the spring load.

The free body carries its own (absolute) Euler body coordinates as states, given
concrete initial conditions `phi = [0, 0, 0]` and `phid = [0, 0, 0]`. The
spherical constraint imposes no rotational constraint, so any orientation lies on
the constraint manifold and the initialization is fully determined (cf. the
`RevoluteConstraintTest` rationale for pinning the orientation).
"""
example component SphericalConstraintTest
  world = MultibodyComponents.World() {}
  constraint = MultibodyComponents.SphericalConstraint() {}
  body = MultibodyComponents.Body(m = 1, r_cm = [0.2, 0, 0], I_11 = 0.1, I_22 = 0.1, I_33 = 0.1, orientation_state = OrientationState.Euler(), sequence = [1, 2, 3], phi(initial = [0, 0, 0]), phid(initial = [0, 0, 0]), r_0(initial = missing), v_0(initial = missing)) {}
  rod = MultibodyComponents.FixedTranslation(r = [0.4, 0, 0], render = false) {}
  spring = MultibodyComponents.Spring(c = 20, s_unstretched = 0) {}
  mount = MultibodyComponents.FixedTranslation(r = [0.8, 0, 0.3], render = false) {}
relations
  connect(world.frame_b, constraint.frame_a) {}
  connect(constraint.frame_b, body.frame_a, rod.frame_a) {}
  connect(rod.frame_b, spring.frame_b) {}
  connect(world.frame_b, mount.frame_a) {}
  connect(mount.frame_b, spring.frame_a) {}
metadata {}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
