hmi.physics
Class PhysicalHumanoid

java.lang.Object
  extended by hmi.physics.PhysicalHumanoid
Direct Known Subclasses:
OdeHumanoid

public abstract class PhysicalHumanoid
extends Object


Field Summary
private  boolean bIsEnabled
           
private  float[] COM
           
private  float[] COMDiff
           
private  float[] COMNoContacts
           
private  float[] COMNoContactsDiff
           
private  float[] COMOffset
           
private  float[] COMOffsetDiff
           
private  String id
           
protected  List<PhysicalJoint> joints
           
(package private)  float[] m
           
protected  HashMap<String,PhysicalJoint> namePhysicalJointMap
           
protected  HashMap<String,PhysicalSegment> nameSegmentMap
           
private  float offsetMass
           
private  float[] qTemp
           
protected  float[] rootRotationBuffer
           
private  PhysicalSegment rootSegment
           
protected  float[] rootTranslationBuffer
           
private  List<PhysicalSegment> segments
           
private  float[] v1
           
private  float[] v2
           
private  float[] v3
           
private  float[] vecTemp
           
 
Constructor Summary
PhysicalHumanoid(String id)
          Constructor
 
Method Summary
 void addRootSegment(PhysicalSegment segment)
           
 void addSegment(PhysicalSegment segment)
           
 void clear()
          Cleans up joint structure, call when the human is removed
 void copy()
          copy the simulation info to the root and joint local translation and rotation buffers
abstract  PhysicalHumanoid createNew(String id)
          Create a new PhysicalHumanoid of the same type
abstract  PhysicalSegment createSegment(String segmentId, String segmentSid)
          Creates a PhysicalSegment of the correct type for this PhysicalHumanoid subclass and makes sure its rigid body exists
 float[] getCOM()
           
 float[] getCOMDiff()
           
 float[] getCOMNoContacts()
          Get the COM excluding feet weights
 float[] getCOMNoContactsDiff()
          Get the dCOM/dt excluding feet weights
 float[] getCOMOffset()
           
 float[] getCOMOffsetDiff()
           
 float getCOMOffsetMass()
           
 String getId()
           
 PhysicalJoint getJoint(String name)
          Get the PhysicalJoint with this name in the Humanoid
 List<PhysicalJoint> getJoints()
           
 PhysicalSegment getRootSegment()
           
 PhysicalSegment getSegment(String name)
          Get the PhysicalSegment with this start joint
 PhysicalSegment[] getSegments()
          Gets an array of segments, including the root segment.
 float getTotalMass()
          Gets the total mass of the humanoid
protected  void handleCollisions()
           
 boolean isEnabled()
           
 void removeFromHashMap(PhysicalSegment ps)
          Removes a physical segment from the name->segment hashmap
 void removeSegment(PhysicalSegment segment)
           
 void set(PhysicalHumanoid ph)
          Sets the CoM and derivates + all segments with the matching names to the state of ph COMOffset is set to 0
 void setCOMOffset(float[] offset, float mass)
          Offsets the COM
 void setEnabled(boolean enabled)
          Disables or enables the PhysicalHumanoid.
private  void setJoint(VJoint vj)
           
private  void setNullPoseForJoint(VJoint vj)
           
 void setNullPoseFromVJoint(VJoint vj)
           
 void setPoseFromVJoint(VJoint vj)
           
 void setRelativeTranslation(float[] trans)
          Translates the physical humanoid
 void setRelativeTranslation(float x, float y, float z)
          Translates the physical humanoid
 void setRootRotationBuffer(float[] rootRotationBuffer)
           
 void setRootSegment(PhysicalSegment rs)
           
private  void setRootSimInfo()
           
 void setRootTranslationBuffer(float[] rootTranslationBuffer)
           
 void setRotation(float[] center, float[] q)
          Rotates the physical humanoid around some center
 void setupHashMaps(PhysicalSegment ps)
          Add a PhysicalSegment to the name->segment HashMap
abstract  PhysicalJoint setupJoint(String name, PhysicalSegment seg1, PhysicalSegment seg2, float[] anchor)
          Creates a PhysicalJoint
 String toString()
          Get String representation
 void updateCollision()
          Checks if segments touch the ground and updates their onGrounds accordingly.
 void updateCOM(float timeStep)
          Calculates the new Center Of Mass COM and COMDiff (=dCOM/dt)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bIsEnabled

private boolean bIsEnabled

COM

private float[] COM

COMDiff

private float[] COMDiff

COMNoContacts

private float[] COMNoContacts

COMNoContactsDiff

private float[] COMNoContactsDiff

COMOffset

private float[] COMOffset

COMOffsetDiff

private float[] COMOffsetDiff

vecTemp

private float[] vecTemp

qTemp

private float[] qTemp

segments

private List<PhysicalSegment> segments

joints

protected List<PhysicalJoint> joints

rootSegment

private PhysicalSegment rootSegment

nameSegmentMap

protected HashMap<String,PhysicalSegment> nameSegmentMap

namePhysicalJointMap

protected HashMap<String,PhysicalJoint> namePhysicalJointMap

rootTranslationBuffer

protected float[] rootTranslationBuffer

rootRotationBuffer

protected float[] rootRotationBuffer

offsetMass

private float offsetMass

id

private String id

m

float[] m

v1

private float[] v1

v2

private float[] v2

v3

private float[] v3
Constructor Detail

PhysicalHumanoid

public PhysicalHumanoid(String id)
Constructor

Method Detail

removeSegment

public void removeSegment(PhysicalSegment segment)

addSegment

public void addSegment(PhysicalSegment segment)

addRootSegment

public void addRootSegment(PhysicalSegment segment)

set

public void set(PhysicalHumanoid ph)
Sets the CoM and derivates + all segments with the matching names to the state of ph COMOffset is set to 0

Parameters:
ph -

setupJoint

public abstract PhysicalJoint setupJoint(String name,
                                         PhysicalSegment seg1,
                                         PhysicalSegment seg2,
                                         float[] anchor)
Creates a PhysicalJoint

Parameters:
name - joint name
seg1 - corresponds with visual parent segment
seg2 - corresponds with visual segment that rotates with the joint
anchor - world position of the joint anchor
Returns:
the created joint

createSegment

public abstract PhysicalSegment createSegment(String segmentId,
                                              String segmentSid)
Creates a PhysicalSegment of the correct type for this PhysicalHumanoid subclass and makes sure its rigid body exists

Returns:
the created segment

createNew

public abstract PhysicalHumanoid createNew(String id)
Create a new PhysicalHumanoid of the same type


getSegments

public PhysicalSegment[] getSegments()
Gets an array of segments, including the root segment. This is a copy of the actual arraylist containing the segments, so changes to the array itself do not affect the PhysicalHumanoid.


getJoint

public PhysicalJoint getJoint(String name)
Get the PhysicalJoint with this name in the Humanoid

Parameters:
name - joint name
Returns:
the PhysicalJoint

getSegment

public PhysicalSegment getSegment(String name)
Get the PhysicalSegment with this start joint

Parameters:
name - name of the startJoint
Returns:
the PhysicalSegment

removeFromHashMap

public void removeFromHashMap(PhysicalSegment ps)
Removes a physical segment from the name->segment hashmap

Parameters:
ps - the segment to remove

setupHashMaps

public void setupHashMaps(PhysicalSegment ps)
Add a PhysicalSegment to the name->segment HashMap

Parameters:
ps - the segment

copy

public void copy()
copy the simulation info to the root and joint local translation and rotation buffers


updateCollision

public void updateCollision()
Checks if segments touch the ground and updates their onGrounds accordingly. The default implementation sets all onGrounds to false, subclasses have to implement the handleCollisions function to detect ground collision.


setEnabled

public void setEnabled(boolean enabled)
Disables or enables the PhysicalHumanoid. Disabled Humanoids are not updated with the physical simulation step and do not collide with other bodies.

Parameters:
enabled -

isEnabled

public boolean isEnabled()

getTotalMass

public float getTotalMass()
Gets the total mass of the humanoid

Returns:
the total mass

setCOMOffset

public void setCOMOffset(float[] offset,
                         float mass)
Offsets the COM

Parameters:
offset - offset, scaled by mass
mass - mass of the offset

getCOMOffsetMass

public float getCOMOffsetMass()

getCOMOffset

public float[] getCOMOffset()

updateCOM

public void updateCOM(float timeStep)
Calculates the new Center Of Mass COM and COMDiff (=dCOM/dt)

Parameters:
timeStep - time since last update

toString

public String toString()
Get String representation

Overrides:
toString in class Object

getCOM

public float[] getCOM()
Returns:
the last calculated COM, use updateCOM to calculate the current COM

getCOMDiff

public float[] getCOMDiff()
Returns:
the last calculated COMDiff, use updateCOM to calculate the current COMDiff

getCOMNoContacts

public float[] getCOMNoContacts()
Get the COM excluding feet weights

Returns:
the COMNoFeet

getCOMNoContactsDiff

public float[] getCOMNoContactsDiff()
Get the dCOM/dt excluding feet weights

Returns:
the COMNoFeetDiff

setRootRotationBuffer

public void setRootRotationBuffer(float[] rootRotationBuffer)
Parameters:
rootRotationBuffer - the rootRotationBuffer to set

setRootTranslationBuffer

public void setRootTranslationBuffer(float[] rootTranslationBuffer)
Parameters:
rootTranslationBuffer - the rootTranslationBuffer to set

setRootSimInfo

private void setRootSimInfo()

clear

public void clear()
Cleans up joint structure, call when the human is removed


setRelativeTranslation

public void setRelativeTranslation(float[] trans)
Translates the physical humanoid

Parameters:
trans - new physical world position of the humanoid

setRotation

public void setRotation(float[] center,
                        float[] q)
Rotates the physical humanoid around some center

Parameters:
center -
q -

setRelativeTranslation

public void setRelativeTranslation(float x,
                                   float y,
                                   float z)
Translates the physical humanoid


handleCollisions

protected void handleCollisions()

getId

public String getId()
Returns:
the id

setJoint

private void setJoint(VJoint vj)

setPoseFromVJoint

public void setPoseFromVJoint(VJoint vj)

setNullPoseFromVJoint

public void setNullPoseFromVJoint(VJoint vj)

setNullPoseForJoint

private void setNullPoseForJoint(VJoint vj)

getCOMOffsetDiff

public float[] getCOMOffsetDiff()
Returns:
the cOMOffsetDiff, scaled by mass

getRootSegment

public PhysicalSegment getRootSegment()
Returns:
the rootSegment

setRootSegment

public void setRootSegment(PhysicalSegment rs)

getJoints

public List<PhysicalJoint> getJoints()
Returns:
an unmodifiable view of the joint list