Skip to content

Expose qfrc_actuator and qfrc_external on EntityData#779

Merged
kevinzakka merged 1 commit intomainfrom
qfrc-accessors
Mar 12, 2026
Merged

Expose qfrc_actuator and qfrc_external on EntityData#779
kevinzakka merged 1 commit intomainfrom
qfrc-accessors

Conversation

@kevinzakka
Copy link
Collaborator

@kevinzakka kevinzakka commented Mar 11, 2026

MuJoCo decomposes generalized forces into physically distinct components but EntityData only exposed actuator_force (in actuation space, not joint space).

This adds qfrc_actuator (actuator forces projected into joint space through the transmission) and qfrc_external (recovers the J^T * xfrc_applied contribution that MuJoCo folds into qfrc_smooth without storing separately). Also removes generalized_force which was bugged (indexed free joint DOFs instead of articulated DOFs) and had an ambiguous name.

Fixes electrical_power_cost to use qfrc_actuator instead of actuator_force so mechanical power is correct for actuators with non-unit gear ratios.

Fixes #776

Add qfrc_actuator (actuator forces in joint space) and qfrc_external
(J^T * xfrc_applied contribution recovered from the qfrc_smooth identity)
as read-only properties on EntityData, sliced to entity joint DOFs.

Remove generalized_force which was bugged (indexed free joint DOFs instead
of articulated DOFs) and had an ambiguous name. Update joint_torques error
message to point to the new accessors.

Fix electrical_power_cost to use qfrc_actuator instead of actuator_force
so mechanical power is correct for actuators with non-unit gear ratios.

Fixes #776
@kevinzakka kevinzakka changed the title Expose generalized force decomposition on EntityData Expose qfrc_actuator and qfrc_external on EntityData Mar 12, 2026
@kevinzakka kevinzakka merged commit 5daa440 into main Mar 12, 2026
15 checks passed
@kevinzakka kevinzakka deleted the qfrc-accessors branch March 12, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can obtain full external force on a specific link (Body), but cannot directly get its mapped joint-space torque

1 participant