Load
load
¶
Load
¶
Bases: MojoBaseModel, ABC
Base class to build forcing functions off of.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
resolve_ids
¶
Caches the integer IDs from the compiled MuJoCo model.
calculate
abstractmethod
¶
Calculate the force for the timestep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mj_model
|
MjModel
|
description |
required |
mj_data
|
MjData
|
description |
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
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
PointToPointForce
¶
Bases: Load
Acts along the line-of-sight between two sites.
xtion_site
instance-attribute
¶
Site on which the forcing function will apply a reation force. Leave as None to use the worldbody.
This is called xtion to limit confusion between "reaction" and "relative".
magnitude_func
instance-attribute
¶
Func(distance, velocity, initial distance, MjModel, MjData) -> scalar_force. Can be a regular function, lambda, etc.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
resolve_ids
¶
Caches the integer IDs from the compiled MuJoCo model.
Source code in src/mujoco_mojo/runtime/load.py
| Python | |
|---|---|
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> 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
Standard linear spring-damper (works in both tension and compression).
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
Creates a spring-damper that only acts when the runtime length is between rest_length and (rest_legnth + stroke_length)
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
BodyReactionForce
¶
Bases: Load
xtion_body
class-attribute
instance-attribute
¶
Body on which the load should be acted on. If None the world will be used.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
calculate
abstractmethod
¶
Calculate the force for the timestep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mj_model
|
MjModel
|
description |
required |
mj_data
|
MjData
|
description |
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
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
ScalarForce
¶
Bases: BodyReactionForce
Applies a scalar force along the local X-axis of the action_site.
scalar_func
class-attribute
instance-attribute
¶
scalar_func: Callable[
[float, ndarray, MjModel, MjData], float
] = lambda t, unit_vec, m, d: 0.0
Func(time, action_site x axis unit vector, MjModel, MjData) -> scalar force value.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
xtion_body
class-attribute
instance-attribute
¶
Body on which the load should be acted on. If None the world will be used.
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
ScalarTorque
¶
Bases: BodyReactionForce
Applies a scalar torque along the local X-axis of the action_site.
scalar_func
class-attribute
instance-attribute
¶
scalar_func: Callable[
[float, ndarray, MjModel, MjData], float
] = lambda t, unit_vec, m, d: 0.0
Func(time, action_site x-axis unit vector, MjModel, MjData) -> scalar torque value.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
xtion_body
class-attribute
instance-attribute
¶
Body on which the load should be acted on. If None the world will be used.
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
GeneralLoad
¶
Bases: VectorForce, VectorTorque
A 6-DOF force/torque applier.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
xtion_body
class-attribute
instance-attribute
¶
Body on which the load should be acted on. If None the world will be used.
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.