Skip to content

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

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

ariesninjadev
Copy link
Contributor

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:

  • All acceptance criteria outlined in the ticket are met.
  • Necessary test cases have been added and updated.
  • A feature toggle or safe disable path has been added (if applicable).
  • User-facing polish:
    • Ask: "Is this ready-looking?"
  • Cross-linking between Jira and GitHub:
    • PR links to the relevant Jira issue.
    • Jira ticket has a comment referencing this PR.

@ariesninjadev ariesninjadev self-assigned this Aug 6, 2025
@ariesninjadev ariesninjadev added the physics Relating to either the underlying physics engine or the usage of it label Aug 6, 2025
@ariesninjadev ariesninjadev requested a review from a team as a code owner August 6, 2025 17:44
@ariesninjadev ariesninjadev added the gameplay Relating to the playability of Synthesis label Aug 6, 2025
@ariesninjadev ariesninjadev requested a review from a team as a code owner August 6, 2025 17:44
Copy link
Member

@rutmanz rutmanz left a 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?

Comment on lines +511 to +522
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)
Copy link
Member

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 CenterOfGravityInterface: React.FC<CenterOfGravityInterfaceProps> = ({ selectedRobot }) => {
const gizmoRef = useRef<GizmoSceneObject | undefined>(undefined)
Copy link
Member

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

Copy link
Member

@rutmanz rutmanz left a 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

@ariesninjadev ariesninjadev requested a review from rutmanz August 18, 2025 09:16
Copy link
Member

@rutmanz rutmanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like the previous review was fully addressed

@ariesninjadev
Copy link
Contributor Author

Doesn't look like the previous review was fully addressed

Yes, I disagree with your suggestion that the physics be paused because if the user creates a try-and-repeat test scenario that involves any form of movement when pinpointing their CoG, this feature would prevent them from doing so. There are few or no cases where perpetual robot movement significantly impacts the selection.

It also wasn't made clear where the code was duplicated from (hence the emoji reaction), I searched for 5 minutes and then stopped with the presumption that it didn't matter enough to spend more time on; if it's truly a concern, then I will address it I suppose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gameplay Relating to the playability of Synthesis physics Relating to either the underlying physics engine or the usage of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants