Skip to content

Commit

Permalink
Adjusted com calcs (#769)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stermere committed Jul 7, 2023
1 parent 7f11534 commit d227b97
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ public class LegTweakBuffer {
// hyperparameters
public static final float SKATING_DISTANCE_CUTOFF = 0.5f;
static float SKATING_VELOCITY_THRESHOLD = 2.4f;
static float SKATING_ACCELERATION_THRESHOLD = 0.7f;
static float SKATING_ACCELERATION_THRESHOLD = 0.8f;
private static final float SKATING_ROTVELOCITY_THRESHOLD = 4.5f;
private static final float SKATING_LOCK_ENGAGE_PERCENT = 0.85f;
private static final float SKATING_ACCELERATION_Y_USE_PERCENT = 0.25f;
private static final float FLOOR_DISTANCE_CUTOFF = 0.125f;
private static final float SIX_TRACKER_TOLERANCE = -0.10f;
private static final Vector3 FORCE_VECTOR_TO_PRESSURE = new Vector3(0.25f, 1.0f, 0.25f);
Expand Down Expand Up @@ -523,17 +522,9 @@ private LegTweakBuffer getNParent(int n) {
// compute the acceleration magnitude of the feet from the acceleration
// given by the imus (exclude y)
private void computeAccelerationMagnitude() {
leftFootAccelerationMagnitude = new Vector3(
leftFootAcceleration.getX(),
leftFootAcceleration.getY() * SKATING_ACCELERATION_Y_USE_PERCENT,
leftFootAcceleration.getZ()
).len();
leftFootAccelerationMagnitude = leftFootAcceleration.len();

rightFootAccelerationMagnitude = new Vector3(
rightFootAcceleration.getX(),
rightFootAcceleration.getY() * SKATING_ACCELERATION_Y_USE_PERCENT,
rightFootAcceleration.getZ()
).len();
rightFootAccelerationMagnitude = rightFootAcceleration.len();
}

// compute the velocity and acceleration of the center of mass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public class LegTweaks {

// hyperparameters (COM calculation)
// mass percentages of the body
private static final float HEAD_MASS = 0.082f;
private static final float UPPER_CHEST_MASS = 0.125f;
private static final float CHEST_MASS = 0.125f;
private static final float WAIST_MASS = 0.209f;
private static final float THIGH_MASS = 0.128f;
private static final float CALF_MASS = 0.0535f;
private static final float UPPER_ARM_MASS = 0.031f;
private static final float FOREARM_MASS = 0.017f;
private static final float HEAD_MASS = 0.0827f;
private static final float THORAX_MASS = 0.1870f;
private static final float ABDOMEN_MASS = 0.1320f;
private static final float PELVIS_MASS = 0.1530f;
private static final float THIGH_MASS = 0.1122f;
private static final float LEG_AND_FOOT_MASS = 0.0620f;
private static final float UPPER_ARM_MASS = 0.0263f;
private static final float FOREARM_AND_HAND_MASS = 0.0224f;

// hyperparameters (rotation correction)
private static final float ROTATION_CORRECTION_VERTICAL = 0.1f;
Expand Down Expand Up @@ -1097,19 +1097,19 @@ private Vector3 computeCenterOfMass() {
// compute the center of mass of smaller body parts and then sum them up
// with their respective weights
Vector3 head = skeleton.headNode.getWorldTransform().getTranslation();
Vector3 upperChest = skeleton.upperChestNode.getWorldTransform().getTranslation();
Vector3 chest = skeleton.chestNode.getWorldTransform().getTranslation();
Vector3 hip = skeleton.hipNode.getWorldTransform().getTranslation();
Vector3 thorax = getCenterOfJoint(skeleton.chestNode, skeleton.upperChestNode);
Vector3 abdomen = skeleton.waistNode.getWorldTransform().getTranslation();
Vector3 pelvis = skeleton.hipNode.getWorldTransform().getTranslation();
Vector3 leftCalf = getCenterOfJoint(skeleton.leftAnkleNode, skeleton.leftKneeNode);
Vector3 rightCalf = getCenterOfJoint(skeleton.rightAnkleNode, skeleton.rightKneeNode);
Vector3 leftThigh = getCenterOfJoint(skeleton.leftKneeNode, skeleton.leftHipNode);
Vector3 rightThigh = getCenterOfJoint(skeleton.rightKneeNode, skeleton.rightHipNode);
centerOfMass = centerOfMass.plus(head.times(HEAD_MASS));
centerOfMass = centerOfMass.plus(upperChest.times(UPPER_CHEST_MASS));
centerOfMass = centerOfMass.plus(chest.times(CHEST_MASS));
centerOfMass = centerOfMass.plus(hip.times(WAIST_MASS));
centerOfMass = centerOfMass.plus(leftCalf.times(CALF_MASS));
centerOfMass = centerOfMass.plus(rightCalf.times(CALF_MASS));
centerOfMass = centerOfMass.plus(thorax.times(THORAX_MASS));
centerOfMass = centerOfMass.plus(abdomen.times(ABDOMEN_MASS));
centerOfMass = centerOfMass.plus(pelvis.times(PELVIS_MASS));
centerOfMass = centerOfMass.plus(leftCalf.times(LEG_AND_FOOT_MASS));
centerOfMass = centerOfMass.plus(rightCalf.times(LEG_AND_FOOT_MASS));
centerOfMass = centerOfMass.plus(leftThigh.times(THIGH_MASS));
centerOfMass = centerOfMass.plus(rightThigh.times(THIGH_MASS));

Expand All @@ -1129,17 +1129,17 @@ private Vector3 computeCenterOfMass() {
);
centerOfMass = centerOfMass.plus(leftUpperArm.times(UPPER_ARM_MASS));
centerOfMass = centerOfMass.plus(rightUpperArm.times(UPPER_ARM_MASS));
centerOfMass = centerOfMass.plus(leftForearm.times(FOREARM_MASS));
centerOfMass = centerOfMass.plus(rightForearm.times(FOREARM_MASS));
centerOfMass = centerOfMass.plus(leftForearm.times(FOREARM_AND_HAND_MASS));
centerOfMass = centerOfMass.plus(rightForearm.times(FOREARM_AND_HAND_MASS));
} else {
// if the arms are not available put them slightly in front
// of the upper chest.
Vector3 chestUnitVector = computeUnitVector(
skeleton.upperChestNode.getWorldTransform().getRotation()
);
Vector3 armLocation = chest.plus(chestUnitVector.times(DEFAULT_ARM_DISTANCE));
Vector3 armLocation = abdomen.plus(chestUnitVector.times(DEFAULT_ARM_DISTANCE));
centerOfMass = centerOfMass.plus(armLocation.times(UPPER_ARM_MASS * 2.0f));
centerOfMass = centerOfMass.plus(armLocation.times(FOREARM_MASS * 2.0f));
centerOfMass = centerOfMass.plus(armLocation.times(FOREARM_AND_HAND_MASS * 2.0f));
}

// finally translate in to tracker space
Expand Down

0 comments on commit d227b97

Please sign in to comment.