pagoda.skeleton.Skeleton

class pagoda.skeleton.Skeleton(world)[source]

A skeleton is a group of rigid bodies connected with articulated joints.

Commonly, the skeleton is used to represent an articulated body that is capable of mimicking the motion of the human body.

Most often, skeletons are configured by parsing information from a text file of some sort. See pagoda.parser.BodyParser for more information about the format of the text file. Skeletons can also be loaded from text files in ASF format; see pagoda.parser.AsfParser for more information.

Parameters:

world : pagoda.physics.World

A world object that holds bodies and joints for physics simulation.

Attributes

bodies (list of pagoda.physics.Body) A list of the rigid bodies that comprise this skeleton.
joints (list of pagoda.physics.Joint) A list of the joints that connect bodies in this skeleton.
__init__(world)[source]

Methods

__init__(world)
add_torques(torques) Add torques for each degree of freedom in the skeleton.
disable_motors() Disable joint motors in this skeleton.
enable_motors(max_force) Enable the joint motors in this skeleton.
get_body_states() Return a list of the states of all bodies in the skeleton.
indices_for_body(name[, step]) Get a list of the indices for a specific body.
indices_for_joint(name) Get a list of the indices for a specific joint.
joint_distances() Get the current joint separations for the skeleton.
load(source, **kwargs) Load a skeleton definition from a file.
load_asf(source, **kwargs) Load a skeleton definition from an ASF text file.
load_skel(source, **kwargs) Load a skeleton definition from a text file.
set_body_states(states) Set the states of all bodies in the skeleton.
set_joint_velocities([target]) Set the target velocity for all joints in the skeleton.
set_pid_params(*args, **kwargs) Set PID parameters for all joints in the skeleton.
set_target_angles(angles) Move each joint toward a target angle.

Attributes

body_angular_velocities Get a list of all current body angular velocities in the skeleton.
body_linear_velocities Get a list of all current body velocities in the skeleton.
body_positions Get a list of all current body positions in the skeleton.
body_rotations Get a list of all current body rotations in the skeleton.
cfm
color
erp
joint_angles Get a list of all current joint angles in the skeleton.
joint_torques Get a list of all current joint torques in the skeleton.
joint_velocities Get a list of all current joint velocities in the skeleton.
num_dofs Return the number of degrees of freedom in the skeleton.
add_torques(torques)[source]

Add torques for each degree of freedom in the skeleton.

Parameters:

torques : list of float

A list of the torques to add to each degree of freedom in the skeleton.

body_angular_velocities

Get a list of all current body angular velocities in the skeleton.

body_linear_velocities

Get a list of all current body velocities in the skeleton.

body_positions

Get a list of all current body positions in the skeleton.

body_rotations

Get a list of all current body rotations in the skeleton.

disable_motors()[source]

Disable joint motors in this skeleton.

This method sets to 0 the maximum force that joint motors are allowed to apply, in addition to disabling torque feedback.

enable_motors(max_force)[source]

Enable the joint motors in this skeleton.

This method sets the maximum force that can be applied by each joint to attain the desired target velocities. It also enables torque feedback for all joint motors.

Parameters:

max_force : float

The maximum force that each joint is allowed to apply to attain its target velocity.

get_body_states()[source]

Return a list of the states of all bodies in the skeleton.

indices_for_body(name, step=3)[source]

Get a list of the indices for a specific body.

Parameters:

name : str

The name of the body to look up.

step : int, optional

The number of numbers for each body. Defaults to 3, should be set to 4 for body rotation (since quaternions have 4 values).

Returns:

list of int :

A list of the index values for quantities related to the named body.

indices_for_joint(name)[source]

Get a list of the indices for a specific joint.

Parameters:

name : str

The name of the joint to look up.

Returns:

list of int :

A list of the index values for quantities related to the named joint. Often useful for getting, say, the angles for a specific joint in the skeleton.

joint_angles

Get a list of all current joint angles in the skeleton.

joint_distances()[source]

Get the current joint separations for the skeleton.

Returns:

distances : list of float

A list expressing the distance between the two joint anchor points, for each joint in the skeleton. These quantities describe how “exploded” the bodies in the skeleton are; a value of 0 indicates that the constraints are perfectly satisfied for that joint.

joint_torques

Get a list of all current joint torques in the skeleton.

joint_velocities

Get a list of all current joint velocities in the skeleton.

load(source, **kwargs)[source]

Load a skeleton definition from a file.

Parameters:

source : str or file

A filename or file-like object that contains text information describing a skeleton. See pagoda.parser.Parser for more information about the format of the text file.

load_asf(source, **kwargs)[source]

Load a skeleton definition from an ASF text file.

Parameters:

source : str or file

A filename or file-like object that contains text information describing a skeleton, in ASF format.

load_skel(source, **kwargs)[source]

Load a skeleton definition from a text file.

Parameters:

source : str or file

A filename or file-like object that contains text information describing a skeleton. See pagoda.parser.BodyParser for more information about the format of the text file.

num_dofs

Return the number of degrees of freedom in the skeleton.

set_body_states(states)[source]

Set the states of all bodies in the skeleton.

set_joint_velocities(target=0)[source]

Set the target velocity for all joints in the skeleton.

Often the target is set to 0 to cancel out any desired joint rotation.

Parameters:

target : float, optional

The target velocity for all joints in the skeleton. Defaults to 0.

set_pid_params(*args, **kwargs)[source]

Set PID parameters for all joints in the skeleton.

Parameters for this method are passed directly to the pid constructor.

set_target_angles(angles)[source]

Move each joint toward a target angle.

This method uses a PID controller to set a target angular velocity for each degree of freedom in the skeleton, based on the difference between the current and the target angle for the respective DOF.

PID parameters are by default set to achieve a tiny bit less than complete convergence in one time step, using only the P term (i.e., the P coefficient is set to 1 - delta, while I and D coefficients are set to 0). PID parameters can be updated by calling the set_pid_params method.

Parameters:

angles : list of float

A list of the target angles for every joint in the skeleton.