RigidSolver#

The RigidSolver handles rigid body dynamics, including articulated bodies, robots, and rigid objects. For usage, see Rigid bodies.

Options#

class genesis.options.solvers.RigidOptions(*, contact_resolve_time: float | None = None, dt: float | None = None, gravity: tuple[float, float, float] | None = None, enable_collision: bool = True, enable_joint_limit: bool = True, enable_self_collision: bool = True, enable_neutral_collision: bool = False, enable_adjacent_collision: bool = False, disable_constraint: bool = False, max_collision_pairs: int = 150, max_contacts: int | None = None, multiplier_collision_broad_phase: int = 8, integrator: genesis.constants.integrator = integrator.approximate_implicitfast, IK_max_targets: int = 6, batch_links_info: bool = False, batch_joints_info: bool = False, batch_dofs_info: bool = False, constraint_solver: genesis.constants.constraint_solver = constraint_solver.Newton, iterations: int = 50, tolerance: float | None = None, ls_iterations: int = 50, ls_tolerance: float = 0.01, noslip_iterations: int = 0, noslip_tolerance: float = 1e-06, friction_cone: genesis.constants.friction_cone = friction_cone.pyramidal, contact_resolution: genesis.constants.contact_resolution | None = None, enable_torsional_friction: bool = False, enable_rolling_friction: bool = False, impratio: float | None = None, contact_pruning_tolerance: float | None = 0.02, sparse_solve: bool | None = None, constraint_timeconst: float | None = 0.01, use_contact_island: bool = True, box_box_detection: bool = False, use_hibernation: bool = False, hibernation_thresh_vel: float | None = None, max_dynamic_constraints: int = 8, enable_multi_contact: bool = True, enable_mujoco_compatibility: bool = False, use_gjk_collision: bool | None = None, enable_contact_patch: bool | None = None, broadphase_traversal: genesis.constants.broadphase_traversal | None = None) None[source]#

Options configuring the RigidSolver.

Parameters:
  • enable_collision (bool, optional) – Whether to enable collision detection. Defaults to True.

  • enable_joint_limit (bool, optional) – Whether to enable joint limit. Defaults to True.

  • enable_self_collision (bool, optional) – Whether to enable self collision within each entity. Defaults to True.

  • enable_neutral_collision (bool, optional) – Whether to enable self collision occurring in neutral configuration (qpos0) within each entity. Defaults to False.

  • enable_adjacent_collision (bool, optional) – Whether to enable collision between successive parent-child body pairs within each entity. Defaults to False.

  • disable_constraint (bool, optional) – Whether to disable all constraints. Defaults to False.

  • max_collision_pairs (int, optional) – Maximum number of collision pairs. Defaults to 100.

  • max_contacts (int, optional) –

    Maximum number of simultaneous contact points per environment that the constraint solver can handle, which determines the size of the contact constraint buffers (3 to 10 constraint rows per contact point depending on ‘friction_cone’, ‘enable_torsional_friction’, and ‘enable_rolling_friction’). Defaults to None.

    This limit applies to the final contact points after pruning, not to the candidate contact points that collision detection can emit (see ‘max_collision_pairs’). Exceeding it at runtime halts the simulation with an error. None resolves it automatically: the pre-pruning worst case or, when contact pruning is enabled (see ‘contact_pruning_tolerance’), 32 contact points per candidate link pair but no less than 512, whichever is smaller.

  • integrator (gs.integrator, optional) – Integrator type. Current supported integrators are ‘gs.integrator.Euler’, ‘gs.integrator.implicitfast’ and ‘gs.integrator.approximate_implicitfast’. ‘Euler’ and ‘implicitfast’ are consistent with their Mujoco counterpart. ‘approximate_implicitfast’ is an even faster approximation of ‘implicitfast’, which avoid computing the inverse mass matrix twice by considering the first order correction terms of the implicit integration scheme systematically, including for computing the acceleration resulting from the constraints and external forces. Although this approximation is wrong in theory, it works reasonably well in practice. Defaults to ‘approximate_implicitfast’.

  • IK_max_targets (int, optional) – Maximum number of IK targets. Increasing this doesn’t affect IK solving speed, but will increase memory usage. Defaults to 6.

  • batch_links_info (bool, optional) – Whether the model parameters of a link, such as its mass or its inertia, are stored per environment rather than shared by the whole batch. Storing them per environment is what lets each environment carry its own values, which domain randomization needs, and what makes a per-environment write possible at all. It costs one copy of every link parameter per environment, in memory and in the bandwidth to read it, which slows down the memory-bound kernels. Automatically enabled for heterogeneous simulation. Defaults to False.

  • batch_joints_info (bool, optional) – Whether the model parameters of a joint are stored per environment rather than shared by the whole batch, with the same tradeoff as batch_links_info. Defaults to False.

  • batch_dofs_info (bool, optional) – Whether the model parameters of a degree of freedom are stored per environment rather than shared by the whole batch, with the same tradeoff as batch_links_info. Defaults to False.

  • constraint_solver (gs.constraint_solver, optional) – Constraint solver type. Current supported constraint solvers are ‘gs.constraint_solver.CG’ (conjugate gradient) and ‘gs.constraint_solver.Newton’ (Newton’s method). Defaults to ‘Newton’.

  • iterations (int, optional) – Maximum number of iterations for the constraint solver; the solve exits early once its convergence tolerance is met, so this bound only binds on hard steps. Defaults to 50.

  • tolerance (float, optional) – Tolerance for the constraint solver. If None, resolved based on the floating-point precision selected via gs.init(precision=...): 1e-5 for single precision (“32”) and 1e-8 for double precision (“64”). Defaults to None.

  • ls_iterations (int, optional) – Number of line search iterations for the constraint solver. Defaults to 50.

  • ls_tolerance (float, optional) – Tolerance for the line search. Defaults to 1e-2.

  • noslip_iterations (int, optional) – Number of iterations for the noslip solver. Defaults to 0 (disabled). noslip is a post-processing step after the main solver to suppress slip/drift. Recommended to set this value to 5 for manipulation tasks or when slip/drift is a big problem. This option should only be enabled if necessary because it is experimental and will slow down the simulation.

  • noslip_tolerance (float, optional) – Tolerance for the noslip solver. Defaults to 1e-6.

  • friction_cone (gs.friction_cone, optional) – Contact friction cone model, trading numerical robustness for physical accuracy. ‘gs.friction_cone.pyramidal’ (default) is robust and easy to solve; ‘gs.friction_cone.elliptic’ is the exact isotropic cone, harder to solve but paired with a high ‘impratio’ it holds resting stacks without slow tangential creep. See ‘gs.friction_cone’ for the description of each model. Unsupported with the noslip solver or differentiable simulation.

  • contact_resolution (gs.contact_resolution, optional) – How a contact’s normal force and friction force are resolved against each other. ‘gs.contact_resolution.signorini’ bounds friction against the normal force the contact has developed, so sliding never inflates it and a body launched horizontally decelerates at mu * g instead of lifting off, at the cost of extra solver iterations. ‘gs.contact_resolution.convex’ poses the contact as a single convex program, which converges more predictably on stiff scenes but lets fast sliding buy normal force. See ‘gs.contact_resolution’ for the description of each model. Defaults to None, resolving to ‘signorini’ with the elliptic cone and the Newton solver, and ‘convex’ otherwise - the pyramidal cone’s rows do not separate, and the conjugate gradient solver does not reach the fixed point. Always ‘convex’ when ‘enable_mujoco_compatibility’ is set.

  • enable_torsional_friction (bool, optional) – Whether contacts also resist relative spin about their normal, with strength set per geometry by the material option ‘friction_torsional’ (see ‘gs.materials.Rigid’). Enable it when spin resistance matters - a grasped object twisting in a gripper, a top spinning in place - motions a point contact transmits no torque against, so they persist indefinitely otherwise. The extra spin resistance slows down the constraint solve on every contact, including those where spin is irrelevant. Defaults to False.

  • enable_rolling_friction (bool, optional) – Whether contacts also resist rolling, with strength set per geometry by the material option ‘friction_rolling’ (see ‘gs.materials.Rigid’). Enable it when rolling resistance matters - a ball or wheel coasting to rest, a cylinder settling on a slope - motions a point contact otherwise never slows down. The extra rolling resistance slows down the constraint solve on every contact, more so than torsional friction (two extra axes), and requires ‘enable_torsional_friction’. Defaults to False.

  • impratio (float, optional) – Ratio of tangential (friction) to normal constraint impedance at contacts. Raising it above 1 stiffens friction so resting stacks and piles hold their pose under sustained shear, at the cost of a slower solve that turns numerically unstable once pushed too far - a stiffness-versus-stability tradeoff, so use the smallest value that holds the contacts. It matters mainly with the elliptic cone, which stiffens friction alone while leaving the normal contact response at its own impedance. Defaults to None, resolving to 100 with the elliptic cone (1 when ‘enable_mujoco_compatibility’ is set) and 1 otherwise.

  • sparse_solve (bool, optional) –

    Whether to exploit sparsity (skyline-envelope Cholesky) in the constraint solver.

    Defaults to None, which resolves automatically: enabled on the CPU backend (and not under MuJoCo compatibility) when the scene has block structure - at least two DOF-carrying bodies or at least two free joints - so the Hessian band stays much tighter than its dimension. Never enabled on GPU, where the dense tiled factorization is faster. Set True or False to override the automatic choice; True is ignored with a warning on GPU.

  • contact_resolve_time (float, optional) – Please note that this option will be deprecated in a future version. Use ‘constraint_timeconst’ instead.

  • constraint_timeconst (float | None) – Time constant of the constraint response, in seconds, used for every geom that does not carry one of its own. The smaller it is, the stiffer the constraint, down to a floor of twice the integration interval, below which the solve becomes unstable. Set it to None to leave those geoms at that floor: as stiff as the timestep allows, and what a model authoring its own values expects, at the cost of contacts that respond more abruptly. This parameter is called ‘timeconst’ in Mujoco (https://mujoco.readthedocs.io/en/latest/modeling.html#solver-parameters). Defaults to 0.01.

  • use_contact_island (bool, optional) – Whether to partition the constraint solve into independent per-island blocks. It has no effect on a scene that is a single dense-coupled tree (one island) or is differentiable, where the dense whole-scene solve is used regardless. Defaults to True.

  • use_hibernation (bool, optional) – Whether to put bodies that have come to rest to sleep, so the solver skips them until they are disturbed. It quietly has no effect on a body that is differentiable, prunable, or under no-slip friction. Defaults to False.

  • hibernation_thresh_vel (float, optional) – Velocity tolerance for hibernation, in meters per second: a body sleeps once its maximum DOF speed stays below this for a few consecutive steps, and a whole island sleeps once all its bodies are ready. Each rotational DOF is weighted by the body’s swept radius, so the tolerance is a single linear speed that applies uniformly to translation and rotation. If None, it is set to 1e-4 when MuJoCo compatibility is enabled (matching MuJoCo’s default) and 2e-3 otherwise. Defaults to None.

  • max_dynamic_constraints (int, optional) – Maximum number of dynamic constraints (like suction cup). Defaults to 8.

  • use_gjk_collision (bool, optional) – Whether to use GJK for collision detection instead of MPR. More stable but much slower. Defaults to sim_options.requires_grad.

  • enable_contact_patch (bool, optional) – Whether to recover the full contact patch from the touching faces inside GJK, in a single detection pass, instead of through perturbed re-detections. The contact patch is cheaper and reports the exact contact polygon, but it is discouraged: it is less reliable than the perturbation-based detection, which is extremely robust at the cost of extra detection passes. Requires GJK collision detection, and raises otherwise. If None, it is enabled when MuJoCo compatibility is enabled together with GJK and multi-contact, and disabled otherwise. Defaults to None.

  • broadphase_traversal (gs.broadphase_traversal, optional) – Broadphase traversal strategy. SAP (sweep-and-prune) or ALL_VS_ALL (parallel pair iteration). Defaults to None (auto: SAP on CPU or when hibernation/heterogeneous entities are enabled, ALL_VS_ALL on GPU otherwise). See gs.broadphase_traversal for details on each strategy.

Warning

Hibernation hasn’t been robustly tested and will be fully supported soon.

Option enums#

The values accepted by the RigidOptions fields above. The model each one selects is described in Constraint model.

class genesis.constants.integrator[source]#
class genesis.constants.constraint_solver[source]#
class genesis.constants.friction_cone[source]#

Contact friction cone model, trading numerical robustness for physical accuracy.

‘pyramidal’ (the default) approximates the friction cone by a pyramid: robust and easy to solve, but the approximation makes friction anisotropic (the effective limit depends on the sliding direction). ‘elliptic’ is the exact cone: friction is isotropic and bounded by its true Euclidean limit sqrt(f_t1^2 + f_t2^2) <= mu * f_n in every direction, and with a high ‘impratio’ it holds resting stacks without the slow tangential creep of regularized friction, in return for being harder to solve and more sensitive numerically. Prefer pyramidal for robustness; choose elliptic when isotropic friction or firm static friction matters - e.g. objects that must stay put at rest instead of slowly creeping.

class genesis.constants.contact_resolution[source]#

How a contact’s normal force and friction force are resolved against each other.

‘convex’ poses the whole contact as a single smooth convex cost and lets the solver trade the normal residual against the tangential one. Because the friction limit mu * f_n bounds the pair jointly, a contact sliding fast enough that its friction rows demand more force than the cone allows can be answered by raising f_n instead: a body launched horizontally then lifts off a flat floor, by more the faster it slides. In exchange the whole problem stays one convex program, which converges predictably on stiff articulated chains and high mass ratios.

‘signorini’ bounds friction against the normal force the contact has actually developed, so that force is set by the contact’s own normal state rather than by tangential demand, and sliding can never inflate it - a sliding body decelerates at mu * g and stays down at any speed. Contacts are resolved by successive approximation, costing extra solver iterations and giving up the single-convex-program guarantee. Prefer it whenever sliding contact matters; choose ‘convex’ for parity with engines built on that formulation, or if a stiff scene converges better under it.

‘signorini’ requires the elliptic friction cone, whose rows separate into a normal row and a friction disc - the pyramidal cone mixes the normal direction into every row and admits no such split - and the Newton constraint solver, the only one that reaches the fixed point of the resulting successive approximation. It implements the Coulomb complementarity problem eq. (C.22) of Alexis Duburcq, “Learning and Optimization of the Locomotion with an Exoskeleton for Paraplegic People”, PhD thesis, Universite Paris Sciences et Lettres, 2022 (HAL tel-04166955), Appendix C, whose Signorini condition is what forbids the normal force from absorbing tangential demand.

class genesis.constants.broadphase_traversal[source]#

Strategy for broad-phase collision detection in the rigid solver.

Broad-phase quickly eliminates geometry pairs that cannot collide before the more expensive narrow-phase runs.

At init time, geometry pairs that can never collide are filtered out (same-link, fixed-vs-fixed, contype/conaffinity mismatch, etc.), producing a list of valid pairs. The number of valid pairs can be up to O(n_geoms^2) but is typically much smaller after filtering. The two strategies differ in how they search these valid pairs each step:

SAP#

Sweep-and-prune. Sorts geometry AABBs along one axis (O(n_geoms log n_geoms)) then only checks pairs that overlap on that axis. The sort and sweep are single-threaded, which utilizes GPU cores poorly. However the cost per step is only O(n_geoms log n_geoms + k) where k is the number of axis-overlapping pairs — typically much less than the full set of valid pairs.

Type:

int

ALL_VS_ALL#

Checks every valid pair every step (AABB overlap test), dispatching them in parallel across GPU threads. Cost per step is O(n_valid_pairs) which is efficient on GPU when the pair count is moderate, but becomes expensive in scenes with many geometries since the valid pair count grows quadratically. Does not support hibernation or heterogeneous entities at this time.

Type:

int

Notes

RigidOptions.broadphase_traversal defaults to None, which lets the solver choose automatically:

  • CPU backendSAP (sequential sweep is efficient on CPU).

  • GPU backendALL_VS_ALL (parallel pair checking is faster).

  • GPU with hibernation or heterogeneous entitiesSAP (ALL_VS_ALL is not compatible with these features).

Reference frames#

The frame a per-link getter expresses its result in, and the frame an external wrench is read in.

Reference frame at which a per-link quantity is expressed.

Each member fixes an origin, about which spatial quantities are translated, together with an orientation, by which quantities given in local coordinates are rotated. ‘root_COM’ is the center of mass of the whole kinematic tree the link belongs to, with world-aligned axes; the solver stores link velocities and generalized forces there natively, so it is the only frame reached without a moment arm. ‘link_COM’ is the center of mass of the link, with the axes of its inertial frame. ‘link_origin’ is the origin of the link, with the axes of the link frame.

RigidSolver#

class genesis.engine.solvers.rigid.rigid_solver.RigidSolver(scene: Scene, sim: Simulator, options: RigidOptions)[source]#

Bases: GravityMixin, TimeBasedMixin, KinematicSolver

material_cls#

alias of Rigid

init_ckpt()[source]#
build()[source]#
update_forward_pos()[source]#

Run forward kinematics over links and geoms if they are not already up to date for the current pose.

Geoms are refreshed alongside links, unlike the geom-less base solver: the flag this sets also authorizes the next step to skip its own Cartesian-space update, which covers geoms too. Refreshing links alone would leave collision - and any raycast deriving its vertices from geom poses - reading a one-step-stale pose.

substep(f)[source]#
get_error_envs_mask()[source]#
check_errno()[source]#
detect_collision(env_idx=0)[source]#

Apply an external wrench over one simulation step on a set of links.

Parameters:
  • force (None | array_like, optional) – The linear force to apply. None for a pure torque. Defaults to None.

  • torque (None | array_like, optional) – The torque to apply, on top of the moment induced by the linear force. Defaults to None.

  • links_idx (None | array_like, optional) – The indices of the links on which to apply the wrench. None to specify all links. Default to None.

  • envs_idx (None | array_like, optional) – The indices of the environments. If None, all environments will be considered. Defaults to None.

  • pos (None | array_like, optional) – Where the linear force is applied, which sets the moment arm of the induced torque. With local=True, an offset from the origin of the ref frame, so the point follows each link as it moves; otherwise a world position. None applies the force at the origin of the ref frame. Defaults to None.

  • ref (gs.link_ref_frame, optional) – The reference frame: the origin of each link (‘link_origin’), or its center of mass (‘link_COM’). It fixes where the linear force acts when pos is None, and the axes of the input coordinates when local=True. Defaults to ‘link_origin’.

  • local (bool, optional) – Whether force, torque and pos are expressed in the coordinates of the ref frame rather than the world frame. Defaults to False.

substep_pre_coupling(f)[source]#
reset_grad()[source]#
substep_pre_coupling_grad(f)[source]#
substep_post_coupling(f)[source]#
get_state(f=None)[source]#
set_state(f, state, envs_idx=None, *, partial: bool = False) None[source]#
property data: Iterator[DataItem]#

Yield every array and static config the solver holds, tagged by kind (see ‘DataKind’), under the dotted name a checkpoint and a trajectory frame use for it.

process_input(in_backward=False)[source]#

Process input for entities (set qpos from user commands).

process_input_grad()[source]#

No-op: kinematic solver does not support gradients.

save_ckpt(ckpt_name)[source]#

No-op: kinematic solver does not save checkpoints.

load_ckpt(ckpt_name)[source]#

No-op: kinematic solver does not load checkpoints.

Set the mass of the given links, in kg.

Set ‘scale_inertia’ to scale their inertia by the same factor, which gives what a body of the same shape made heavier behaves like, its inertia being proportional to its mass. Without it, the mass of a link changes and the inertia it was given stays as it is.

Every mass must be finite and strictly positive, which is not checked.

The value written survives scene.reset(): a reset restores the configuration the scene was built at and leaves inertial properties alone.

Set the inertia tensor of the given links, expressed in their inertial frame.

The caller is responsible for making sure that the inertia specified is physically sound, that is symmetric positive definite. There is no runtime check of this precondition, for the sake of efficiency.

Set the center of mass (COM) of the given links, as an offset from the origin of their local frame.

set_geoms_friction_ratio(friction_ratio, geoms_idx=None, envs_idx=None)[source]#
set_qpos(qpos, qs_idx=None, envs_idx=None, *, skip_forward=False)[source]#
set_global_sol_params(sol_params)[source]#

Set constraint solver parameters.

Reference: https://mujoco.readthedocs.io/en/latest/modeling.html#solver-parameters

Parameters:

sol_params (Tuple[float] | List[float] | np.ndarray | torch.tensor) – array of length 7 in which each element corresponds to (timeconst, dampratio, dmin, dmax, width, mid, power)

set_sol_params(sol_params, geoms_idx=None, envs_idx=None, *, joints_idx=None, eqs_idx=None)[source]#

Set constraint solver parameters.

See genesis.utils.geom.default_solver_params() for the parameter semantics, in particular the relationship between dampratio, spring stiffness, and velocity damping.

Reference: https://mujoco.readthedocs.io/en/latest/modeling.html#solver-parameters

Parameters:

sol_params (Tuple[float] | List[float] | np.ndarray | torch.tensor) – array of length 7 in which each element corresponds to (timeconst, dampratio, dmin, dmax, width, mid, power)

set_dofs_kp(kp, dofs_idx=None, envs_idx=None)[source]#
set_dofs_kv(kv, dofs_idx=None, envs_idx=None)[source]#
set_dofs_act_gain(act_gain, dofs_idx=None, envs_idx=None)[source]#
set_dofs_act_bias(bias0, bias1, bias2, dofs_idx=None, envs_idx=None)[source]#
set_dofs_force_range(lower, upper, dofs_idx=None, envs_idx=None)[source]#
set_dofs_stiffness(stiffness, dofs_idx=None, envs_idx=None)[source]#
set_dofs_armature(armature, dofs_idx=None, envs_idx=None)[source]#
set_dofs_damping(damping, dofs_idx=None, envs_idx=None)[source]#
set_dofs_frictionloss(frictionloss, dofs_idx=None, envs_idx=None)[source]#
set_dofs_limit(lower, upper, dofs_idx=None, envs_idx=None)[source]#
set_dofs_position(position, dofs_idx=None, envs_idx=None)[source]#
set_dofs_velocity(velocity, dofs_idx=None, envs_idx=None, *, skip_forward=False)[source]#
control_dofs_force(force, dofs_idx=None, envs_idx=None)[source]#
control_dofs_velocity(velocity, dofs_idx=None, envs_idx=None)[source]#
control_dofs_position(position, dofs_idx=None, envs_idx=None)[source]#
control_dofs_position_velocity(position, velocity, dofs_idx=None, envs_idx=None)[source]#
get_sol_params(geoms_idx=None, envs_idx=None, *, joints_idx=None, eqs_idx=None)[source]#

Get constraint solver parameters.

Returns the center of mass (COM) of the entire kinematic tree to which the specified links belong.

This corresponds to the global COM of each entity, assuming a single-rooted structure - that is, as long as no two successive links are connected by a free-floating joint (ie a joint that allows all 6 degrees of freedom).

The center of mass (COM) of each link, as an offset from the origin of its local frame.

Whether the inertial properties of a link are stored per environment rather than shared by the batch.

The mass of each link, as the solver currently uses it.

The inertia matrix of each link, in its inertial frame, as the solver currently uses it.

get_geoms_friction_ratio(geoms_idx=None, envs_idx=None)[source]#
get_geoms_pos(geoms_idx=None, envs_idx=None, *, relative=False)[source]#
get_geoms_quat(geoms_idx=None, envs_idx=None, *, relative=False)[source]#
get_dofs_control_force(dofs_idx=None, envs_idx=None)[source]#
get_dofs_actuator_force(dofs_idx=None, envs_idx=None)[source]#

Generalized effort transmitted to each DOF at the actuator output (torque for revolute DOFs, force for prismatic DOFs), accounting for the gearbox losses between the motor and the joint.

Computed as qf_applied - armature * qacc + qf_frictionloss + qf_passive: the commanded effort from get_dofs_control_force minus the armature-inertia load, plus the dissipative frictionloss and passive damping efforts. Contact, Coriolis and gravity loads are captured implicitly through the constraint-solved acceleration.

get_dofs_force(dofs_idx=None, envs_idx=None)[source]#
get_dofs_kp(dofs_idx=None, envs_idx=None)[source]#
get_dofs_kv(dofs_idx=None, envs_idx=None)[source]#
get_dofs_act_gain(dofs_idx=None, envs_idx=None)[source]#
get_dofs_act_bias(dofs_idx=None, envs_idx=None)[source]#
get_dofs_force_range(dofs_idx=None, envs_idx=None)[source]#
get_dofs_stiffness(dofs_idx=None, envs_idx=None)[source]#
get_dofs_invweight(dofs_idx=None, envs_idx=None)[source]#
get_dofs_armature(dofs_idx=None, envs_idx=None)[source]#
get_dofs_damping(dofs_idx=None, envs_idx=None)[source]#
get_dofs_frictionloss(dofs_idx=None, envs_idx=None)[source]#
get_mass_mat(dofs_idx=None, envs_idx=None, decompose=False)[source]#
get_kinetic_energy(links_idx=None, dofs_idx=None, envs_idx=None)[source]#

Get the kinetic energy of the specified links and DOFs in Joules [J] (translational + rotational).

Summed over the links, each contributing 0.5 * V^T * I * V for its spatial velocity V and spatial inertia I about the center of mass (COM) of its kinematic tree, plus the motor armature contribution 0.5 * sum_d(armature_d * dq_d^2) of the DOFs. This equals the joint-space form 0.5 * dq^T * M(q) * dq while reading the link velocities and inertias that forward kinematics already maintains, so it needs no mass matrix and stays consistent with the current configuration whatever the integrator.

A link and the DOFs driving it contribute independently, so selecting one without the other is meaningful only to isolate that one term.

Parameters:
  • links_idx (None | array_like, optional) – The indices of the links. If None, all links will be considered. Defaults to None.

  • dofs_idx (None | array_like, optional) – The indices of the degrees of freedom. If None, all of them will be considered. Defaults to None.

  • envs_idx (None | array_like, optional) – The indices of the environments. If None, all environments will be considered. Defaults to None.

Returns:

kinetic_energy

Return type:

torch.Tensor, shape () or (n_envs,)

get_potential_energy(links_idx=None, dofs_idx=None, envs_idx=None)[source]#

Get the potential energy of the specified links and DOFs in Joules [J] (gravitational + joint springs).

Gravity contributes -sum_i(m_i * g^T * p_i) over the links free to move, where p_i is the center of mass (COM) position of link i. A link fixed to the world is left out, as it is of the mass of an entity: its potential is a constant of the scene. Joint springs contribute 0.5 * sum_d(stiffness_d * (q_d - q0_d)^2), the elastic energy stored by holding each DOF away from its neutral position. Both are state functions, so their sum with the kinetic energy is conserved by a passive, frictionless, contact-free model.

Contacts contribute nothing: they are resolved by the constraint solver, which stabilizes a penetration rather than storing it as an elastic potential.

Parameters:
  • links_idx (None | array_like, optional) – The indices of the links. If None, all links will be considered. Defaults to None.

  • dofs_idx (None | array_like, optional) – The indices of the degrees of freedom. If None, all of them will be considered. Defaults to None.

  • envs_idx (None | array_like, optional) – The indices of the environments. If None, all environments will be considered. Defaults to None.

Returns:

potential_energy

Return type:

torch.Tensor, shape () or (n_envs,)

get_total_energy(envs_idx=None)[source]#

Get the total mechanical energy of all entities in Joules [J] (kinetic + potential).

Parameters:

envs_idx (None | array_like, optional) – The indices of the environments. If None, all environments will be considered. Defaults to None.

Returns:

total_energy

Return type:

torch.Tensor, shape () or (n_envs,)

get_geoms_friction(geoms_idx=None)[source]#
get_geoms_friction_torsional(geoms_idx=None)[source]#
get_geoms_friction_rolling(geoms_idx=None)[source]#
get_AABB(entities_idx=None, envs_idx=None)[source]#
set_geom_friction(friction, geoms_idx)[source]#
set_geom_friction_torsional(friction_torsional, geoms_idx)[source]#
set_geom_friction_rolling(friction_rolling, geoms_idx)[source]#
set_geoms_friction(friction, geoms_idx=None)[source]#
set_geoms_friction_torsional(friction_torsional, geoms_idx=None)[source]#
set_geoms_friction_rolling(friction_rolling, geoms_idx=None)[source]#
add_weld_constraint(link1_idx, link2_idx, envs_idx=None)[source]#
delete_weld_constraint(link1_idx, link2_idx, envs_idx=None)[source]#
get_weld_constraints(as_tensor: bool = True, to_torch: bool = True)[source]#
get_equality_constraints(as_tensor: bool = True, to_torch: bool = True)[source]#
clear_external_force()[source]#
update_drone_propeller_vgeoms(propellers_vgeom_idxs, propellers_revs, propellers_spin)[source]#
set_drone_rpm(propellers_link_idx, kf, km, propellers_rpm, propellers_spin, invert)[source]#
update_verts_for_geoms(geoms_idx)[source]#
property n_geoms#
property n_cells#
property n_verts#
property n_free_verts#
property n_fixed_verts#
property n_faces#
property n_edges#
property max_collision_pairs#
property n_equalities#
property equalities#

The equality constraints the solver enforces, which a kinematic solver holds none of.

See also#