motrixsim.msd#
Classes:
Functions:
|
Load a model file and return an Scene for transformation and building. |
|
Load MSD from MessagePack binary data. |
|
Load string and return an Scene for transformation and building. |
- class motrixsim.msd.Camera(name=None, position=None, orientation=None, position_track=Ellipsis, rotation_track=Ellipsis, track_target=None, orthographic=False, fovy=45.0, depth_only=False, znear=0.0, zfar=0.0, track_position_speed=0.0, track_rotation_speed=0.0)#
基类:
objectAttributes:
- depth_only#
- fovy#
- name#
- orientation#
- orthographic#
- position#
- position_track#
- rotation_track#
- track_position_speed#
- track_rotation_speed#
- track_target#
- zfar#
- znear#
- 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:
add_camera(camera)Add a camera to the scene.
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.
- add_camera(camera)#
Add a camera to the scene.
This method adds a camera to the scene hierarchy. Cameras added through this method will be available in the built model's camera manager.
- 参数:
camera (Camera) -- The camera to add to the scene.
备注
Multiple cameras can be added by calling this method multiple times.
- 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_msgpack(data, base_path)#
Load MSD from MessagePack binary data.
This is more efficient than JSON for large models.
- 参数:
data (bytes) -- MessagePack binary data.
base_path (str) -- Base path for resolving relative asset paths.
- 返回:
An instance ready for transformation and building.
- 返回类型:
- motrixsim.msd.from_str(string, format='mjcf', base_path=None)#
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".
base_path (str, optional) -- Base path for resolving relative asset paths. Required for MSD format to resolve texture and mesh paths.
- 返回:
An instance ready for transformation and building.
- 返回类型: