motrixsim#
Classes:
The Actuator object represents a controllable actuator in the simulation. |
|
The Body object represents a rigid body in the scene. |
|
The Camera object in the scene. |
|
|
|
The FloatingBase object represents a floating base in the scene. |
|
The Geom object represents a geometry in the scene. |
|
The HField object represents a height field terrain in the scene. |
|
The Joint object represents a joint in the scene. |
|
The Keyframe object represents a keyframe in the scene. |
|
The Link object represents a kinematic link in the scene. |
|
The Mocap object represents a motion capture body in the scene. |
|
The Options object represents the simulation options. |
|
|
The SceneData object represents the simulation state. |
The SceneModel object represents the entire simulation world. |
|
The shape type of a collider. |
|
The Site object represents a reference point or marker in the scene. |
Functions:
|
Run forward kinematic only. |
|
Load a model from a string containing MJCF data. |
|
Load a model from the given file path. |
|
Advance the simulation by one step. |
- class motrixsim.Actuator#
基类:
objectThe Actuator object represents a controllable actuator in the simulation.
This class provides access to the properties and methods of an actuator, allowing users to query its name, index, control range, and set the control value.
Methods:
get_ctrl(data)Get the control value of the actuator.
set_ctrl(data, ctrl)Set the control value of the actuator.
Attributes:
The control range of the actuator.
The index of the actuator in the simulation world.
The name of the actuator.
The name of the actuator target.
The type of the actuator target.
The type of the actuator.
- get_ctrl(data)#
Get the control value of the actuator.
- 参数:
data (SceneData) -- The scene data.
- 返回:
The current control value of the actuator. shape = (*data.shape, )
- 返回类型:
NDArray[float]
- set_ctrl(data, ctrl)#
Set the control value of the actuator.
- 参数:
data (SceneData) -- The scene data to store the control value.
ctrl (float | NDArray[float]) -- The control value to set. If the data has batch dimension, ctrl must have the same shape as the data.
- ctrl_range#
The control range of the actuator.
Returns None if not set.
- Type:
Optional[Tuple[float, float]]
- index#
The index of the actuator in the simulation world.
- Type:
int
- name#
The name of the actuator.
Return "None" if not set.
- Type:
Optional[str]
- target_name#
The name of the actuator target. (e.g., joint name, tendon name).
- Type:
str
- target_type#
The type of the actuator target.
valid values are:
"floating_base": For floating base actuators.
"joint": For joint actuators.
"tendon": For tendon actuators.
- Type:
str
- typ#
The type of the actuator.
valid values are:
"general": General actuator.
"position": Position servo. The ctrl represents the target position
"velocity": Velocity servo. The ctrl represents the target velocity
"motor": The ctrl represents the torque or force
- Type:
str
- class motrixsim.Body#
基类:
objectThe Body object represents a rigid body in the scene.
This class provides access to the properties and state of a rigid body in the simulation. It allows you to retrieve information about the body's name, floating base, pose, and DoF positions and velocities.
Methods:
get_dof_pos_indices([include_floatingbase])Get the indices of the DoF positions of the body.
get_dof_vel_indices([include_floatingbase])Get the indices of the DoF velocities of the body.
get_joint_dof_pos(data)Get the DoF positions of all joints on the body.
get_joint_dof_vel(data)Get the DoF velocities of all joints on the body.
get_pose(data)Get the world pose of the body.
get_position(data)Get the world position of the body.
get_rotation(data)Get the world rotation of the body as a quaternion.
get_rotation_mat(data)Get the world rotation of the body as a rotation matrix.
set_actuator_ctrls(data, ctrls)Set the control values for all actuators on this body.
set_dof_pos(data, dof_pos[, ...])Set the DoF positions of the body.
set_dof_vel(data, dof_vel[, ...])Set the DoF velocities of the body.
Attributes:
The list of actuators associated with this body.
The base link of this body.
The floating base object.
Whether the body is a mocap (kinematic) body.
Convert this body to a mocap object if it is a mocap body.
The name of the body.
The number of actuators associated with this body.
The number of DoF positions of all joints on the body.
The number of DoF velocities of all joints on the body.
The number of joints that belong to this body.
The number of links that belong to this body.
- get_dof_pos_indices(include_floatingbase=True)#
Get the indices of the DoF positions of the body.
- 参数:
include_floatingbase (bool) -- Whether to include the floating base DoF positions indices. If False, only the joint DoF positions indices are returned.
- 返回:
- The DoF position indices. if include_floatingbase is true, shape =
(
num_joint_dof_pos()+ 6,), else shape = (num_joint_dof_pos(),).
- 返回类型:
NDArray[int]
- get_dof_vel_indices(include_floatingbase=True)#
Get the indices of the DoF velocities of the body.
- 参数:
include_floatingbase (bool) -- Whether to include the floating base DoF velocities indices. If False, only the joint DoF velocities indices are returned.
- 返回:
- The DoF velocity indices. if include_floatingbase is true, shape =
(
num_joint_dof_vel()+ 6,), else shape = (num_joint_dof_vel(),).
- 返回类型:
NDArray[int]
- get_joint_dof_pos(data)#
Get the DoF positions of all joints on the body.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The DoF positions. shape = (*data.shape,
num_joint_dof_pos()).- 返回类型:
NDArray[float]
备注
If the body has floating base, the floating base DoF positions are NOT included.
- get_joint_dof_vel(data)#
Get the DoF velocities of all joints on the body.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
- The DoF velocities. shape = (*data.shape,:meth:
body.num_joint_dof_vel).
- 返回类型:
NDArray[float]
备注
If the body has floating base, the floating base DoF velocities are NOT included.
- get_pose(data)#
Get the world pose of the body.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
shape = (*data.shape, 7). Each pose is a 7-element array with [x, y, z, i, j, k, w].
- 返回类型:
NDArray[float]
- get_position(data)#
Get the world position of the body.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
shape = (*data.shape, 3).
- 返回类型:
NDArray[float]
- get_rotation(data)#
Get the world rotation of the body as a quaternion.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
shape = (*data.shape, 4). Each rotation is a 4-element array with [i, j, k, w].
- 返回类型:
NDArray[float]
- get_rotation_mat(data)#
Get the world rotation of the body as a rotation matrix.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
shape = (*data.shape, 3, 3).
- 返回类型:
NDArray[float]
- set_actuator_ctrls(data, ctrls)#
Set the control values for all actuators on this body.
- 参数:
data (SceneData) -- The scene data to modify.
ctrls (NDArray[float]) -- The control values to set. Shape = (len(body.actuators),). If the data has batch dimension, ctrls must have the same shape as the data.
备注
The number of control values must match the number of actuators on the body. Use body.actuators to get the list of actuators and their count.
示例
For a body with 3 actuators:
` body.set_actuator_ctrls(data, [1.0, 0.5, -0.3]) # Set controls for all 3 actuators `
- set_dof_pos(data, dof_pos, include_floatingbase=True)#
Set the DoF positions of the body.
- 参数:
data (SceneData) -- The scene data to modify.
dof_pos (NDArray[float]) -- The DoF positions to set. Shape = (num_joint_dof_pos + 7,) if include_floatingbase is True, else shape = (num_joint_dof_pos,).
include_floatingbase (bool) -- Whether the provided dof_pos includes the floating base DoF positions. If True, the first 7 elements of dof_pos are treated as the floating base DoF positions.
- set_dof_vel(data, dof_vel, include_floatingbase=True)#
Set the DoF velocities of the body.
- 参数:
data (SceneData) -- The scene data to modify.
dof_vel (NDArray[float]) -- The DoF velocities to set. Shape = (
num_joint_dof_vel()+ 6,) if include_floatingbase is True, else shape =(num_joint_dof_vel(),).include_floatingbase (bool) -- Whether the provided dof_vel includes the floating base DoF velocities. If True, the first 6 elements of dof_vel are treated as the floating base DoF velocities.
- actuators#
The list of actuators associated with this body.
Returns an empty list if the body has no actuators.
备注
Actuators are associated with a body through the joints on the body. Each actuator targets a specific joint, and this method returns all actuators that target joints belonging to this body.
- Type:
List[Actuator]
- floatingbase#
The floating base object.
Return None if not present.
备注
In mjcf, a body is free moving if it has <freejoint>
- Type:
Optional[FloatingBase]
- index#
- is_mocap#
Whether the body is a mocap (kinematic) body.
Return True if the body has no joints and fixed to the world, False otherwise.
- Type:
bool
- mocap#
Convert this body to a mocap object if it is a mocap body.
- 返回:
The mocap object if this body is a mocap, None otherwise.
- 返回类型:
Optional[PyMocap]
- model#
- name#
The name of the body.
Return None if not present.
- Type:
Optional[str]
- num_actuators#
The number of actuators associated with this body.
- Type:
int
- num_joint_dof_pos#
The number of DoF positions of all joints on the body.
备注
If the body has floating base, the floating base DoF positions are NOT included
- Type:
int
- num_joint_dof_vel#
The number of DoF velocities of all joints on the body.
备注
If the body has floating base, the floating base DoF velocities are NOT included
- Type:
int
- num_joints#
The number of joints that belong to this body.
备注
The <freejoint> is not counted as a joint in motrixsim but a floating base.
- Type:
int
- num_links#
The number of links that belong to this body.
- Type:
int
- class motrixsim.Camera#
基类:
objectThe Camera object in the scene.
Methods:
get_pose(data)Get the world pose of the camera.
set_near_far(near, far)Set the near and far plane of the camera.
set_render_target(target[, w, h])Set the render target of the camera.
Attributes:
Whether the camera is in depth-only mode.
Get the far plane distance of the camera.
Get the vertical field of view of the camera in degrees.
The index of the camera in the
motrixsim.SceneModel.cameras().Get the link that this camera is attached to.
The scene model that this camera belongs to.
Get the name of the camera.
Get the far plane distance of the camera.
Get or set the position track mode of the camera.
Get the render target of the camera, either "window" or "image".
Get or set the rotation track mode of the camera.
Get or set the link that the camera looks at.
- get_pose(data)#
Get the world pose of the camera.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
- shape = (*data.shape, 7). Each pose is represented as a 7 elements
array with [x, y, z, qx, qy, qz,qw] format.
- 返回类型:
NDArray[float]
- set_near_far(near, far)#
Set the near and far plane of the camera.
- 参数:
near (float) -- The near plane distance. Must be positive.
far (float) -- The far plane distance. Must be larger than near.
- set_render_target(target, w=400, h=300)#
Set the render target of the camera.
- 参数:
target (str) -- The render target, either "window" or "image".
w (int) -- The width of the image if the target is "image". ignored if the target is
"window".
h (int) -- The height of the image if the target is "image". ignored if the target is
"window".
备注
This method must be called before you launch the render application.
- depth_only#
Whether the camera is in depth-only mode.
备注
This attribute must be set before you launch the render application.
- Type:
bool
- far_plane#
Get the far plane distance of the camera.
- Type:
float
- fovy#
Get the vertical field of view of the camera in degrees.
- Type:
float
- index#
The index of the camera in the
motrixsim.SceneModel.cameras().- Type:
int
- link#
Get the link that this camera is attached to.
备注
Returns None if the camera is not attached to any link (i.e., it's a world space camera).
- Type:
Optional[Link]
- model#
The scene model that this camera belongs to.
- Type:
- name#
Get the name of the camera.
- Type:
Option[str]
- near_plane#
Get the far plane distance of the camera.
- Type:
float
- position_track#
Get or set the position track mode of the camera.
Possible values are:
"free": Free to move in all directions.
"fixed_local": Fixed the relative position to parent in local frame.
"fixed_world": Fixed the relative position to parent in world frame.
- Type:
str
- render_target#
Get the render target of the camera, either "window" or "image".
- Type:
str
- rotation_track#
Get or set the rotation track mode of the camera.
Possible values are:
"free": Free to rotate.
"fixed_local": Fixed the relative rotation to parent in local frame.
"fixed_world": Fixed the relative rotation to parent in world frame.
"look_at_link": Always look at the target link. This mode requires setting the track_target_link attribute.
- Type:
str
- class motrixsim.CameraMgr#
基类:
objectMethods:
__getitem__(key, /)Return self[key].
get_index(name)Get the camera index by name.
tolist()Convert the camera manager to a list of cameras.
Attributes:
All the cameras defined in the model.
The scene model that this camera manager belongs to.
- __getitem__(key, /)#
Return self[key].
- get_index(name)#
Get the camera index by name.
- 参数:
name (str) -- The name of the camera.
- 返回:
The index of the camera.
- 返回类型:
int
- Panics:
If the camera name does not exist.
- tolist()#
Convert the camera manager to a list of cameras.
- model#
The scene model that this camera manager belongs to.
- Type:
- class motrixsim.ContactQuery#
基类:
objectMethods:
is_colliding(geom_pairs)Given a list of geometry pairs, check if they are colliding.
Attributes:
The number of contacts in the world.
- is_colliding(geom_pairs)#
Given a list of geometry pairs, check if they are colliding.
- 参数:
geom_pairs (NDArray[u32]) -- Pairs of geometry indices to check for collision. Shape = (N, 2) where N is the number of pairs.
- 返回:
Array of booleans indicating whether each pair is colliding.
- 返回类型:
NDArray[bool]
- num_contacts#
The number of contacts in the world.
- Type:
int
- class motrixsim.DisjointIndices(indices)#
基类:
objectAttributes:
The number of elements in the disjoint index set.
- size#
The number of elements in the disjoint index set. Alias to len(set).
- class motrixsim.FloatingBase#
基类:
objectThe FloatingBase object represents a floating base in the scene.
This class provides access to the properties and state of a floating base in the scene. It allows you to retrieve information about the base's name, DoF velocities and positions, and to set its world translation and rotation.
Methods:
get_dof_pos(data)Get the DoF positions of the floating base.
get_dof_vel(data)Get the DoF velocities of the floating base.
Extract the world angular velocity of the floating base from the dof velocity array.
Extract the world linear velocity of the floating base from the dof velocity array.
Extract the local angular velocity of the floating base from the dof velocity array.
get_rotation(data)Extract the world rotation of the floating base from the dof position array.
get_translation(data)Extract the world translation of the floating base from the dof position array.
set_global_angular_velocity(data, vel)Set the global angular velocity of the floating base to dof velocity array directly.
set_global_linear_velocity(data, vel)Set the global linear velocity of the floating base to dof velocity array directly.
set_local_angular_velocity(data, vel)Set the local angular velocity of the floating base to dof velocity array directly.
set_rotation(data, quat)Set the world rotation of the floating base.
set_translation(data, translation)Set the world translation of the floating base.
Attributes:
The DoF position indices of the floating base.
The DoF position address of the floating base in the
motrixsim.SceneData.dof_pos().The DoF velocity indices of the floating base.
The DoF velocity address of the floating base in the
motrixsim.SceneData.dof_vel().The index of the floatingbase in the
motrixsim.SceneModel.floating_bases().The scene model this floating base belongs to.
The name of the floating base.
- get_dof_pos(data)#
Get the DoF positions of the floating base.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The DoF positions with (x,y,z, i,j,k,w) format. shape = (data.shape, 7).
- 返回类型:
NDArray[float]
- get_dof_vel(data)#
Get the DoF velocities of the floating base.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The DoF velocities with (vx,vy,vz wx,wy,wz) format. shape = (data.shape, 6).
- 返回类型:
NDArray[float]
- get_global_angular_velocity(data)#
Extract the world angular velocity of the floating base from the dof velocity array.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The world angular velocity. shape = (data.shape, 3)
- 返回类型:
NDArray[float]
- get_global_linear_velocity(data)#
Extract the world linear velocity of the floating base from the dof velocity array.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The world linear velocity. shape = (data.shape, 3)
- 返回类型:
NDArray[float]
- get_local_angular_velocity(data)#
Extract the local angular velocity of the floating base from the dof velocity array.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The local angular velocity. shape = (data.shape, 3)
- 返回类型:
NDArray(float)
- get_rotation(data)#
Extract the world rotation of the floating base from the dof position array.
- 参数:
data (SceneData) -- The scene data.
- 返回:
A quaternion representing the rotation in the format [i, j, k, w].
- 返回类型:
NDArray[float]
- get_translation(data)#
Extract the world translation of the floating base from the dof position array.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The world translation. shape = (data.shape, 3)
- 返回类型:
NDArray[float]
- set_global_angular_velocity(data, vel)#
Set the global angular velocity of the floating base to dof velocity array directly.
- 参数:
data (SceneData) -- The scene data to store the velocity.
vel (ArrayLink[float]) -- The global angular velocity to set. shape = (data.shape, 3)
备注
This method only updates the dof velocity array.
- set_global_linear_velocity(data, vel)#
Set the global linear velocity of the floating base to dof velocity array directly.
- 参数:
data (SceneData) -- The scene data to store the velocity.
vel (ArrayLink[float]) -- The world linear velocity to set. shape = (data.shape, 3)
备注
This method only updates the dof velocity array.
- set_local_angular_velocity(data, vel)#
Set the local angular velocity of the floating base to dof velocity array directly.
- 参数:
data (SceneData) -- The scene data to store the velocity.
vel (ArrayLink(float)) -- The local angular velocity, shape = (data.shape, 3).
备注
This method only updates the dof velocity array.
- set_rotation(data, quat)#
Set the world rotation of the floating base.
- 参数:
data (SceneData) -- The scene data to store the rotation.
quat (NDArray[float]) -- The quaternion [i, j, k, w]. shape = (data.shape, 4).
备注
This function only updates the DoF position of the floating base. The actual rotation is updated through the forward kinematic phase.
- set_translation(data, translation)#
Set the world translation of the floating base.
- 参数:
data (SceneData) -- The scene data to store the translation.
translation (NDArray[float]) -- The translation [x, y, z]. shape = (data.shape, 3).
备注
This function only updates the DoF position of the floating base. The actual translation of links is updated through the forward kinematic phase.
- dof_pos_indices#
The DoF position indices of the floating base. size = 7.
- Type:
List[int]
- dof_pos_start#
The DoF position address of the floating base in the
motrixsim.SceneData.dof_pos().- Type:
int
- dof_vel_indices#
The DoF velocity indices of the floating base. size = 6.
- Type:
List[int]
- dof_vel_start#
The DoF velocity address of the floating base in the
motrixsim.SceneData.dof_vel().- Type:
int
- index#
The index of the floatingbase in the
motrixsim.SceneModel.floating_bases().- Type:
int
- model#
The scene model this floating base belongs to.
- Type:
- name#
The name of the floating base.
Return None if not set.
- Type:
Optional[str]
- class motrixsim.Geom#
基类:
objectThe Geom object represents a geometry in the scene.
This class provides access to the properties and state of a geometry in the scene. It allows you to retrieve information about the geom and colliders belong to it.
Methods:
get_angular_velocity(data)Get the world angular velocity of the geom.
get_linear_velocity(data)Get the world linear velocity of the geom.
get_pose(data)Get the world pose of the geom.
Attributes:
The collision affinity of the geom.
The collision group of the geom.
The contact gap of the geom.
The height field associated with this geom, if the shape type is HField.
The index of the geom in the
motrixsim.SceneModel.geoms().The local pose of the geom relative to its parent link or world.
The contact margin of the geom.
The scene model that this geom belongs to.
The name of the geom.
The shape type of the geom.
The size parameters of the geom.
- get_angular_velocity(data)#
Get the world angular velocity of the geom.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
- shape = (*data.shape, 3). The last axis is the angular velocity with
[wx, wy, wz] format.
- 返回类型:
NDArray[float]
- get_linear_velocity(data)#
Get the world linear velocity of the geom.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
- shape = (*data.shape, 3). The last axis is the linear velocity with
[vx, vy, vz] format.
- 返回类型:
NDArray[float]
- get_pose(data)#
Get the world pose of the geom.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
- shape = (*data.shape, 7). Each pose is represented as a 7 elements
with [x, y, z, i, j, k, w] format.
- 返回类型:
NDArray[float]
- collision_affinity#
The collision affinity of the geom.
- 返回:
The collision affinity mask.
- 返回类型:
int
备注
The collision affinity (also called collide_with) is a bitmask that specifies which collision groups this geom can collide with. Two geoms will collide if (geom1.collision_group & geom2.collision_affinity) != 0 or (geom1.collision_affinity & geom2.collision_group) != 0.
- collision_group#
The collision group of the geom.
- 返回:
The collision group identifier.
- 返回类型:
int
备注
The collision group is used to filter which geometries can collide with each other. Two geoms will collide if (geom1.collision_group & geom2.collision_affinity) != 0 or (geom1.collision_affinity & geom2.collision_group) != 0.
- gap#
The contact gap of the geom.
- 返回:
The distance band that determines which contacts generate solver constraints.
- 返回类型:
float
备注
The gap controls the distance threshold for generating solver constraints. Contacts within this distance will generate constraints in the physics solver. This can be tuned to balance stability and performance.
- hfield#
The height field associated with this geom, if the shape type is HField.
- 返回:
- The HField object if this geom's shape is HField and has an associated
height field, otherwise None.
- 返回类型:
Optional[HField]
备注
- This property only returns a valid HField object when:
The geom's shape type is Shape.HField
The geom has an associated height field name
For all other shape types, this returns None. Height fields are used to represent terrain and elevation data for ground interactions and surface-based physics.
- index#
The index of the geom in the
motrixsim.SceneModel.geoms().- Type:
int
- local_pose#
The local pose of the geom relative to its parent link or world.
- 返回:
- The local pose as a numpy array of shape (7,)
with [x, y, z, i, j, k, w] format where the first 3 elements are translation and the last 4 are quaternion rotation.
- 返回类型:
NDArray[float]
备注
The local pose represents the position and orientation of the geom in its parent frame. If the geom is attached to a link, this is relative to that link's frame. If the geom is a world geom (no parent link), this is in world coordinates.
- margin#
The contact margin of the geom.
- 返回:
The distance threshold for detecting contacts.
- 返回类型:
float
备注
The margin is used to control when contact constraints are generated. A larger margin will detect contacts earlier, potentially improving stability but may also increase computational cost.
- model#
The scene model that this geom belongs to.
- Type:
- name#
The name of the geom. Must be unique within the scene.
- 返回:
The name of the geom, or "None" if not set.
- 返回类型:
Optional[str]
- shape#
The shape type of the geom.
- 返回:
The shape type of the geom.
- 返回类型:
备注
The shape type determines the geometric representation of the geom. Possible values include: Sphere, Cylinder, Capsule, Cuboid, InfinitePlane, HField, Mesh, and Plane. Each shape type has different parameters and uses in simulation and collision detection.
- size#
The size parameters of the geom.
- 返回:
- The size parameters as a numpy array of shape (3,)
with [s0, s1, s2].
- 返回类型:
NDArray[float]
备注
- The size represents half-size parameters for different shape types:
Sphere: [radius, 0.0, 0.0] - spherical radius
Capsule: [radius, half_height, 0.0] - radius and half-height
Cylinder: [radius, half_height, 0.0] - radius and half-height
Cuboid: [half_x, half_y, half_z] - half-extents in each axis
Plane: [half_x, half_y, 0.0] - half-extents in x and y directions
Mesh/HField/InfinitePlane: [0.0, 0.0, 0.0] - size is ignored for these types
When a primitive shape references a mesh file, the size is automatically computed from the mesh geometry and the geom size parameters are ignored.
- class motrixsim.HField#
基类:
objectThe HField object represents a height field terrain in the scene.
This class provides access to height field (terrain) data used for ground interactions, terrain following, and surface-based physics. Height fields provide an efficient way to represent large terrain surfaces with elevation data.
Methods:
get(row, col)Get the height value at the specified row and column.
Attributes:
Get the bounding box of the height field in local space.
Get the height matrix data as a numpy array.
The index of the hfield in the scene.
The scene model that this hfield belongs to.
The name of the hfield.
The number of columns in the height field grid.
The number of rows in the height field grid.
- get(row, col)#
Get the height value at the specified row and column.
- 参数:
row (int) -- The row index (0-based).
col (int) -- The column index (0-based).
- 返回:
The height value at the specified grid cell.
- 返回类型:
float
- bound#
Get the bounding box of the height field in local space.
- 返回:
- A 1D numpy array of shape (6,) representing the bounding box
in the format [-extent_x, -extent_y, 0, extent_x, extent_y, size_z].
- 返回类型:
NDArray[float]
- height_matrix#
Get the height matrix data as a numpy array.
备注
The returned array is a copy of the internal data. Modifying it will not affect the hfield.
- 返回:
A 2D numpy array of shape (nrow, ncol) containing the height values.
- 返回类型:
NDArray[float]
- index#
The index of the hfield in the scene.
- Type:
int
- model#
The scene model that this hfield belongs to.
- Type:
- name#
The name of the hfield. Must be unique within the scene.
- 返回:
The name of the hfield, or "None" if not set.
- 返回类型:
Optional[str]
- ncol#
The number of columns in the height field grid.
- Type:
int
- nrow#
The number of rows in the height field grid.
- Type:
int
- class motrixsim.Joint#
基类:
objectThe Joint object represents a joint in the scene.
This class provides access to the properties and state of a joint in the scene. It allows you to retrieve information about the joint's name, link index, number of DoF velocities and positions, and DoF velocity and position addresses.
Methods:
get_dof_pos(data)Get the DoF positions of the joint.
get_dof_vel(data)Get the DoF velocities of the joint.
set_dof_pos(data, position)Set the DoF positions of the joint.
set_dof_vel(data, velocity)Set the DoF velocities of the joint.
Attributes:
The motion axis of the joint.
The position DoF address of the joint.
The velocity DoF address of the joint.
The index of the joint in the
motrixsim.SceneModel.joints().The link this joint is attached to.
The index of the link this joint is attached to.
The scene model this joint belongs to.
The name of the joint.
The number of position DoFs of the joint.
The number of velocity DoFs of the joint.
The range limits of the joint.
- get_dof_pos(data)#
Get the DoF positions of the joint.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The DoF positions. shape = (data.shape,
num_dof_pos())- 返回类型:
NDArray[float]
- get_dof_vel(data)#
Get the DoF velocities of the joint.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The DoF velocities. shape = (data.shape,
num_dof_vel())- 返回类型:
NDArray[float]
- set_dof_pos(data, position)#
Set the DoF positions of the joint.
- 参数:
data (SceneData) -- The scene data to store the new positions.
position (NDArray[float]) -- The new DoF positions. shape = (data.shape,
num_dof_pos())
- set_dof_vel(data, velocity)#
Set the DoF velocities of the joint.
- 参数:
data (SceneData) -- The scene data to store the new velocities.
velocity (NDArray[float]) -- The new DoF velocities. shape = (data.shape,
num_dof_vel())
- axis#
The motion axis of the joint.
Returns a 3-element array representing the motion axis of the joint in the successor body coordinate frame. This is primarily used for hinge and slide joints.
备注
The axis is normalized automatically when the joint is created. For spherical joints, the axis concept doesn't apply in the same way as they have full rotational freedom.
示例
>>> joint.axis array([0., 0., 1.]) # Hinge joint rotating around Z-axis array([1., 0., 0.]) # Slide joint moving along X-axis
- Type:
NDArray[float]
- dof_pos_index#
The position DoF address of the joint.
Return the starting index of the position DoFs.
- Type:
int
- dof_vel_index#
The velocity DoF address of the joint.
Return the starting index of the velocity DoFs.
- Type:
int
- index#
The index of the joint in the
motrixsim.SceneModel.joints().- Type:
int
- link_index#
The index of the link this joint is attached to.
- Type:
int
- model#
The scene model this joint belongs to.
- Type:
- name#
The name of the joint.
Return the name of the joint, or None if not set.
- Type:
Optional[str]
- num_dof_pos#
The number of position DoFs of the joint.
- Type:
int
- num_dof_vel#
The number of velocity DoFs of the joint.
- Type:
int
- range#
The range limits of the joint.
Returns a 2-element array containing the lower and upper bounds of the joint range. Array format: [lower_bound, upper_bound] If the joint has no limits, returns [f32::NEG_INFINITY, f32::INFINITY].
示例
>>> joint.range array([[-1.57, 1.57]]) # Hinge joint with ±π/2 limits
- Type:
NDArray[float]
- class motrixsim.Keyframe#
基类:
objectThe Keyframe object represents a keyframe in the scene.
This class provides access to the properties of a keyframe, including its name, simulation time, joint positions, velocities, and control values.
Methods:
apply(data)Apply the keyframe to scene data.
Attributes:
The actuator control values of the keyframe.
The dof positions of the keyframe.
The joint velocities of the keyframe.
The index of the keyframe in the keyframe list.
The scene model this keyframe belongs to.
The name of the keyframe, or None if not set.
The simulation time of the keyframe, or None if not set.
- apply(data)#
Apply the keyframe to scene data.
- 参数:
data (SceneData) -- Scene data to apply the keyframe to.
备注
This method does NOT automatically call forward_kinematic. Users should call model.forward_kinematic(data) after applying the keyframe if they need to update the scene transforms (e.g., for visualization or getting correct link poses).
示例
model = motrixsim.load_model("scene.xml") data = motrixsim.SceneData(model) # Apply first keyframe model.keyframes[0].apply(data) model.forward_kinematic(data)
- ctrl#
The actuator control values of the keyframe.
Returns a numpy array with shape (num_actuators,) containing the actuator control values for all actuators in the scene.
- Type:
NDArray[float]
- dof_pos#
The dof positions of the keyframe.
Returns a numpy array with shape (num_dof_pos,) containing the dof positions for all degrees of freedom in the scene.
- Type:
NDArray[float]
- dof_vel#
The joint velocities of the keyframe.
Returns a numpy array with shape (num_dof_vel,) containing the joint velocities for all degrees of freedom in the scene.
- Type:
NDArray[float]
- index#
The index of the keyframe in the keyframe list.
- Type:
int
- model#
The scene model this keyframe belongs to.
- Type:
- name#
The name of the keyframe, or None if not set.
- Type:
Optional[str]
- time#
The simulation time of the keyframe, or None if not set.
- Type:
float
- class motrixsim.Link#
基类:
objectThe Link object represents a kinematic link in the scene.
This class provides access to the properties and state of a kinematic link in the scene. It allows you to retrieve information about the link's name, index, joint indices, number of joints, and the joints associated with the link.
Methods:
add_external_force(data, force[, point, local])Add an external force to the link.
add_external_torque(data, torque[, local])Add an external torque to the link.
get_angular_velocity(data)Get the world angular velocity of the link.
Get the center of mass override of the link in the link local frame.
get_joint(index)Get the joint at the specified index if the link has multiple joints.
get_linear_velocity(data)Get the world linear velocity of the link.
get_mass_override(data)Get the overrided mass of the link in the scene data.
get_pose(data)Get the world pose of the link.
get_position(data)Get the world position of the link.
get_rotation(data)Get the world rotation of the link as a quaternion (i, j, k, w).
get_rotation_mat(data)Get the world rotation matrix of the link.
joints()The joints associated with this link.
set_center_of_mass_override(data, center_of_mass)Override the center of mass of the link.
set_mass_override(data, mass)Override the mass of the link.
Attributes:
Get the center of mass of the link in the link local frame.
The index of the link in the
motrixsim.SceneModel.links().The joint indices of this link in the
motrixsim.SceneModel.joints().Get the mass of the link in the model.
The scene model that this link belongs to.
The name of the link.
The number of joints associated with this link.
- add_external_force(data, force, point=None, local=True)#
Add an external force to the link.
- 参数:
data (SceneData) -- The scene data to modify.
force (NDArray[float]) -- The force vector. - Shape (*data.shape, 3): Per-batch force vectors
point (NDArray[float], optional) -- Application point. - Shape (*data.shape, 3): Per-batch points
local (bool) -- Whether the force and point are in local coordinates. Default: True.
备注
The force is applied at the specified point in link coordinates. If point is None, force is applied at the link's center of mass. Forces applied to mocap-type links will be ignored.
- add_external_torque(data, torque, local=True)#
Add an external torque to the link.
- 参数:
备注
Torques applied to mocap-type links will be ignored.
- get_angular_velocity(data)#
Get the world angular velocity of the link.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
- shape = (*data.shape, 3). The last axis is the angular velocity with
[wx, wy, wz] format.
- 返回类型:
NDArray[float]
- get_center_of_mass_override(data)#
Get the center of mass override of the link in the link local frame.
- get_joint(index)#
Get the joint at the specified index if the link has multiple joints.
- 参数:
index (int) -- The local index of the joint.
- 返回:
The joint object, or "None" if not found.
- 返回类型:
Optional[Joint]
- get_linear_velocity(data)#
Get the world linear velocity of the link.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
- shape = (*data.shape, 3). The last axis is the linear velocity with
[vx, vy, vz] format.
- 返回类型:
NDArray[float]
- get_mass_override(data)#
Get the overrided mass of the link in the scene data.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
shape = (1,). The mass override value.
- 返回类型:
NDArray[float]
- get_pose(data)#
Get the world pose of the link.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
- shape = (*data.shape, 7). Each pose is represented as a 7 elements
with [x, y, z, i, j, k, w] format.
- 返回类型:
NDArray[float]
- get_position(data)#
Get the world position of the link.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
shape = (*data.shape, 3).
- 返回类型:
NDArray[float]
- get_rotation(data)#
Get the world rotation of the link as a quaternion (i, j, k, w).
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
A numpy array with shape (*data.shape, 4).
- 返回类型:
NDArray[float]
- get_rotation_mat(data)#
Get the world rotation matrix of the link.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
A numpy array with shape (*data.shape, 3, 3).
- 返回类型:
NDArray[float]
- set_center_of_mass_override(data, center_of_mass)#
Override the center of mass of the link.
- 参数:
备注
If the center_of_mass components are not finite (NaN or infinity), or the link is mocap type, or the link is fixed to world, the override will be ignored.
- set_mass_override(data, mass)#
Override the mass of the link.
- 参数:
备注
If the mass is non-positive or the link is mocap type, or the link is fixed to world, the override will be ignored.
- center_of_mass#
Get the center of mass of the link in the link local frame.
- 返回:
shape = (3,). The center of mass position
- 返回类型:
NDArray[float]
- index#
The index of the link in the
motrixsim.SceneModel.links().- Type:
int
- joint_indices#
The joint indices of this link in the
motrixsim.SceneModel.joints().- 返回:
The size of the list must be equal to
num_joints()- 返回类型:
List[int]
- mass#
Get the mass of the link in the model.
- 返回:
The mass of the link.
- 返回类型:
Real
- model#
The scene model that this link belongs to.
- Type:
- name#
The name of the link. Must be unique within the scene.
- 返回:
The name of the link, or "None" if not set.
- 返回类型:
Optional[str]
- num_joints#
The number of joints associated with this link.
- 返回:
number of joints associated with this link.
- 返回类型:
int
- class motrixsim.Mocap#
基类:
objectThe Mocap object represents a motion capture body in the scene. it can will participate in the collision and apply force to other bodies, but will not be affected by the physics simulation.
Methods:
set_pose(data, pose)Set the pose of the mocap.
Attributes:
- set_pose(data, pose)#
Set the pose of the mocap.
- 参数:
data (SceneData) -- The scene data to store the pose.
pose (NDArray[float]) -- The pose to set, as a 7-element array (x, y, z, qx, qy, qz, qw). shape = (data.shape,7)
- model#
The scene model this mocap belongs to.
- Type:
- class motrixsim.Options#
基类:
objectThe Options object represents the simulation options.
This class is used to configure the simulation options. You can access it through model.options.
Attributes:
Is all contact constraints disabled in the simulation?
Is the gravity disabled in the simulation?
The gravity vector applied to the simulation.
The maximum number of iterations for the solver.
The tolerance for the solver.
The delta time for each simulation step.
- disable_contacts#
Is all contact constraints disabled in the simulation?
- Type:
bool
- disable_gravity#
Is the gravity disabled in the simulation?
- Type:
bool
- gravity#
The gravity vector applied to the simulation.
A numpy array of shape (3,) or a list of three floats representing the gravity vector.
- Type:
NDArray[float]
- max_iterations#
The maximum number of iterations for the solver.
- 抛出:
ValueError -- The set max iterations is zero.
- Type:
int
- solver_tolerance#
The tolerance for the solver.
- 抛出:
ValueError -- The set tolerance is not positive.
- Type:
float
- timestep#
The delta time for each simulation step.
- 抛出:
ValueError -- The set timestep is not positive.
- Type:
float
- class motrixsim.SceneData(model, batch=Ellipsis)#
基类:
objectThe SceneData object represents the simulation state.
This class provides access to the dynamic state of the simulation, including joint positions, velocities, and other runtime data. Users can query or modify the simulation state, reset the scene to its initial state, and access low-level simulation data for advanced use cases. The state can be accessed via properties such as qpos, qvel, and via methods like reset(). For advanced control, the low property exposes the low-level data object.
Methods:
__getitem__(key, /)Return self[key].
get(index)Get sub-data by index.
reset(model)Reset the scene data with the given model.
set_dof_pos(dof_pos, model)Set the dof position for the whole world data.
set_dof_vel(dof_vel)Set the dof velocity for the whole world data.
Attributes:
The all the actuator control values.
The dof position array of the world.
The dof velocity array of the world.
The low-level data object for advanced simulation control.
The number of dimensions of the data.
The shape of the data.
- __getitem__(key, /)#
Return self[key].
- get(index)#
Get sub-data by index. Alias to __getitem__
- 参数:
index (int | ndarray[bool] | DisjointIndices) -- The index to select. Following types are
- supported:
int: Select a single element. Raise error if the data has no batch dimension.
ndarray[bool]: Select multiple elements based on a boolean mask.
DisjointIndices: Select multiple non-contiguous elements.
- reset(model)#
Reset the scene data with the given model.
Reinitializes all simulation state variables using the provided model.
- 参数:
model (SceneModel) -- The scene model to reset the data with.
- set_dof_pos(dof_pos, model)#
Set the dof position for the whole world data.
- 参数:
dof_pos (NDArray[float]) -- The dof position array to set. if shape = (*data.shape, num_dof_pos), each data will use the corresponding slice. if shape = (num_dof_pos,), all data will use the same dof position.
model (SceneModel) -- The scene model to validate the dof position.
- 抛出:
Exception -- When the dof position data is invalid.(e.g. quaternion not normalized)
备注
- The dof_pos array must follow the same format as the getter method:
Floating base/free body: 7 elements [tx, ty, tz, qx, qy, qz, qw]
Ball joint: 4 elements [qx, qy, qz, qw] for quaternion rotation
Hinge joint: 1 element for angular position
Slide joint: 1 element for linear position
Elements should be concatenated in
order:[floating_base_dofs...,joint1_dofs...,joint2_dofs...,...]
- set_dof_vel(dof_vel)#
Set the dof velocity for the whole world data.
- 参数:
dof_vel (NDArray[float]) -- The dof velocity array to set. shape = (*data.shape, num_dof_vel).
- actuator_ctrls#
The all the actuator control values. (Get&Set)
Array of actuator control values. shape = (*data.shape, num_ctrls).
备注
If the model is created from MJCF, the order of the control values matches the order of actuators in the MJCF file.
- 抛出:
TypeError -- When the shape of the setted values is not invalid.
- Type:
NDArray[float]
- dof_pos#
The dof position array of the world.
Array of DoF positions. shape = (*data.shape, num_dof_pos)
备注
The dof_pos array contains position coordinates for all degrees of freedom in the simulation, with format varying by joint type:
Floating base/free body: 7 elements [tx, ty, tz, qx, qy, qz, qw]
Ball joint: 4 elements [qx, qy, qz, qw] for quaternion rotation
Hinge joint: 1 element for angular position
Slide joint: 1 element for linear position
Elements are concatenated in order: [floating_base_dofs...,joint1_dofs...,joint2_dofs..., ...]
- Type:
NDArray[float]
- dof_vel#
The dof velocity array of the world.
Array of DoF velocities. shape = (*data.shape, num_dof_vel)
- Type:
NDArray[float]
- low#
The low-level data object for advanced simulation control.
备注
Only modify the low-level data if you understand the implications. Incorrect modifications may lead to unstable simulation behavior.
- Type:
LowData
- ndim#
The number of dimensions of the data.
- Type:
int
- shape#
The shape of the data.
If the data is batched, the shape is (batch_size,). If not batched, the shape is ().
- Type:
Tuple[int]
- class motrixsim.SceneModel#
基类:
objectThe SceneModel object represents the entire simulation world.
This class provides a high-level interface to access and manipulate the simulation world model, including all bodies, joints, actuators, links, and sites. Users can query the scene structure and configuration, modify simulation options, and access components through properties (joints, options) or methods (get_body(), get_sensor_values()).
Methods:
Compute the initial DoF positions for the world.
forward_kinematic(data)Perform forward kinematic calculations using the current model and data.
get_actuator(arg)Get an actuator by name or index.
get_actuator_ctrls(data)Alias to
SceneData.actuator_ctrls()get_actuator_index(name)Get actuator index by its name.
get_body(key)Get a body by name or index.
get_body_index(name)Get the body index by its name.
get_camera_poses(data)Get the world poses of all cameras.
get_contact_query(data)Get a contact query object for the current model and data.
get_geom(arg)Get a geom by name or index.
get_geom_index(name)Get the geometry index by its name.
get_hfield(arg)Get an hfield by name or index.
get_hfield_index(name)Get hfield index by its name.
get_joint(key)Get a joint by name or index.
get_joint_index(name)Get the joint index by its name.
get_link(arg)Get a link by name or index.
get_link_index(name)Get the link index by its name.
get_link_poses(data)Get the world poses of all links.
get_link_rotation_mats(data)Get all link rotation matrices.
get_sensor_value(id, data)Get the value of a specific sensor by its ID.
get_site(key)Get a site by name or index.
get_site_index(name)Get site index by name.
step(data)Advance the simulation by one step using the current model and data.
step_n(data, n)Advance the simulation by n steps using the current model and data.
Attributes:
The actuator control ranges.
The list of actuator names in the world.
Get all actuators defined in the model.
The list of all bodies in the world.
The list of all body names in the world.
The camera manager for accessing cameras by name.
The list of all floating bases in the world.
The list of all geoms names in the world.
The list of all geoms in the world.
The start dof index for each joint in the dof positions array.
The number of DoF positions for each joint.
The start dof index for each joint in the dof velocities array.
The size of DoF velocities of each joint.
The joint position limits for each joint.
The list of all joint names in the world.
The list of all joints in the world.
The list of all keyframes in the model.
The list of all link names in the world.
The list of all links in the world.
The low-level model for advanced or internal simulation access.
The number of actuators in the world.
The number of bodies in the world.
The number of DoF positions in the world.
The number of DoF velocities in the world.
The number of geoms in the world.
The number of height fields in the world.
The number of joints in the world.
The number of keyframes in the model.
The number of links in the world.
The number of sensors in the world.
The number of sites in the world.
The simulation options of the model.
The list of all site names in the world.
The list of all sites in the world.
- compute_init_dof_pos()#
Compute the initial DoF positions for the world.
- 返回:
shape=(num_dof_pos,). Initial DoF positions.
- 返回类型:
NDArray[float]
- forward_kinematic(data)#
Perform forward kinematic calculations using the current model and data.
备注
This method only updates the world poses of all links and bodies based on the current joint positions.
- get_actuator(arg)#
Get an actuator by name or index.
- 参数:
key (str or int) -- Name or index of the actuator.
- 返回:
The actuator object, or None if not found.
- 返回类型:
Optional[Actuator]
- get_actuator_ctrls(data)#
Alias to
SceneData.actuator_ctrls()
- get_actuator_index(name)#
Get actuator index by its name.
- 参数:
name (str) -- Name of the actuator.
- 返回:
Index of the actuator, or None if not found.
- 返回类型:
Optional[int]
- get_body(key)#
Get a body by name or index.
- 参数:
key (str or int) -- Name or index of the body.
- 返回:
The body object, or None if not found.
- 返回类型:
Optional[Body]
- get_body_index(name)#
Get the body index by its name.
- 参数:
name (str) -- Name of the body.
- 返回:
Index of the body, or None if not found.
- 返回类型:
Optional[int]
- get_camera_poses(data)#
Get the world poses of all cameras.
- 参数:
data (SceneData) -- Scene data.
- 返回:
A numpy array with shape (*data.shape,num_cameras, 7). Each pose is composed of [x, y, z, qx, qy, qz, qw],
- 返回类型:
NDArray[float]
备注
If there are no cameras in the scene, returns an array with shape (*data.shape, 0, 7).
- get_contact_query(data)#
Get a contact query object for the current model and data.
- 参数:
data (SceneData) -- Scene data.
- 返回:
A contact query object that can be used to query contacts in the world.
- 返回类型:
- get_geom(arg)#
Get a geom by name or index.
- 参数:
key (str or int) -- Name or index of the geom.
- 返回:
The geom object, or None if not found.
- 返回类型:
Optional[Geom]
- get_geom_index(name)#
Get the geometry index by its name.
- 参数:
name (str) -- Name of the geometry.
- 返回:
Index of the geometry, or None if not found.
- 返回类型:
Optional[int]
- get_hfield(arg)#
Get an hfield by name or index.
- 参数:
key (str or int) -- Name or index of the hfield.
- 返回:
The hfield object, or None if not found.
- 返回类型:
Optional[HField]
- get_hfield_index(name)#
Get hfield index by its name.
- 参数:
name (str) -- Name of the hfield.
- 返回:
Index of the hfield, or None if not found.
- 返回类型:
Optional[int]
- get_joint(key)#
Get a joint by name or index.
- 参数:
key (str or int) -- Name or index of the joint.
- 返回:
The joint object, or None if not found.
- 返回类型:
Optional[Joint]
- get_joint_index(name)#
Get the joint index by its name.
- 参数:
name (str) -- Name of the joint.
- 返回:
Index of the joint, or None if not found.
- 返回类型:
Optional[int]
- get_link(arg)#
Get a link by name or index.
- 参数:
key (str or int) -- Name or index of the link.
- 返回:
The link object, or None if not found.
- 返回类型:
Optional[Link]
- get_link_index(name)#
Get the link index by its name.
- 参数:
name (str) -- Name of the link.
- 返回:
Index of the link, or None if not found.
- 返回类型:
Optional[int]
- get_link_poses(data)#
Get the world poses of all links.
- 参数:
data (SceneData) -- Scene data.
- 返回:
A numpy array with shape (*data.shape,num_links, 7). Each pose is composed of [x, y, z, i, j, k, w],
- 返回类型:
NDArray[float]
- get_link_rotation_mats(data)#
Get all link rotation matrices.
- 参数:
data (SceneData) -- Scene data.
- 返回:
A numpy array with shape (*data.shape,num_links, 3, 3). Each rotation
- 返回类型:
NDArray[float]
matrix is in column-major order.
- get_sensor_value(id, data)#
Get the value of a specific sensor by its ID.
- 参数:
id (str) -- Sensor ID.
data (SceneData) -- Scene data.
- 返回:
Sensor values. shape = (*data.shape, sensor_value_size)
- 返回类型:
NDArray[float]
- get_site(key)#
Get a site by name or index.
- 参数:
key (str or int) -- Name or index of the site.
- 返回:
The site object, or None if not found.
- 返回类型:
Optional[Site]
- get_site_index(name)#
Get site index by name.
- 参数:
name (str) -- Name of the site.
- 返回:
Index of the site, or None if not found.
- 返回类型:
Optional[int]
- step(data)#
Advance the simulation by one step using the current model and data.
备注
If the data has batch dimension, motrixsim will run simulation in parallel
- step_n(data, n)#
Advance the simulation by n steps using the current model and data.
- 参数:
data (SceneData) -- Scene data.
n (int) -- Number of steps to advance the simulation.
备注
This method can skip the python overhead when stepping multiple times.
- actuator_ctrl_limits#
The actuator control ranges.
Return a 2-dimensional numpy array with shape (2, num_actuators). The first dimension is the minimum control value, and the second dimension is the maximum control value. If the limits do not set for a actuator, (-inf, inf) will be used as the limits.
- Type:
NDArray[float]
- actuator_names#
The list of actuator names in the world.
Return list of actuator names, can be None if the actuator does not have a name.
- Type:
List[Optional[str]]
- actuators#
Get all actuators defined in the model.
- 返回:
A list of all actuator objects in the world.
- 返回类型:
List[Actuator]
- bodies#
The list of all bodies in the world.
备注
don't confuse the body in motrixsim with the body in mjcf. See 🤖 刚体(Body) for more details.
- Type:
List[Body]
- body_names#
The list of all body names in the world.
Return list of body names, can be None if the body does not have a name.
- Type:
List[Optional[str]]
- floating_bases#
The list of all floating bases in the world.
- Type:
List[FloatingBase]
- geom_names#
The list of all geoms names in the world.
A list of geom names, can be None if the geom does not have a name.
- Type:
List[Optional[str]]
- joint_dof_pos_indices#
The start dof index for each joint in the dof positions array.
A list of start indices for each joint's dof positions in the dof positions array. size = num_joints.
备注
The DoF of floating base is not included.
- Type:
List[int]
- joint_dof_pos_nums#
The number of DoF positions for each joint.
List of position DoF sizes for each joint. size = num_joints
- Type:
List[int]
- joint_dof_vel_indices#
The start dof index for each joint in the dof velocities array.
A list of start indices for each joint's dof velocities in the dof velocities array.
备注
The DoF of floating base is not included.
- Type:
List[int]
- joint_dof_vel_nums#
The size of DoF velocities of each joint.
List of velocity DoF sizes for each joint. size = num_joints.
- Type:
List[int]
- joint_limits#
The joint position limits for each joint.
A 2-dimensional numpy array with shape (2, num_joints).
The first dimension is the minimum position limit, and the second dimension is the maximum position limit. If the limits are not set for a joint, -inf, inf will be used as the limits.
- Type:
NDArray[float]
- joint_names#
The list of all joint names in the world.
Return list of joint names, can be None if the joint does not have a name.
- Type:
List[Optional[str]]
- link_names#
The list of all link names in the world.
A list of link names, can be None if the link does not have a name.
- Type:
List[Optional[str]]
- low#
The low-level model for advanced or internal simulation access.
This property exposes the underlying low-level scene model, which provides direct access to internal simulation data and advanced features.
备注
Do not use this property unless you know what you are doing.
- Type:
LowSceneModel
- num_actuators#
The number of actuators in the world.
- Type:
int
- num_bodies#
The number of bodies in the world.
- Type:
int
- num_dof_pos#
The number of DoF positions in the world.
- Type:
int
- num_dof_vel#
The number of DoF velocities in the world.
备注
This value may be different from the [num_dof_pos] because for some joint (like ball joint), we use Quaternion to represent the rotation, which has 4 components.
- Type:
int
- num_geoms#
The number of geoms in the world.
- Type:
int
- num_hfields#
The number of height fields in the world.
- Type:
int
- num_joints#
The number of joints in the world.
备注
freejoint in MJCF is not considered as a joint but a floating base.
- Type:
int
- num_keyframes#
The number of keyframes in the model.
- Type:
int
- num_links#
The number of links in the world.
备注
The worldbody in MJCF is not considered as a link.
- Type:
int
- num_sensors#
The number of sensors in the world.
- Type:
int
- num_sites#
The number of sites in the world.
- Type:
int
- site_names#
The list of all site names in the world.
- Type:
List[str]
- class motrixsim.Shape#
基类:
objectThe shape type of a collider.
- Enum Values:
Sphere: A spherical collision shape Cylinder: A cylindrical collision shape Capsule: A capsule collision shape (cylinder with hemispherical ends) Cuboid: A box-shaped collision shape InfinitePlane: An infinite plane collision shape HField: A height field collision shape for terrain
Methods:
Returns all shape type names as a list of strings.
types()Returns all shape types as a list.
Attributes:
- static type_names()#
Returns all shape type names as a list of strings.
- 返回:
All shape type names.
- 返回类型:
List[str]
- Capsule = Shape.Capsule#
- Cuboid = Shape.Cuboid#
- Cylinder = Shape.Cylinder#
- HField = Shape.HField#
- InfinitePlane = Shape.InfinitePlane#
- Mesh = Shape.Mesh#
- Plane = Shape.Plane#
- Sphere = Shape.Sphere#
- class motrixsim.Site#
基类:
objectThe Site object represents a reference point or marker in the scene.
Methods:
get_pose(data)Get the pose of the site in the world frame.
get_position(data)Get the position of the site in the world frame.
get_rotation_mat(data)Get the rotation matrix of the site in the world frame.
Attributes:
The index of the site in the site list.
The local position of the site in the parent frame in (x, y, z).
The local orientation of the site as a quaternion (i, j, k, w).
The model that this site belongs to.
The name of the site, or None if not set.
The parent link of the site, or None if the site is attached to the world frame.
- get_pose(data)#
Get the pose of the site in the world frame.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The pose of the site in the world frame. shape = (*data.shape,7). The last axis is 7-element array with [x, y, z, i, j, k, w].
- 返回类型:
NDArray[float]
- get_position(data)#
Get the position of the site in the world frame.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
The position of the site in the world frame. shape = (*data.shape,3).
- 返回类型:
NDArray[float]
- get_rotation_mat(data)#
Get the rotation matrix of the site in the world frame.
- 参数:
data (SceneData) -- The scene data to query.
- 返回:
- The rotation matrix of the site in the world frame. shape =
(*data.shape,3,3).
- 返回类型:
NDArray[float]
- index#
The index of the site in the site list.
- Type:
int
- local_pos#
The local position of the site in the parent frame in (x, y, z).
- Type:
NDArray[float]
- local_quat#
The local orientation of the site as a quaternion (i, j, k, w).
- Type:
NDArray[float]
- model#
The model that this site belongs to.
- name#
The name of the site, or None if not set.
- Type:
Optional[str]
- motrixsim.forward_kinematic(model, data)#
Run forward kinematic only.
- 参数:
model (SceneModel) -- The scene model.
data (SceneData) -- The scene data.
- motrixsim.load_mjcf_str(mjcf)#
Load a model from a string containing MJCF data.
- 参数:
mjcf (str) -- The MJCF data as a string.
- 返回:
The loaded scene model.
- 返回类型:
- motrixsim.load_model(path)#
Load a model from the given file path.
- 参数:
path (str) -- The path to the model file.
supported. (currently mjcf and urdf are)
- 返回:
The loaded scene model.
- 返回类型:
- motrixsim.step(model, data)#
Advance the simulation by one step.
- 参数:
model (SceneModel) -- The scene model.
data (SceneData) -- The scene data.