myoconverter.xml.bodies.utils

This module contains a collection of utility functions useful for parsing and converting the OpenSim BodySet

@author: Aleksi Ikkala

Module Contents

Functions

valid_inertia(mass, inertia_vec)

Check if given inertia vector is valid and can be used in the MuJoCo model.

copy_mesh_file(mesh_file, geometry_folder, ...)

This function copies the original mesh file,converts it to stl and fixes unconnected facets (if necessary)

get_rgba(mesh)

Return rgba string for given mesh

myoconverter.xml.bodies.utils.valid_inertia(mass, inertia_vec)[source]

Check if given inertia vector is valid and can be used in the MuJoCo model.

Parameters:
  • mass – Mass of a body/geom

  • inertia_vec – Inertia vector

Returns:

Boolean indicating whether the given vector is valid

myoconverter.xml.bodies.utils.copy_mesh_file(mesh_file, geometry_folder, output_geometry_folder)[source]

This function copies the original mesh file,converts it to stl and fixes unconnected facets (if necessary)

Parameters:
  • mesh_file – Path to mesh file

  • geometry_folder – Path to the folder where the mesh file is

  • output_geometry_folder – Path to folder into which the mesh file will be copied to

Returns:

Name of mesh, filename of converted stl mesh file

Raises:

NotImplementedError – if given mesh file is not vtk or stl

myoconverter.xml.bodies.utils.get_rgba(mesh)[source]

Return rgba string for given mesh

Parameters:

mesh – XML element

Returns:

Rgba string in format “r g b a”