myoconverter.xml.path_wraps.utils

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

@author: Aleksi Ikkala

Module Contents

Functions

add_wrapping_site(idx, sites, muscle_name, ...)

Add wrapping site to given index.

maybe_add_wrapping_site(idx, sites, muscle_name, ...)

Maybe add a wrapping site to given index.

segment_distance_to_wrapping_object(s1, s2, ...)

Calculate distance between a given segment (straight line between two sites) and a wrapping object.

create_sidesite_name(tendon_name, wrap_object_name, idx)

Utility function to create a name for a {tendon, wrapping object} pair

myoconverter.xml.path_wraps.utils.add_wrapping_site(idx, sites, muscle_name, wrap_object_name, wrap_object_pos, wrap_object_radius, wrap_object_body, wrap_object_body_pos, M_WORLDBODY)[source]

Add wrapping site to given index.

Parameters:
  • idx – Index indicating between which sites a wrapping site is added

  • sites – List of MuJoCo sites

  • muscle_name – Name of the actuator/tendon to which this wrapping site belongs

  • wrap_object_name – Name of wrapping object

  • wrap_object_pos – Position of wrapping object

  • wrap_object_radius – Radius of wrapping object

  • wrap_object_body – MuJoCo Body where wrapping object is located

  • wrap_object_body_pos – Position of the wrap_object_body

  • M_WORLDBODY – Pointer to MuJoCo XML worldbody element

Returns:

Dictionary with wrapping site info

myoconverter.xml.path_wraps.utils.maybe_add_wrapping_site(idx, sites, muscle_name, wrap_object_name, wrap_object_pos, wrap_object_radius, wrap_object_body, wrap_object_body_pos, params, M_WORLDBODY)[source]

Maybe add a wrapping site to given index.

Wrapping site not added if one of the proposed sites is a ConditionalPathPoint or a MovingPathPoint. We can currently only add wrapping sites between stationary PathPoints.

Parameters:
  • idx – Index indicating between which sites a wrapping site is added

  • sites – List of MuJoCo sites

  • muscle_name – Name of the actuator/tendon to which this wrapping site belongs

  • wrap_object_name – Name of wrapping object

  • wrap_object_pos – Position of wrapping object

  • wrap_object_radius – Radius of wrapping object

  • wrap_object_body – MuJoCo Body where wrapping object is located

  • wrap_object_body_pos – Position of the wrap_object_body

  • params – Dictionary with wrapping site info for an existing wrapping site (for this idx)

  • M_WORLDBODY – Pointer to MuJoCo XML worldbody element

Returns:

Dictionary with wrapping site info, boolean indicating whether a warning should be raised

myoconverter.xml.path_wraps.utils.segment_distance_to_wrapping_object(s1, s2, wrap_object_pos, M_WORLDBODY)[source]

Calculate distance between a given segment (straight line between two sites) and a wrapping object.

Parameters:
  • s1 – Start point (site) of the segment

  • s2 – End point (site) of the segment

  • wrap_object_pos – Position of the wrapping object

  • M_WORLDBODY – Pointer to MuJoCo XML ‘worldbody’ element

Returns:

Distances between 10 points in the segment and the wrapping object, and positions of those points

myoconverter.xml.path_wraps.utils.create_sidesite_name(tendon_name, wrap_object_name, idx)[source]

Utility function to create a name for a {tendon, wrapping object} pair

Parameters:
  • tendon_name – Name of the tendon that wraps around the wrapping object

  • wrap_object_name – Wrapping object name

  • idx – Running index to keep the sidesite names unique

Returns:

Unique name for a sidesite