Core Model#

The core biomechanical model classes and parsers for system representation.

Model Classes#

Model Parsers#

class biosym.model.parsers.base_parser.BaseParser(model_file)#

Bases: ABC

Abstract base class for model parsers.

abstractmethod get_bodies()#

Returns the list of bodies in the model. Each body is a dictionary with the following keys:

  • name: The name of the body

  • mass: The mass of the body

  • inertia: The inertia of the body

  • body_offset: The offset of the body

  • com: The center of mass of the body

  • parent: The parent body of the body

  • joints: The joint associated with the body

abstractmethod get_external_forces_bodies()#

Returns the list of bodies, where external forces can be applied.

abstractmethod get_gravity()#

Returns the gravity vector in the model.

abstractmethod get_internal_forces()#

Returns the list of internal forces in the model.

abstractmethod get_joints()#

Returns the list of joints in the model. Each joint is a dictionary with the following keys:

  • name: The name of the joint

  • type: The type of the joint (e.g. revolute, prismatic)

  • axis: The axis of the joint

  • parent: The parent body of the joint

  • child: The child body of the joint

We should add range / stiffness / damping / etc. here to be mujoco-feature complete

abstractmethod get_n_bodies()#

Returns the number of bodies in the model.

abstractmethod get_n_external_forces()#

Returns the number of bodies, where external forces can be applied.

abstractmethod get_n_internal_forces()#

Returns the number of internal forces in the model.

abstractmethod get_n_joints()#

Returns the number of joints in the model.

abstractmethod get_n_sites()#

Returns the number of sites (e.g., MuJoCo <site> elements or marker points) defined in the model.

abstractmethod get_sites()#

Returns the list of sites in the model. Each site should be represented as a dictionary with keys such as:

  • name: site name

  • pos: position (x, y, z) relative to parent body/frame

  • body: parent body name (optional)

  • size: visual size (optional)

  • rgba: color/alpha tuple (optional)

class biosym.model.parsers.mujoco_parser.MujocoParser(model_file, verbose=False)#

Bases: BaseParser

Parser for Mujoco model files. Currently, this only builds the structure, but we also want to have the parameters

get_actuators()#

Returns the xml entries for the actuators in the model

get_bodies()#

Returns the list of bodies in the model.

get_contact_model()#

Returns the xml entries for the contact model in the model.

get_external_forces_bodies()#

Returns the list of bodies, where external forces can be applied.

get_gravity()#

Returns the gravity vector in the model.

get_internal_forces()#

Returns the list of internal forces in the model.

get_joints()#

Returns the list of joints in the model.

get_n_bodies()#

Returns the number of bodies in the model.

get_n_external_forces()#

Returns the number of bodies, where external forces can be applied. In mujoco, ground contact isn’t explicitly stated, so that should be in a config somewhere

get_n_internal_forces()#

Returns the number of internal forces in the model.

get_n_joints()#

Returns the number of joints in the model.

get_n_sites()#

Returns the number of sites in the model.

get_sites()#

Returns the list of sites in the model.

has_actuators()#

Returns True if the model has actuators, False otherwise.

has_contact_model()#

Returns True if the model has a contact model, False otherwise.