-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fixes DCMotor clipping for negative power and adds actuator tests #2300
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
Merged
kellyguo11
merged 56 commits into
isaac-sim:main
from
jtigue-bdai:jat/feat/q4_dc_motor_limits
Jul 23, 2025
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
1fa5a8a
add implicit actuator init and effort limit test
jtigue-bdai 3b9d9f7
add edge cases and velocity limit cfg tests
jtigue-bdai 97ea7f0
rename to test_implicit_actuator
jtigue-bdai c1dab1e
cleanup and add ideal_pd tests
jtigue-bdai cddbeb5
add ideal_pd compute test
jtigue-bdai 283ef5c
dc motor clip test for positive power
jtigue-bdai ca7b1a0
change log
jtigue-bdai c6e757f
fix test and clipping
jtigue-bdai 37674e8
update documentation
jtigue-bdai ba0e4e1
update changelog
jtigue-bdai 3e50893
change axes of ascii torque-speed curve
jtigue-bdai a96e1d6
sepereate dc motor tests to anothe file
jtigue-bdai b6138ae
update dc motor docs
jtigue-bdai ee8c3bb
fix test docstring
jtigue-bdai 38db7a0
Merge branch 'main' into jat/feat/q4_dc_motor_limits
kellyguo11 5cce90e
Merge branch 'main' into jat/feat/q4_dc_motor_limits
jtigue-bdai 91863cb
Merge branch 'main' into jat/feat/q4_dc_motor_limits
kellyguo11 03649aa
fix test convertion to pytest
jtigue-bdai a62d818
Merge branch 'main' into jat/feat/q4_dc_motor_limits
jtigue-bdai 4359f0b
fix format
jtigue-bdai 0299af9
Trigger build
jtigue-bdai 96f2365
Trigger build
jtigue-bdai 7cf4b59
Merge branch 'main' into jat/feat/q4_dc_motor_limits
jtigue-bdai c104e38
fix clippling for very large input velocities
jtigue-bdai e42f04f
fix format
jtigue-bdai 14e4df3
reduce numerical clamping
jtigue-bdai 477d25d
Merge branch 'main' into jat/feat/q4_dc_motor_limits
kellyguo11 9816be1
Update extension.toml
kellyguo11 58740b8
Merge branch 'main' into jat/feat/q4_dc_motor_limits
kellyguo11 d207856
add clamp fix to lstm net actuator
jtigue-bdai 43f7f44
Merge branch 'main' into jat/feat/q4_dc_motor_limits
kellyguo11 570537d
add extra dc motor test case
jtigue-bdai 169db35
Merge branch 'main' into jat/feat/q4_dc_motor_limits
jtigue-bdai 94a017f
fix documentation and return lstm actuator to original
jtigue-bdai e434e46
adjust benchmaring configs for testing
jtigue-bdai 228a2d9
clean up format
jtigue-bdai a2620c3
Fix license
jtigue-bdai 55cfedf
Revert actuator_net clip change
jtigue-bdai 9db87eb
format
jtigue-bdai 1da335c
Format
jtigue-bdai 0d5ddd2
add velocity limitation to lstmActuatorNet
jtigue-bdai d0eac46
Trigger Build
jtigue-bdai 4b67629
reset benchmark configs
jtigue-bdai b10c427
remove clipping past the effort limit
jtigue-bdai 378e174
simplify
jtigue-bdai 5c6b01d
Merge branch 'main' into jat/feat/q4_dc_motor_limits
jtigue-bdai 42d1175
fix format
jtigue-bdai 974c645
fix test
jtigue-bdai 50df3a8
Trigger Build
jtigue-bdai 9de13ec
Merge branch 'main' into jat/feat/q4_dc_motor_limits
jtigue-bdai 73404aa
Apply suggestions from code review
jtigue-bdai dcb9362
Apply suggestions from code review
jtigue-bdai a782a50
Update source/isaaclab/docs/CHANGELOG.rst
jtigue-bdai 0c3e532
Merge branch 'main' into jat/feat/q4_dc_motor_limits
jtigue-bdai 110d194
Merge branch 'main' into jat/feat/q4_dc_motor_limits
kellyguo11 c39a235
Update extension.toml
kellyguo11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
# Copyright (c) 2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
from isaaclab.app import AppLauncher | ||
|
||
HEADLESS = True | ||
|
||
# if not AppLauncher.instance(): | ||
simulation_app = AppLauncher(headless=HEADLESS).app | ||
|
||
"""Rest of imports follows""" | ||
|
||
import torch | ||
|
||
import pytest | ||
|
||
from isaaclab.actuators import DCMotorCfg | ||
|
||
|
||
@pytest.mark.parametrize("num_envs", [1, 2]) | ||
@pytest.mark.parametrize("num_joints", [1, 2]) | ||
@pytest.mark.parametrize("device", ["cuda:0", "cpu"]) | ||
def test_dc_motor_init_minimum(num_envs, num_joints, device): | ||
joint_names = [f"joint_{d}" for d in range(num_joints)] | ||
joint_ids = [d for d in range(num_joints)] | ||
stiffness = 200 | ||
damping = 10 | ||
effort_limit = 60.0 | ||
saturation_effort = 100.0 | ||
velocity_limit = 50 | ||
|
||
actuator_cfg = DCMotorCfg( | ||
joint_names_expr=joint_names, | ||
stiffness=stiffness, | ||
damping=damping, | ||
effort_limit=effort_limit, | ||
saturation_effort=saturation_effort, | ||
velocity_limit=velocity_limit, | ||
) | ||
# assume Articulation class: | ||
# - finds joints (names and ids) associate with the provided joint_names_expr | ||
|
||
actuator = actuator_cfg.class_type( | ||
actuator_cfg, | ||
joint_names=joint_names, | ||
joint_ids=joint_ids, | ||
num_envs=num_envs, | ||
device=device, | ||
) | ||
|
||
# check device and shape | ||
torch.testing.assert_close(actuator.computed_effort, torch.zeros(num_envs, num_joints, device=device)) | ||
torch.testing.assert_close(actuator.applied_effort, torch.zeros(num_envs, num_joints, device=device)) | ||
torch.testing.assert_close( | ||
actuator.effort_limit, | ||
effort_limit * torch.ones(num_envs, num_joints, device=device), | ||
) | ||
torch.testing.assert_close( | ||
actuator.velocity_limit, velocity_limit * torch.ones(num_envs, num_joints, device=device) | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("num_envs", [1, 2]) | ||
@pytest.mark.parametrize("num_joints", [1, 2]) | ||
@pytest.mark.parametrize("device", ["cuda", "cpu"]) | ||
@pytest.mark.parametrize("test_point", range(20)) | ||
def test_dc_motor_clip(num_envs, num_joints, device, test_point): | ||
r"""Test the computation of the dc motor actuator 4 quadrant torque speed curve. | ||
torque_speed_pairs of interest: | ||
|
||
0 - fully inside torque speed curve and effort limit (quadrant 1) | ||
1 - greater than effort limit but under torque-speed curve (quadrant 1) | ||
2 - greater than effort limit and outside torque-speed curve (quadrant 1) | ||
3 - less than effort limit but outside torque speed curve (quadrant 1) | ||
4 - less than effort limit but outside torque speed curve and outside corner velocity(quadrant 4) | ||
5 - fully inside torque speed curve and effort limit (quadrant 4) | ||
6 - fully outside torque speed curve and -effort limit (quadrant 4) | ||
7 - fully inside torque speed curve, outside -effort limit, and inside corner velocity (quadrant 4) | ||
8 - fully inside torque speed curves, outside -effort limit, and outside corner velocity (quadrant 4) | ||
9 - less than effort limit but outside torque speed curve and inside corner velocity (quadrant 4) | ||
e - effort_limit | ||
s - saturation_effort | ||
v - velocity_limit | ||
c - corner velocity | ||
\ - torque-speed linear boundary between v and s | ||
each torque_speed_point will be tested in quadrant 3 and 4 | ||
=========================================================== | ||
Torque | ||
\ (+) | ||
\ | | ||
Q2 s Q1 | ||
| \ 2 | ||
\ | 1 \ | ||
c ---------------------e-----\ | ||
\ | \ | ||
\ | 0 \ 3 | ||
\ | \ | ||
(-)-----------v -------------o-------------v --------------(+) Speed | ||
\ | \ 9 4 | ||
\ | 5 \ | ||
\ | \ | ||
\ -----e---------------------c | ||
\ | \ 6 | ||
Q3 \ | 7 Q4 \ | ||
\s \ | ||
|\ 8 \ | ||
(-) \ | ||
============================================================ | ||
""" | ||
effort_lim = 60 | ||
saturation_effort = 100.0 | ||
velocity_limit = 50 | ||
|
||
torque_speed_pairs = [ | ||
(30.0, 10.0), # 0 | ||
(70.0, 10.0), # 1 | ||
(80.0, 40.0), # 2 | ||
(30.0, 40.0), # 3 | ||
(-20.0, 90.0), # 4 | ||
(-30.0, 10.0), # 5 | ||
(-80.0, 110.0), # 6 | ||
(-80.0, 50.0), # 7 | ||
(-120.0, 90.0), # 8 | ||
(-10.0, 70.0), # 9 | ||
(-30.0, -10.0), # -0 | ||
(-70.0, -10.0), # -1 | ||
(-80.0, -40.0), # -2 | ||
(-30.0, -40.0), # -3 | ||
(20.0, -90.0), # -4 | ||
(30.0, -10.0), # -5 | ||
(80.0, -110.0), # -6 | ||
(80.0, -50.0), # -7 | ||
(120.0, -90.0), # -8 | ||
(10.0, -70.0), # -9 | ||
] | ||
expected_clipped_effort = [ | ||
30.0, # 0 | ||
60.0, # 1 | ||
20.0, # 2 | ||
20.0, # 3 | ||
-60.0, # 4 | ||
-30.0, # 5 | ||
-60.0, # 6 | ||
-60.0, # 7 | ||
-60.0, # 8 | ||
-40.0, # 9 | ||
-30.0, # -0 | ||
-60.0, # -1 | ||
-20, # -2 | ||
-20, # -3 | ||
60.0, # -4 | ||
30.0, # -5 | ||
60.0, # -6 | ||
60.0, # -7 | ||
60.0, # -8 | ||
40.0, # -9 | ||
] | ||
|
||
joint_names = [f"joint_{d}" for d in range(num_joints)] | ||
joint_ids = [d for d in range(num_joints)] | ||
stiffness = 200 | ||
damping = 10 | ||
actuator_cfg = DCMotorCfg( | ||
joint_names_expr=joint_names, | ||
stiffness=stiffness, | ||
damping=damping, | ||
effort_limit=effort_lim, | ||
velocity_limit=velocity_limit, | ||
saturation_effort=saturation_effort, | ||
) | ||
|
||
actuator = actuator_cfg.class_type( | ||
actuator_cfg, | ||
joint_names=joint_names, | ||
joint_ids=joint_ids, | ||
num_envs=num_envs, | ||
device=device, | ||
stiffness=actuator_cfg.stiffness, | ||
damping=actuator_cfg.damping, | ||
) | ||
|
||
ts = torque_speed_pairs[test_point] | ||
torque = ts[0] | ||
speed = ts[1] | ||
actuator._joint_vel[:] = speed * torch.ones(num_envs, num_joints, device=device) | ||
effort = torque * torch.ones(num_envs, num_joints, device=device) | ||
clipped_effort = actuator._clip_effort(effort) | ||
torch.testing.assert_close( | ||
expected_clipped_effort[test_point] * torch.ones(num_envs, num_joints, device=device), | ||
clipped_effort, | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.