human Module

The human module defines the Human class, which is composed of Segment’s. The Human class has methods to define the constituent segments from inputs, calculates their properties, and manages file input/output.

class yeadon.human.Human(meas_in, CFG=None, symmetric=True, density_set='Dempster')[source]

Bases: object

CFGbounds = [[-3.141592653589793, 3.141592653589793], [-3.141592653589793, 3.141592653589793], [-3.141592653589793, 3.141592653589793], [-1.5707963267948966, 3.141592653589793], [-1.5707963267948966, 1.5707963267948966], [-1.5707963267948966, 1.5707963267948966], [-1.5707963267948966, 1.5707963267948966], [-3.141592653589793, 1.5707963267948966], [-4.71238898038469, 1.5707963267948966], [-3.141592653589793, 3.141592653589793], [-3.141592653589793, 1.5707963267948966], [-1.5707963267948966, 4.71238898038469], [-3.141592653589793, 3.141592653589793], [-3.141592653589793, 0.0], [-3.141592653589793, 0.0], [-3.141592653589793, 1.5707963267948966], [-1.5707963267948966, 1.5707963267948966], [-3.141592653589793, 1.5707963267948966], [-1.5707963267948966, 1.5707963267948966], [0, 3.141592653589793], [0, 3.141592653589793]]
CFGnames = ('somersault', 'tilt', 'twist', 'PTsagittalFlexion', 'PTbending', 'TCspinalTorsion', 'TCsagittalSpinalFlexion', 'CA1extension', 'CA1adduction', 'CA1rotation', 'CB1extension', 'CB1abduction', 'CB1rotation', 'A1A2extension', 'B1B2extension', 'PJ1extension', 'PJ1adduction', 'PK1extension', 'PK1abduction', 'J1J2flexion', 'K1K2flexion')
calc_properties(self)[source]

Calculates the mass, center of mass, and inertia tensor of the human. The quantities are calculated from the segment quantities.

center_of_mass

Center of mass of the human, a np.ndarray, in units of m, expressed the global frame, from the bottom center of the pelvis (center of the Ls0 stadium).

combine_inertia(self, objlist)[source]

Returns the inertia properties of a combination of solids and/or segments of the human, using the fixed human frame (or the modified fixed frame as given by the user). Be careful with inputs: do not specify a solid that is part of a segment that you have also specified. This method does not assign anything to any object attributes (it is ‘const’), it simply returns the desired quantities.

See documentation for description of the global frame.

Parameters:
objlist : tuple

Tuple of strings that identify a solid or segment. The strings can be any of the following:

  • solids: ‘s0’ through ‘s7’, ‘a0’ through ‘a6’, ‘b0’ through ‘b6’, ‘j0’ through ‘j8’, ‘k0’ through ‘k8’
  • segments: ‘P’, ‘T’, ‘C’, ‘A1’, ‘A2’, ‘B1’, ‘B2’, ‘J1’, ‘J2’, ‘K1’, ‘K2’
Returns:
combined_mass : float

Sum of the masses of the input solids and/or segments.

combined_COM : np.array (3,1)

Position of the center of mass of the input solids and/or segments, expressed in the global frame .

combined_inertia : np.matrix (3,3)

Inertia tensor about the combined_COM, expressed in the global frame.

draw(self, mlabobj=None, gui=False)[source]

Draws the human in 3D in a new window using MayaVi. The mouse can be used to control or explore the 3D view.

Parameters:
mlabobj : mayavi.mlab, optional, default=None

A mayavi mlab object. If None a new one will be created.

gui: boolean, optional, default=False

If false the mlab.show() command will be called and the scene will be displayed to the screen.

get_segment_by_name(self, name)[source]

Returns a segment given its name.

inertia

Inertia matrix/dyadic of the human, a np.matrix, in units of kg-m^2, about the center of mass of the human, expressed in the global frame.

inertia_transformed(self, pos=None, rotmat=None)[source]

Returns an inertia tensor of the human with respect to the position provided in pos and a new frame that is defined by rotation relative to the global frame with the direction cosine matrix rotmat. The position is to be provided from the origin of the global frame, which is at the center of the Ls0 stadium (bottom of pelvis), and its components are expressed in the basis of the global frame. This method does NOT alter any attributes of the Human (it is ‘const’).

Parameters:
pos : array_like, (3,), (1, 3), or (3, 1), optional

Position vector from the origin (center of Ls0) to the point about which the user desires the inertia tensor. This position vector must be expressed in the global reference frame. If not provided, the tensor is given about the center of mass of the human.

rotmat : np.matrix (3,3), optional

If not provided, the returned tensor is expressed in the global frame, else the returned tensor is expressed in the rotated reference frame. Consider N to be the global frame and B to be the frame in which the user desires the inertia tensor. Then rotmat is the rotation matrix that converts a vector expressed in the basis B to a vector expressed in the basis N (i.e. vN = rotmat * vB). That is, the columns of rotmat are the unit vectors b_x, b_y, and b_z, each expressed in the basis given by the unit vectors n_x, n_y, n_z.

Returns:
transformed : np.matrix (3,3)

If B is the frame in which the user desires the inertia tensor, this method returns ^{B}I^{H/P}, where P is the point specified by pos, and H is the human system.

Notes

If N is the global frame, B is the frame in which the user desires the inertia tensor, then rotmat = ^{N}R^{B}.

mass

Mass of the human, in units of kg.

measnames = ('Ls1L', 'Ls2L', 'Ls3L', 'Ls4L', 'Ls5L', 'Ls6L', 'Ls7L', 'Ls8L', 'Ls0p', 'Ls1p', 'Ls2p', 'Ls3p', 'Ls5p', 'Ls6p', 'Ls7p', 'Ls0w', 'Ls1w', 'Ls2w', 'Ls3w', 'Ls4w', 'Ls4d', 'La2L', 'La3L', 'La4L', 'La5L', 'La6L', 'La7L', 'La0p', 'La1p', 'La2p', 'La3p', 'La4p', 'La5p', 'La6p', 'La7p', 'La4w', 'La5w', 'La6w', 'La7w', 'Lb2L', 'Lb3L', 'Lb4L', 'Lb5L', 'Lb6L', 'Lb7L', 'Lb0p', 'Lb1p', 'Lb2p', 'Lb3p', 'Lb4p', 'Lb5p', 'Lb6p', 'Lb7p', 'Lb4w', 'Lb5w', 'Lb6w', 'Lb7w', 'Lj1L', 'Lj3L', 'Lj4L', 'Lj5L', 'Lj6L', 'Lj8L', 'Lj9L', 'Lj1p', 'Lj2p', 'Lj3p', 'Lj4p', 'Lj5p', 'Lj6p', 'Lj7p', 'Lj8p', 'Lj9p', 'Lj8w', 'Lj9w', 'Lj6d', 'Lk1L', 'Lk3L', 'Lk4L', 'Lk5L', 'Lk6L', 'Lk8L', 'Lk9L', 'Lk1p', 'Lk2p', 'Lk3p', 'Lk4p', 'Lk5p', 'Lk6p', 'Lk7p', 'Lk8p', 'Lk9p', 'Lk8w', 'Lk9w', 'Lk6d')
print_properties(self, precision=5, suppress=True)[source]

Prints human mass, center of mass, and inertia.

Parameters:
precision : integer, default=5

The precision for floating point representation.

suppress : boolean, default=True

Print very small values as 0 instead of scientific notation.

Notes

See numpy.set_printoptions for more details on the optional arguments.

scale_human_by_mass(self, measmass)[source]

Takes a measured mass and scales all densities by that mass so that the mass of the human is the same as the mesaured mass. Mass must be in units of kilograms to be consistent with the densities used.

Parameters:
measmass : float

Measured mass of the human in kilograms.

segment_names = ['head-neck', 'shoulders', 'thorax', 'abdomen-pelvis', 'upper-arm', 'forearm', 'hand', 'thigh', 'lower-leg', 'foot']
segmental_densities = {'Chandler': {'abdomen-pelvis': 853, 'foot': 1091, 'forearm': 1052, 'hand': 1080, 'head-neck': 1056, 'lower-leg': 1078, 'shoulders': 853, 'thigh': 1020, 'thorax': 853, 'upper-arm': 1005}, 'Clauser': {'abdomen-pelvis': 1019, 'foot': 1084, 'forearm': 1089, 'hand': 1109, 'head-neck': 1070, 'lower-leg': 1085, 'shoulders': 1019, 'thigh': 1044, 'thorax': 1019, 'upper-arm': 1056}, 'Dempster': {'abdomen-pelvis': 1010, 'foot': 1100, 'forearm': 1130, 'hand': 1160, 'head-neck': 1110, 'lower-leg': 1090, 'shoulders': 1040, 'thigh': 1050, 'thorax': 920, 'upper-arm': 1070}}
set_CFG(self, varname, value)[source]

Allows the user to set a single configuration variable in CFG. CFG is a dictionary that holds all 21 configuration variables. Then, this function validates and updates the human model with the new configuration variable.

Parameters:
varname : str

Must be a valid name of a configuration variable.

value : float

New value for the configuration variable identified by varname. Units are radians. This value will be validated for joint angle limits.

set_CFG_dict(self, CFG)[source]

Allows the user to pass an entirely new CFG dictionary with which to update the human object. Ensure that the dictionary is of the right format (ideally obtain it from a Human object with Human.CFG and modify it). After configuration is update, the segments are updated.

Parameters:
CFG : dict

Stores the 21 joint angles.

update(self)[source]

Redefines all solids and then calls yeadon.Human._update_segments. Called by the method yeadon.Human.scale_human_by_mass. The method is to be used in instances in which measurements change.

write_CFG(self, CFGfname)[source]

Writes the keys and values of the self.CFG dict to a .txt file. Text file is formatted using YAML syntax.

Parameters:
CFGfname : str

Filename or path to configuration output .txt file

write_meas_for_ISEG(self, fname)[source]

Writes the values of the self.meas dict to a .txt file that is formidable as input to Yeadon’s ISEG fortran code that performs similar calculations to this package. ISEG is published in Yeadon’s dissertation.

Parameters:
fname : str

Filename or path for ISEG .txt input file.

write_measurements(self, fname)[source]

Writes the keys and values of the self.meas dict to a text file. Units of measurements is meters.

Parameters:
fname : str

Filename or path to measurement output .txt file.