Load
load
¶
Load
¶
Bases: MojoBaseModel, ABC
Abstract base for all load types. Subclass and implement resolve_ids and apply_load.
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
resolve_ids
abstractmethod
¶
apply_load
abstractmethod
¶
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
SiteLoad
¶
Bases: Load
Abstract base for Cartesian-space forcing functions applied at a named site. Subclass and implement calculate() to return (force_world, torque_world); the base class handles mj_applyFT, telemetry, and visualization.
action_site
instance-attribute
¶
Site where the force is applied. Its parent body receives the generalized force.
rel_to_site
class-attribute
instance-attribute
¶
Coordinate frame for force/torque components returned by calculate(). When None, components are in the world frame.
user_data
class-attribute
instance-attribute
¶
user_data: SerializeAsAny[UserData] | None = None
Optional strongly-typed payload accessible inside calculate(). Passed through unchanged each timestep.
force_length_scale
class-attribute
instance-attribute
¶
force_length_scale: float | None = None
Length multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_length_scale.
force_width_scale
class-attribute
instance-attribute
¶
force_width_scale: float | None = None
Width multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_width_scale.
torque_length_scale
class-attribute
instance-attribute
¶
torque_length_scale: float | None = None
Length multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_length_scale.
torque_width_scale
class-attribute
instance-attribute
¶
torque_width_scale: float | None = None
Width multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_width_scale.
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
resolve_ids
¶
Caches the integer IDs from the compiled MuJoCo model.
Source code in src/mujoco_mojo/runtime/load.py
calculate
abstractmethod
¶
Calculate the force for the timestep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
MjState
|
The paired MuJoCo model and data instance. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: The force and toque vector output. |
Source code in src/mujoco_mojo/runtime/load.py
| Python | |
|---|---|
request
¶
request(
signal_manager: SignalManager | None = None,
channels: list[Literal["force", "torque"]]
| dict[
Literal["force", "torque"], dict[str, Any] | None
] = ["force", "torque"],
)
Registers specific channels for logging.
| Channel | Description | Type |
|---|---|---|
force |
applied force in the world frame | xyzm |
torque |
applied torque in the world frame | xyzm |
Each channel is posted under subgroups=(load_name, channel).
- An
xyzmis a cartesian vector, posted as 4 values (x,y,z, and its magnitudem).
Each signal is tagged with built-in dimension metadata for its channel (force as force, torque as torque).
If signal_manager is omitted, the SignalManager of the active RuntimeManager with block is used. If that RuntimeManager has no SignalManager configured, this is a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_manager
|
SignalManager | None
|
The signal manager to register the sampler with. |
None
|
channels
|
list[Literal['force', 'torque']] | dict[Literal['force', 'torque'], dict[str, Any] | None]
|
The load data channels to log. Pass a list to select channels, or a dict mapping channel name to metadata overrides (or |
['force', 'torque']
|
Source code in src/mujoco_mojo/runtime/load.py
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
PointToPointForce
¶
Bases: SiteLoad
Scalar force along the line-of-sight between two sites, with an equal and opposite reaction on xtion_site. Use the class-method factories for standard spring formulations, or supply a custom magnitude_func.
xtion_site
instance-attribute
¶
Site that receives the equal-and-opposite reaction force. Named xtion to avoid ambiguity with rel_to_site.
magnitude_func
instance-attribute
¶
Callable (user_data, state) -> signed force magnitude (N). Positive pushes sites apart.
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
action_site
instance-attribute
¶
Site where the force is applied. Its parent body receives the generalized force.
rel_to_site
class-attribute
instance-attribute
¶
Coordinate frame for force/torque components returned by calculate(). When None, components are in the world frame.
user_data
class-attribute
instance-attribute
¶
user_data: SerializeAsAny[UserData] | None = None
Optional strongly-typed payload accessible inside calculate(). Passed through unchanged each timestep.
force_length_scale
class-attribute
instance-attribute
¶
force_length_scale: float | None = None
Length multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_length_scale.
force_width_scale
class-attribute
instance-attribute
¶
force_width_scale: float | None = None
Width multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_width_scale.
torque_length_scale
class-attribute
instance-attribute
¶
torque_length_scale: float | None = None
Length multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_length_scale.
torque_width_scale
class-attribute
instance-attribute
¶
torque_width_scale: float | None = None
Width multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_width_scale.
resolve_ids
¶
Caches the integer IDs from the compiled MuJoCo model.
Source code in src/mujoco_mojo/runtime/load.py
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
ideal_spring
classmethod
¶
ideal_spring(
name: str,
action_site: AnySite,
xtion_site: AnySite,
stiffness: float | NamedValue[float] = 0.0,
damping: float | NamedValue[float] = 0.0,
rest_length: float = 0.0,
) -> Self
Bidirectional spring-damper active in both tension and compression. F = -k*(d - d0) - c*v.
Source code in src/mujoco_mojo/runtime/load.py
stroke_compression_spring
classmethod
¶
stroke_compression_spring(
name: str,
action_site: AnySite,
xtion_site: AnySite,
stiffness: float | NamedValue[float] = 0.0,
damping: float | NamedValue[float] = 0.0,
preload: float | NamedValue[float] = 0.0,
max_stroke: float | NamedValue[float] = 0.1,
) -> Self
Compression spring with a finite stroke; only active while the sites are compressed between rest and (rest + max_stroke). Useful for preloaded gas springs and mechanical end-stops.
Source code in src/mujoco_mojo/runtime/load.py
compression_spring
classmethod
¶
compression_spring(
name: str,
action_site: AnySite,
xtion_site: AnySite,
stiffness: float | NamedValue[float] = 0.0,
damping: float | NamedValue[float] = 0.0,
rest_length: float = 0.0,
) -> Self
Creates a spring-damper that only acts when compressed (dist < rest_length). Useful for bumpers, feet, push-off springs, or end-stops.
Source code in src/mujoco_mojo/runtime/load.py
tension_spring
classmethod
¶
tension_spring(
name: str,
action_site: AnySite,
xtion_site: AnySite,
stiffness: float | NamedValue[float] = 0.0,
damping: float | NamedValue[float] = 0.0,
rest_length: float = 0.0,
) -> Self
Creates a spring-damper that only acts when extended (dist > rest_length). Useful for cables, bungees, or tendons.
Source code in src/mujoco_mojo/runtime/load.py
request
¶
request(
signal_manager: SignalManager | None = None,
channels: list[Literal["force", "torque"]]
| dict[
Literal["force", "torque"], dict[str, Any] | None
] = ["force", "torque"],
)
Registers specific channels for logging.
| Channel | Description | Type |
|---|---|---|
force |
applied force in the world frame | xyzm |
torque |
applied torque in the world frame | xyzm |
Each channel is posted under subgroups=(load_name, channel).
- An
xyzmis a cartesian vector, posted as 4 values (x,y,z, and its magnitudem).
Each signal is tagged with built-in dimension metadata for its channel (force as force, torque as torque).
If signal_manager is omitted, the SignalManager of the active RuntimeManager with block is used. If that RuntimeManager has no SignalManager configured, this is a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_manager
|
SignalManager | None
|
The signal manager to register the sampler with. |
None
|
channels
|
list[Literal['force', 'torque']] | dict[Literal['force', 'torque'], dict[str, Any] | None]
|
The load data channels to log. Pass a list to select channels, or a dict mapping channel name to metadata overrides (or |
['force', 'torque']
|
Source code in src/mujoco_mojo/runtime/load.py
BodyReactionForce
¶
Bases: SiteLoad
Load that also applies an equal and opposite reaction to a second body. If xtion_body is None, only the action site receives the force.
xtion_body
class-attribute
instance-attribute
¶
Body that receives the reaction force. When None, no reaction is applied and the force acts on the world.
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
action_site
instance-attribute
¶
Site where the force is applied. Its parent body receives the generalized force.
rel_to_site
class-attribute
instance-attribute
¶
Coordinate frame for force/torque components returned by calculate(). When None, components are in the world frame.
user_data
class-attribute
instance-attribute
¶
user_data: SerializeAsAny[UserData] | None = None
Optional strongly-typed payload accessible inside calculate(). Passed through unchanged each timestep.
force_length_scale
class-attribute
instance-attribute
¶
force_length_scale: float | None = None
Length multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_length_scale.
force_width_scale
class-attribute
instance-attribute
¶
force_width_scale: float | None = None
Width multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_width_scale.
torque_length_scale
class-attribute
instance-attribute
¶
torque_length_scale: float | None = None
Length multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_length_scale.
torque_width_scale
class-attribute
instance-attribute
¶
torque_width_scale: float | None = None
Width multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_width_scale.
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
calculate
abstractmethod
¶
Calculate the force for the timestep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
MjState
|
The paired MuJoCo model and data instance. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: The force and toque vector output. |
Source code in src/mujoco_mojo/runtime/load.py
| Python | |
|---|---|
request
¶
request(
signal_manager: SignalManager | None = None,
channels: list[Literal["force", "torque"]]
| dict[
Literal["force", "torque"], dict[str, Any] | None
] = ["force", "torque"],
)
Registers specific channels for logging.
| Channel | Description | Type |
|---|---|---|
force |
applied force in the world frame | xyzm |
torque |
applied torque in the world frame | xyzm |
Each channel is posted under subgroups=(load_name, channel).
- An
xyzmis a cartesian vector, posted as 4 values (x,y,z, and its magnitudem).
Each signal is tagged with built-in dimension metadata for its channel (force as force, torque as torque).
If signal_manager is omitted, the SignalManager of the active RuntimeManager with block is used. If that RuntimeManager has no SignalManager configured, this is a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_manager
|
SignalManager | None
|
The signal manager to register the sampler with. |
None
|
channels
|
list[Literal['force', 'torque']] | dict[Literal['force', 'torque'], dict[str, Any] | None]
|
The load data channels to log. Pass a list to select channels, or a dict mapping channel name to metadata overrides (or |
['force', 'torque']
|
Source code in src/mujoco_mojo/runtime/load.py
ScalarForce
¶
Bases: BodyReactionForce
Force along the local X-axis of action_site, scaled by scalar_func each timestep.
scalar_func
class-attribute
instance-attribute
¶
Callable (user_data, state) -> signed force magnitude (N). Positive is along the site's +X axis.
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
action_site
instance-attribute
¶
Site where the force is applied. Its parent body receives the generalized force.
rel_to_site
class-attribute
instance-attribute
¶
Coordinate frame for force/torque components returned by calculate(). When None, components are in the world frame.
user_data
class-attribute
instance-attribute
¶
user_data: SerializeAsAny[UserData] | None = None
Optional strongly-typed payload accessible inside calculate(). Passed through unchanged each timestep.
force_length_scale
class-attribute
instance-attribute
¶
force_length_scale: float | None = None
Length multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_length_scale.
force_width_scale
class-attribute
instance-attribute
¶
force_width_scale: float | None = None
Width multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_width_scale.
torque_length_scale
class-attribute
instance-attribute
¶
torque_length_scale: float | None = None
Length multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_length_scale.
torque_width_scale
class-attribute
instance-attribute
¶
torque_width_scale: float | None = None
Width multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_width_scale.
xtion_body
class-attribute
instance-attribute
¶
Body that receives the reaction force. When None, no reaction is applied and the force acts on the world.
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
request
¶
request(
signal_manager: SignalManager | None = None,
channels: list[Literal["force", "torque"]]
| dict[
Literal["force", "torque"], dict[str, Any] | None
] = ["force", "torque"],
)
Registers specific channels for logging.
| Channel | Description | Type |
|---|---|---|
force |
applied force in the world frame | xyzm |
torque |
applied torque in the world frame | xyzm |
Each channel is posted under subgroups=(load_name, channel).
- An
xyzmis a cartesian vector, posted as 4 values (x,y,z, and its magnitudem).
Each signal is tagged with built-in dimension metadata for its channel (force as force, torque as torque).
If signal_manager is omitted, the SignalManager of the active RuntimeManager with block is used. If that RuntimeManager has no SignalManager configured, this is a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_manager
|
SignalManager | None
|
The signal manager to register the sampler with. |
None
|
channels
|
list[Literal['force', 'torque']] | dict[Literal['force', 'torque'], dict[str, Any] | None]
|
The load data channels to log. Pass a list to select channels, or a dict mapping channel name to metadata overrides (or |
['force', 'torque']
|
Source code in src/mujoco_mojo/runtime/load.py
ScalarTorque
¶
Bases: BodyReactionForce
Torque about the local X-axis of action_site, scaled by scalar_func each timestep.
scalar_func
class-attribute
instance-attribute
¶
Callable (user_data, state) -> signed torque magnitude. Positive follows the right-hand rule about the site's +X axis.
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
action_site
instance-attribute
¶
Site where the force is applied. Its parent body receives the generalized force.
rel_to_site
class-attribute
instance-attribute
¶
Coordinate frame for force/torque components returned by calculate(). When None, components are in the world frame.
user_data
class-attribute
instance-attribute
¶
user_data: SerializeAsAny[UserData] | None = None
Optional strongly-typed payload accessible inside calculate(). Passed through unchanged each timestep.
force_length_scale
class-attribute
instance-attribute
¶
force_length_scale: float | None = None
Length multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_length_scale.
force_width_scale
class-attribute
instance-attribute
¶
force_width_scale: float | None = None
Width multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_width_scale.
torque_length_scale
class-attribute
instance-attribute
¶
torque_length_scale: float | None = None
Length multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_length_scale.
torque_width_scale
class-attribute
instance-attribute
¶
torque_width_scale: float | None = None
Width multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_width_scale.
xtion_body
class-attribute
instance-attribute
¶
Body that receives the reaction force. When None, no reaction is applied and the force acts on the world.
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
request
¶
request(
signal_manager: SignalManager | None = None,
channels: list[Literal["force", "torque"]]
| dict[
Literal["force", "torque"], dict[str, Any] | None
] = ["force", "torque"],
)
Registers specific channels for logging.
| Channel | Description | Type |
|---|---|---|
force |
applied force in the world frame | xyzm |
torque |
applied torque in the world frame | xyzm |
Each channel is posted under subgroups=(load_name, channel).
- An
xyzmis a cartesian vector, posted as 4 values (x,y,z, and its magnitudem).
Each signal is tagged with built-in dimension metadata for its channel (force as force, torque as torque).
If signal_manager is omitted, the SignalManager of the active RuntimeManager with block is used. If that RuntimeManager has no SignalManager configured, this is a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_manager
|
SignalManager | None
|
The signal manager to register the sampler with. |
None
|
channels
|
list[Literal['force', 'torque']] | dict[Literal['force', 'torque'], dict[str, Any] | None]
|
The load data channels to log. Pass a list to select channels, or a dict mapping channel name to metadata overrides (or |
['force', 'torque']
|
Source code in src/mujoco_mojo/runtime/load.py
VectorForce
¶
Bases: BodyReactionForce
3-axis force with independent per-axis callables. Components are expressed in rel_to_site frame, or world frame if None.
fx
class-attribute
instance-attribute
¶
Callable (user_data, state) -> X-axis force component (N).
fy
class-attribute
instance-attribute
¶
Callable (user_data, state) -> Y-axis force component (N).
fz
class-attribute
instance-attribute
¶
Callable (user_data, state) -> Z-axis force component (N).
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
action_site
instance-attribute
¶
Site where the force is applied. Its parent body receives the generalized force.
rel_to_site
class-attribute
instance-attribute
¶
Coordinate frame for force/torque components returned by calculate(). When None, components are in the world frame.
user_data
class-attribute
instance-attribute
¶
user_data: SerializeAsAny[UserData] | None = None
Optional strongly-typed payload accessible inside calculate(). Passed through unchanged each timestep.
force_length_scale
class-attribute
instance-attribute
¶
force_length_scale: float | None = None
Length multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_length_scale.
force_width_scale
class-attribute
instance-attribute
¶
force_width_scale: float | None = None
Width multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_width_scale.
torque_length_scale
class-attribute
instance-attribute
¶
torque_length_scale: float | None = None
Length multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_length_scale.
torque_width_scale
class-attribute
instance-attribute
¶
torque_width_scale: float | None = None
Width multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_width_scale.
xtion_body
class-attribute
instance-attribute
¶
Body that receives the reaction force. When None, no reaction is applied and the force acts on the world.
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
request
¶
request(
signal_manager: SignalManager | None = None,
channels: list[Literal["force", "torque"]]
| dict[
Literal["force", "torque"], dict[str, Any] | None
] = ["force", "torque"],
)
Registers specific channels for logging.
| Channel | Description | Type |
|---|---|---|
force |
applied force in the world frame | xyzm |
torque |
applied torque in the world frame | xyzm |
Each channel is posted under subgroups=(load_name, channel).
- An
xyzmis a cartesian vector, posted as 4 values (x,y,z, and its magnitudem).
Each signal is tagged with built-in dimension metadata for its channel (force as force, torque as torque).
If signal_manager is omitted, the SignalManager of the active RuntimeManager with block is used. If that RuntimeManager has no SignalManager configured, this is a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_manager
|
SignalManager | None
|
The signal manager to register the sampler with. |
None
|
channels
|
list[Literal['force', 'torque']] | dict[Literal['force', 'torque'], dict[str, Any] | None]
|
The load data channels to log. Pass a list to select channels, or a dict mapping channel name to metadata overrides (or |
['force', 'torque']
|
Source code in src/mujoco_mojo/runtime/load.py
VectorTorque
¶
Bases: BodyReactionForce
3-axis torque with independent per-axis callables. Components are expressed in rel_to_site frame, or world frame if None.
tx
class-attribute
instance-attribute
¶
Callable (user_data, state) -> X-axis torque component.
ty
class-attribute
instance-attribute
¶
Callable (user_data, state) -> Y-axis torque component.
tz
class-attribute
instance-attribute
¶
Callable (user_data, state) -> Z-axis torque component.
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
action_site
instance-attribute
¶
Site where the force is applied. Its parent body receives the generalized force.
rel_to_site
class-attribute
instance-attribute
¶
Coordinate frame for force/torque components returned by calculate(). When None, components are in the world frame.
user_data
class-attribute
instance-attribute
¶
user_data: SerializeAsAny[UserData] | None = None
Optional strongly-typed payload accessible inside calculate(). Passed through unchanged each timestep.
force_length_scale
class-attribute
instance-attribute
¶
force_length_scale: float | None = None
Length multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_length_scale.
force_width_scale
class-attribute
instance-attribute
¶
force_width_scale: float | None = None
Width multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_width_scale.
torque_length_scale
class-attribute
instance-attribute
¶
torque_length_scale: float | None = None
Length multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_length_scale.
torque_width_scale
class-attribute
instance-attribute
¶
torque_width_scale: float | None = None
Width multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_width_scale.
xtion_body
class-attribute
instance-attribute
¶
Body that receives the reaction force. When None, no reaction is applied and the force acts on the world.
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
request
¶
request(
signal_manager: SignalManager | None = None,
channels: list[Literal["force", "torque"]]
| dict[
Literal["force", "torque"], dict[str, Any] | None
] = ["force", "torque"],
)
Registers specific channels for logging.
| Channel | Description | Type |
|---|---|---|
force |
applied force in the world frame | xyzm |
torque |
applied torque in the world frame | xyzm |
Each channel is posted under subgroups=(load_name, channel).
- An
xyzmis a cartesian vector, posted as 4 values (x,y,z, and its magnitudem).
Each signal is tagged with built-in dimension metadata for its channel (force as force, torque as torque).
If signal_manager is omitted, the SignalManager of the active RuntimeManager with block is used. If that RuntimeManager has no SignalManager configured, this is a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_manager
|
SignalManager | None
|
The signal manager to register the sampler with. |
None
|
channels
|
list[Literal['force', 'torque']] | dict[Literal['force', 'torque'], dict[str, Any] | None]
|
The load data channels to log. Pass a list to select channels, or a dict mapping channel name to metadata overrides (or |
['force', 'torque']
|
Source code in src/mujoco_mojo/runtime/load.py
GeneralLoad
¶
Bases: VectorForce, VectorTorque
Full 6-DOF force and torque with independent callables for each component. Combines VectorForce and VectorTorque into a single load.
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
action_site
instance-attribute
¶
Site where the force is applied. Its parent body receives the generalized force.
rel_to_site
class-attribute
instance-attribute
¶
Coordinate frame for force/torque components returned by calculate(). When None, components are in the world frame.
user_data
class-attribute
instance-attribute
¶
user_data: SerializeAsAny[UserData] | None = None
Optional strongly-typed payload accessible inside calculate(). Passed through unchanged each timestep.
force_length_scale
class-attribute
instance-attribute
¶
force_length_scale: float | None = None
Length multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_length_scale.
force_width_scale
class-attribute
instance-attribute
¶
force_width_scale: float | None = None
Width multiplier for this load's force arrow(s), on top of MuJoCo's native scaling. None falls back to VisualizationSettings.force_width_scale.
torque_length_scale
class-attribute
instance-attribute
¶
torque_length_scale: float | None = None
Length multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_length_scale.
torque_width_scale
class-attribute
instance-attribute
¶
torque_width_scale: float | None = None
Width multiplier for this load's torque arrow, on top of MuJoCo's native scaling. None falls back to VisualizationSettings.torque_width_scale.
xtion_body
class-attribute
instance-attribute
¶
Body that receives the reaction force. When None, no reaction is applied and the force acts on the world.
tx
class-attribute
instance-attribute
¶
Callable (user_data, state) -> X-axis torque component.
ty
class-attribute
instance-attribute
¶
Callable (user_data, state) -> Y-axis torque component.
tz
class-attribute
instance-attribute
¶
Callable (user_data, state) -> Z-axis torque component.
fx
class-attribute
instance-attribute
¶
Callable (user_data, state) -> X-axis force component (N).
fy
class-attribute
instance-attribute
¶
Callable (user_data, state) -> Y-axis force component (N).
fz
class-attribute
instance-attribute
¶
Callable (user_data, state) -> Z-axis force component (N).
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
request
¶
request(
signal_manager: SignalManager | None = None,
channels: list[Literal["force", "torque"]]
| dict[
Literal["force", "torque"], dict[str, Any] | None
] = ["force", "torque"],
)
Registers specific channels for logging.
| Channel | Description | Type |
|---|---|---|
force |
applied force in the world frame | xyzm |
torque |
applied torque in the world frame | xyzm |
Each channel is posted under subgroups=(load_name, channel).
- An
xyzmis a cartesian vector, posted as 4 values (x,y,z, and its magnitudem).
Each signal is tagged with built-in dimension metadata for its channel (force as force, torque as torque).
If signal_manager is omitted, the SignalManager of the active RuntimeManager with block is used. If that RuntimeManager has no SignalManager configured, this is a no-op.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_manager
|
SignalManager | None
|
The signal manager to register the sampler with. |
None
|
channels
|
list[Literal['force', 'torque']] | dict[Literal['force', 'torque'], dict[str, Any] | None]
|
The load data channels to log. Pass a list to select channels, or a dict mapping channel name to metadata overrides (or |
['force', 'torque']
|
Source code in src/mujoco_mojo/runtime/load.py
JointLoad
¶
Bases: Load
Abstract base for loads applied directly in generalized-coordinate (joint) space via qfrc_applied. Subclass and implement apply_load().
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
resolve_ids
¶
Caches the joint ID, DOF address, and DOF count from the compiled MuJoCo model.
Source code in src/mujoco_mojo/runtime/load.py
apply_load
abstractmethod
¶
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
JointFriction
¶
Bases: JointLoad
Joint friction with a pluggable formulation; use the class-method factories to construct.
Works for hinge, slide, and ball joints. The friction_func receives the full generalized velocity vector for the joint's DOFs and returns a generalized force vector of the same length. All built-in formulations use the velocity magnitude as the scalar speed and apply the resulting force magnitude along -vel/|vel|, so they generalize naturally to multi-DOF joints. Use a NamedValue inside the closure to make parameters mutable at runtime.
friction_func
instance-attribute
¶
(vel, state) -> friction force/torque vector in generalized coordinates. Constructed by the named class-method factories.
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
apply_load
¶
Evaluates friction_func at the current joint velocity vector and accumulates the result into qfrc_applied.
Source code in src/mujoco_mojo/runtime/load.py
request
¶
request(
signal_manager: SignalManager | None = None,
metadata: dict[str, dict[str, Any]] | None = None,
) -> None
Registers specific channels for logging.
| Channel | Description | Type |
|---|---|---|
friction |
applied friction force/torque in the world frame | xyzm |
Each channel is posted under subgroups=(load_name, channel).
- An
xyzmis a cartesian vector, posted as 4 values (x,y,z, and its magnitudem).
friction is tagged with built-in dimension metadata resolved from the joint's type (force for slide, torque for hinge/ball).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_manager
|
SignalManager
|
Manager to register the sampler with. If omitted, the |
None
|
metadata
|
dict[str, dict[str, Any]] | None
|
Metadata overriding or extending the built-in default for the |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the joint has no name. |
Source code in src/mujoco_mojo/runtime/load.py
coulomb_simple
classmethod
¶
Constant-magnitude Coulomb (dry) friction opposing motion. Zero force at standstill. Good for brake pads, dry contacts, and cable friction.
"Simple" because the magnitude is a fixed number you choose, not derived from any actual load on the joint. See karnopp for friction that responds to the joint's real bearing/pin reaction load.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Load name used for telemetry column labeling. |
required |
joint
|
Joint
|
The MJCF joint to act on (slide, hinge, or ball). |
required |
magnitude
|
float | NamedValue[float]
|
Friction force or torque magnitude. Accepts |
required |
Source code in src/mujoco_mojo/runtime/load.py
viscous_simple
classmethod
¶
Velocity-proportional viscous damping. Force is continuous through zero with no discontinuity at standstill. Good for grease-lubricated joints and fluid drag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Load name used for telemetry column labeling. |
required |
joint
|
Joint
|
The MJCF joint to act on (slide, hinge, or ball). |
required |
damping
|
float | NamedValue[float]
|
Damping coefficient (force per velocity, or torque per angular velocity). Accepts |
required |
Source code in src/mujoco_mojo/runtime/load.py
coulomb_viscous_simple
classmethod
¶
coulomb_viscous_simple(
name: str,
joint: Joint,
coulomb: float | NamedValue[float],
viscous: float | NamedValue[float],
) -> Self
Coulomb and viscous friction combined, both at fixed magnitudes you choose. Constant sliding friction plus a velocity-proportional drag term.
"Simple" because neither term is derived from any actual load on the joint. See karnopp for friction that responds to the joint's real bearing/pin reaction load.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Load name used for telemetry column labeling. |
required |
joint
|
Joint
|
The MJCF joint to act on (slide, hinge, or ball). |
required |
coulomb
|
float | NamedValue[float]
|
Coulomb friction force or torque magnitude. Accepts |
required |
viscous
|
float | NamedValue[float]
|
Viscous damping coefficient (force per velocity, or torque per angular velocity). Accepts |
required |
Source code in src/mujoco_mojo/runtime/load.py
stribeck_simple
classmethod
¶
stribeck_simple(
name: str,
joint: Joint,
coulomb: float | NamedValue[float],
static: float | NamedValue[float],
stribeck_velocity: float | NamedValue[float],
viscous: float | NamedValue[float] = 0.0,
) -> Self
Full Stribeck friction model, at fixed magnitudes you choose. Friction peaks at standstill, drops to the kinetic level as motion begins, then rises with speed. Best for brake and clutch models where stick-slip matters.
F = -(coulomb + (static - coulomb) * exp(-|v| / stribeck_velocity) + viscous * |v|) * v / |v|
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Load name used for telemetry column labeling. |
required |
joint
|
Joint
|
The MJCF joint to act on (slide, hinge, or ball). |
required |
coulomb
|
float | NamedValue[float]
|
Kinetic friction force or torque magnitude. Accepts |
required |
static
|
float | NamedValue[float]
|
Peak static friction force or torque at zero velocity. Must be >= |
required |
stribeck_velocity
|
float | NamedValue[float]
|
Characteristic velocity at which friction transitions from static to kinetic. Smaller values give a sharper transition. Accepts |
required |
viscous
|
float | NamedValue[float]
|
Velocity-proportional damping (force per velocity, or torque per angular velocity). Defaults to 0. Accepts |
0.0
|
Source code in src/mujoco_mojo/runtime/load.py
karnopp
classmethod
¶
karnopp(
name: str,
joint: Joint,
mu_kinetic: float | NamedValue[float],
mu_static: float | NamedValue[float],
velocity_threshold: float | NamedValue[float],
viscous: float | NamedValue[float] = 0.0,
) -> Self
Karnopp friction whose normal force is the joint's actual bearing/pin reaction load (Joint.rt_bearing_load), not a fixed magnitude. Responds to ordinary side loads (e.g. a body's weight pressing on a hinge pin, or a side load on a slider) not just a number you pick. Properly distinguishes "stuck" from "sliding" instead of picking a coefficient based on speed alone:
- Sliding (
|v| >= velocity_threshold): ordinary kinetic Coulomb friction,F = -mu_kinetic * bearing_load * v/|v|, plus an optionalviscousterm. - Stuck (
|v| < velocity_threshold): rather than picking a direction from a near-zero (and possibly noisy) velocity, friction is set to exactly cancel whatever other smooth force is currently acting on the joint (qfrc_smooth: passive + actuator + applied + bias), clamped to the static limitmu_static * bearing_load. If the driving force exceeds that limit the joint breaks away and friction saturates at the limit, opposing the driving force.
This avoids the chattering a pure velocity-direction switch can produce right at standstill, since the held force no longer depends on the sign of a near-zero, noisy velocity.
The bearing load comes from Joint.rt_cfrc_int, which refreshes itself on demand via state.ensure_rne_post_constraint(), so no extra wiring is needed regardless of how the simulation is driven. Note that qfrc_smooth reflects the previous step's solve, since this step's values are not yet known when loads are applied; this mirrors the existing one-step lag already inherent in using vel to set this step's force.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Load name used for telemetry column labeling. |
required |
joint
|
Joint
|
The MJCF joint to act on (slide, hinge, or ball). |
required |
mu_kinetic
|
float | NamedValue[float]
|
Friction coefficient applied to the bearing load while sliding. Accepts |
required |
mu_static
|
float | NamedValue[float]
|
Friction coefficient applied to the bearing load that the joint can hold against before breaking away. Accepts |
required |
velocity_threshold
|
float | NamedValue[float]
|
Speed below which the joint is considered stuck rather than sliding. Accepts |
required |
viscous
|
float | NamedValue[float]
|
Velocity-proportional damping added on top of the kinetic term while sliding. Defaults to 0. Accepts |
0.0
|
Source code in src/mujoco_mojo/runtime/load.py
resolve_ids
¶
Caches the joint ID, DOF address, and DOF count from the compiled MuJoCo model.
Source code in src/mujoco_mojo/runtime/load.py
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]
ActuatorControl
¶
Bases: Load
Drives an actuator's control input each timestep, writing into mjData.ctrl. Use control_func for an arbitrary control law, or the constant factory for a simple, runtime-mutable set point.
actuator
instance-attribute
¶
actuator: SerializeAsAny[ActuatorBase]
The MJCF actuator this load drives.
control_func
class-attribute
instance-attribute
¶
Callable (user_data, state) -> control value written into mjData.ctrl for this actuator.
user_data
class-attribute
instance-attribute
¶
user_data: SerializeAsAny[UserData] | None = None
Optional strongly-typed payload accessible inside control_func. Passed through unchanged each timestep.
name
instance-attribute
¶
name: str
Unique label used for telemetry column naming and duplicate-registration warnings.
active
class-attribute
instance-attribute
¶
active: bool = True
When False the load is suppressed.
resolve_ids
¶
apply_load
¶
Evaluates control_func and writes the result into mjData.ctrl[self._aid].
Source code in src/mujoco_mojo/runtime/load.py
| Python | |
|---|---|
request
¶
request(
signal_manager: SignalManager | None = None,
metadata: dict[str, dict[str, Any]] | None = None,
) -> None
Registers the applied control value for logging under Loads/<name>:ctrl.
ctrl's units depend on the driven actuator's transmission and gear/dyntype (the same ambiguity as ActuatorBase.request()'s ctrl channel), so no built-in metadata default is applied. Supply metadata={"ctrl": {...}} yourself if you know it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal_manager
|
SignalManager
|
Manager to register the sampler with. If omitted, the |
None
|
metadata
|
dict[str, dict[str, Any]] | None
|
Metadata for the |
None
|
Source code in src/mujoco_mojo/runtime/load.py
constant
classmethod
¶
Drives the actuator with a fixed set point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Load name used for telemetry column labeling. |
required |
actuator
|
ActuatorBase
|
The MJCF actuator to drive. |
required |
value
|
float | NamedValue[float]
|
Control value written to |
required |
Source code in src/mujoco_mojo/runtime/load.py
get_visuals
¶
get_visuals(state: MjState) -> list[ArrowConfig]