myoconverter.xml.wrap_objects.utils

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

@author: Aleksi Ikkala

Module Contents

Functions

mujoco_wrap_object_name(osim_wrap_object_name)

Get wrapping object name in MuJoCo

projected_point_inside_segment(a, b, p)

Check if projection of point p is inside segment starting from a and ending in b.

point_distance_from_segment(a, b, p)

Calculate distance between point p and segment starting from a and ending in b.

find_wrap_path(xml, body, tendon, center)

Find locations of wrapping sites within a tendon. This placement is very much based on heuristics, and probably

Attributes

wrap_name_mapping

myoconverter.xml.wrap_objects.utils.wrap_name_mapping[source]
myoconverter.xml.wrap_objects.utils.mujoco_wrap_object_name(osim_wrap_object_name)[source]

Get wrapping object name in MuJoCo

Parameters:

osim_wrap_object_name – Name of an OpenSim wrapping object

Returns:

Wrapping object name in MuJoCo model

Raises:

RuntimeError: If a wrap object with given name cannot be found

myoconverter.xml.wrap_objects.utils.projected_point_inside_segment(a, b, p)[source]

Check if projection of point p is inside segment starting from a and ending in b.

Adapted from https://stackoverflow.com/a/47492642/6065074

Parameters:
  • a – Start point of segment

  • b – End point of segment

  • p – Point

Returns:

Boolean indicating whether projection of point p is inside given segment

myoconverter.xml.wrap_objects.utils.point_distance_from_segment(a, b, p)[source]

Calculate distance between point p and segment starting from a and ending in b.

Adapted from https://www.nagwa.com/en/explainers/939127418581/

Parameters:
  • a – Start point of segment

  • b – End point of segment

  • p – Point

Returns:

DIstance between point p and segment

myoconverter.xml.wrap_objects.utils.find_wrap_path(xml, body, tendon, center)[source]

Find locations of wrapping sites within a tendon. This placement is very much based on heuristics, and probably could be improved.

NOTE! This function is not used anywhere. Leaving it here in case it could be useful in the future.

Parameters:
  • xml – OpenSim wrapping object XML element

  • body – MuJoCo body XML element

  • tendon – MuJoCo tendon/spatial XML element

  • center – Position of wrapping object

Returns:

None or a list of indices

Raises:

RuntimeError: If something goes wrong while estimating which wrap object is closest