-
Notifications
You must be signed in to change notification settings - Fork 61
Implement adjustable center of gravity [AARD-1921]
#1259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to standardize our language around Center of Mass vs Center of Gravity?
if (rootNodeId) { | ||
const robotTransform = convertJoltMat44ToThreeMatrix4( | ||
World.physicsSystem.getBody(rootNodeId).GetWorldTransform() | ||
) | ||
const robotWorldPos = new THREE.Vector3() | ||
const robotWorldQuat = new THREE.Quaternion() | ||
const robotWorldScale = new THREE.Vector3() | ||
robotTransform.decompose(robotWorldPos, robotWorldQuat, robotWorldScale) | ||
|
||
const worldCoG = this._modifiedCenterOfGravity.clone() | ||
worldCoG.applyQuaternion(robotWorldQuat) | ||
worldCoG.add(robotWorldPos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code looks duplicated from earlier
|
||
const mass = 1 / inverseMass | ||
|
||
const correctionFactor = (mass / totalMass) * this._cogEffectStrength |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why there is a coefficient here on the gravity force?
} | ||
|
||
const CenterOfGravityInterface: React.FC<CenterOfGravityInterfaceProps> = ({ selectedRobot }) => { | ||
const gizmoRef = useRef<GizmoSceneObject | undefined>(undefined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the physics of the robot should be paused while doing this so it doesn't move around while you're setting the CoM
setEffectStrength(value) | ||
selectedRobot.cogEffectStrength = value | ||
}} | ||
tooltip="Adjusts how strongly the modified center of gravity affects the robot's physics (0 = no effect, 1 = normal, 2 = exaggerated)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like what does exaggerated mean? Shouldn't there be a "correct" amount? And why is it a discrete integer slider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like what does exaggerated mean?
See above:
This PR adds a config for robots that allows you to ... adjust the torque output consequence (the functional equivalent of scaling the weight of the robot).
Shouldn't there be a "correct" amount? And why is it a discrete integer slider?
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case I think it would make more sense to give it units and call it mass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case I think it would make more sense to give it units
It's a scale
and call it mass
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops meant to request changes
Task
AARD-1921
This PR adds a config for robots that allows you to move their center of gravity, and allows you to adjust the torque output consequence (the functional equivalent of scaling the weight of the robot).
Symptom
A user may wish to observe the physical output of the robot when its weight is at a pre-calculated or desired position. This is most often used for setting safety limits on move/rotation speeds.
Solution
To simulate a modified center-of-gravity, we compute the lever arm between where the gravitational force acts and where it "should" act, and gives us a rotational moment (torque). This torque is calculated, dampened (to avoid Jolt-related inaccuracies), and then distributed to each rigid body.
Verification
Place the center-of-gravity at various points and observe the effect on the robot's balance. Verifying using real values is not feasible due to limitations in Jolt.
Before merging, ensure the following criteria are met: