motrixsim.msd#
Classes:
A builder for combining and building MSD models. |
Functions:
|
Load a model file and return an Scene for transformation and building. |
|
Load string and return an Scene for transformation and building. |
- class motrixsim.msd.Scene#
基类:
objectA builder for combining and building MSD models.
This class provides a simple API for combining multiple models together using attach, then building the final simulation model.
Example:
```text import motrixsim as mx
# Load and build directly model = mx.from_file("robot.xml").build()
# Attach another model with transformations robot = mx.from_file("robot.xml") gripper = mx.from_file("gripper.xml") robot.attach(
gripper, self_link_name="hand", other_prefix="gripper_", other_translation=[0.1, 0, 0]
) model = robot.build()
# Combine multiple instances of the same model (other is cloned internally) scene = mx.from_file("scene.xml") robot = mx.from_file("robot.xml") scene.attach(robot, other_prefix="robot1_", other_translation=[1, 0, 0]) scene.attach(robot, other_prefix="robot2_", other_translation=[2, 0, 0]) model = scene.build() ```
Methods:
attach(other[, self_link_name, ...])Attach another model to this one.
build()Build this Scene into a SceneModel ready for simulation.
deepcopy()Deepcopy this Scene.
Attributes:
Get the name of this instance.
- attach(other, self_link_name=None, other_link_name=None, other_translation=None, other_rotation=None, other_prefix=None, other_suffix=None)#
Attach another model to this one.
This method merges another Scene into this one. The other model can be optionally attached to a specific link, transformed, and have its names prefixed/suffixed to avoid conflicts.
备注
The other model is cloned internally, so it can be reused for multiple attach calls.
- 参数:
other (Scene) -- The model to attach (cloned internally).
self_link_name (str, optional) -- Link in this model to attach to. If None, the other model is merged at the root level.
other_link_name (str, optional) -- Extract only this subtree from the other model before attaching.
other_translation (list[float], optional) -- Translation [x, y, z] to apply to the other model.
other_rotation (list[float], optional) -- Rotation quaternion [x, y, z, w] to apply to the other model.
other_prefix (str, optional) -- Prefix to add to all names in the other model (e.g., "left_" to avoid name conflicts).
other_suffix (str, optional) -- Suffix to add to all names in the other model.
- 抛出:
RuntimeError -- If the link is not found or if there are duplicate names.
Example:
```text robot = mx.from_file("robot.xml") gripper = mx.from_file("gripper.xml")
# Attach gripper to robot's hand link with prefix robot.attach(
gripper, self_link_name="hand", other_prefix="gripper_", other_translation=[0.05, 0, 0]
)
# gripper can be reused robot.attach(gripper, self_link_name="other_hand", other_prefix="gripper2_")
- build()#
Build this Scene into a SceneModel ready for simulation.
This compiles all attached models into a single simulation model.
- 返回:
The compiled simulation model.
- 返回类型:
- 抛出:
RuntimeError -- If the build fails.
Example:
```text # Simple build model = mx.from_file("robot.xml").build()
# Build after attaching models robot = mx.from_file("robot.xml") gripper = mx.from_file("gripper.xml") robot.attach(gripper, self_link_name="hand", other_prefix="gripper_") model = robot.build()
- name#
Get the name of this instance.
- 返回:
The name of the model.
- 返回类型:
str
- motrixsim.msd.from_file(path)#
Load a model file and return an Scene for transformation and building.
- 参数:
path (str) -- Path to the model file (MJCF, URDF, or MSD format).
- 返回:
An instance ready for transformation and building.
- 返回类型:
- motrixsim.msd.from_str(string, format='mjcf')#
Load string and return an Scene for transformation and building.
- 参数:
string (str) -- MJCF/URDF/MSD model string.
format (str) -- The format of the model string. One of "mjcf", "urdf", or "msd".
- 返回:
An instance ready for transformation and building.
- 返回类型: