-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[Newton] Full Rigid Body Support #4385
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/newton
Are you sure you want to change the base?
[Newton] Full Rigid Body Support #4385
Conversation
Greptile Summary
Important Files Changed
Confidence score: 2/5
|
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.
18 files reviewed, 30 comments
|
|
||
| class RigidObject(FactoryBase): | ||
| class RigidObject(FactoryBase, BaseRigidObject): | ||
| """Factory for creating articulation instances.""" |
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.
syntax: Docstring incorrectly refers to 'articulation instances' instead of 'rigid object instances'
| """Factory for creating articulation instances.""" | |
| """Factory for creating rigid object instances.""" |
| """Benchmark a single property of ArticulationData. | ||
| Args: | ||
| articulation_data: The ArticulationData instance. | ||
| mock_view: The mock view for setting random data. | ||
| property_name: Name of the property to benchmark. | ||
| config: Benchmark configuration. | ||
| Returns: | ||
| BenchmarkResult with timing statistics. | ||
| """ |
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.
syntax: Docstring incorrectly references ArticulationData instead of RigidObjectData
| """Benchmark a single property of ArticulationData. | |
| Args: | |
| articulation_data: The ArticulationData instance. | |
| mock_view: The mock view for setting random data. | |
| property_name: Name of the property to benchmark. | |
| config: Benchmark configuration. | |
| Returns: | |
| BenchmarkResult with timing statistics. | |
| """ | |
| """Benchmark a single property of RigidObjectData. | |
| Args: | |
| rigid_object_data: The RigidObjectData instance. | |
| mock_view: The mock view for setting random data. | |
| property_name: Name of the property to benchmark. | |
| config: Benchmark configuration. | |
| Returns: | |
| BenchmarkResult with timing statistics. | |
| """ |
| """Run all benchmarks for ArticulationData. | ||
| Args: | ||
| config: Benchmark configuration. | ||
| Returns: | ||
| Tuple of (List of BenchmarkResults, hardware_info dict). |
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.
syntax: Docstring incorrectly references ArticulationData instead of RigidObjectData
| """Run all benchmarks for ArticulationData. | |
| Args: | |
| config: Benchmark configuration. | |
| Returns: | |
| Tuple of (List of BenchmarkResults, hardware_info dict). | |
| """Run all benchmarks for RigidObjectData. | |
| Args: | |
| config: Benchmark configuration. | |
| Returns: | |
| Tuple of (List of BenchmarkResults, hardware_info dict). | |
| """ |
| """Generate Warp inputs for set_masses.""" | ||
| return { | ||
| "masses": wp.from_torch( | ||
| torch.rand(config.num_instances, config.num_bodies, device=config.device, dtype=torch.float32), |
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.
style: Mass values should be positive - consider using torch.rand(...) + 0.1 to ensure non-zero masses
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| def play(self): | ||
| """Starts the simulation.""" | ||
|
|
||
| print("Playing simulation") |
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.
style: Debug print statement should be removed before production release
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| print(f"Body com: {wp.to_torch(self._sim_bind_body_com_pos_b)}") | ||
| print(f"Body com shape: {wp.to_torch(self._sim_bind_body_com_pos_b).shape}") |
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.
style: Debug print statements should be removed in production code
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| print(f"Pose: {wp.to_torch(pose)}") | ||
| self._update_array_with_array_masked(pose, self._data.root_link_pose_w, env_mask, self.num_instances) | ||
| print(f"Root link pose: {wp.to_torch(self._data.root_link_pose_w)}") |
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.
style: Debug print statements should be removed before merging to production
| print(f"Pose: {wp.to_torch(pose)}") | |
| self._update_array_with_array_masked(pose, self._data.root_link_pose_w, env_mask, self.num_instances) | |
| print(f"Root link pose: {wp.to_torch(self._data.root_link_pose_w)}") | |
| self._update_array_with_array_masked(pose, self._data.root_link_pose_w, env_mask, self.num_instances) |
| print(self.num_instances, self.num_bodies) | ||
| print(f"Masses: {wp.to_torch(masses)}") | ||
| env_mask = make_masks_from_torch_ids(self.num_instances, env_ids, env_mask, device=self.device) | ||
| body_mask = make_masks_from_torch_ids(self.num_bodies, body_ids, body_mask, device=self.device) | ||
| print(f"Env mask: {env_mask}") | ||
| print(f"Body mask: {body_mask}") | ||
| print(f"Masses: {wp.to_torch(masses)}") |
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.
style: Multiple debug print statements should be removed before production deployment
| print(self.num_instances, self.num_bodies) | |
| print(f"Masses: {wp.to_torch(masses)}") | |
| env_mask = make_masks_from_torch_ids(self.num_instances, env_ids, env_mask, device=self.device) | |
| body_mask = make_masks_from_torch_ids(self.num_bodies, body_ids, body_mask, device=self.device) | |
| print(f"Env mask: {env_mask}") | |
| print(f"Body mask: {body_mask}") | |
| print(f"Masses: {wp.to_torch(masses)}") | |
| env_mask = make_masks_from_torch_ids(self.num_instances, env_ids, env_mask, device=self.device) | |
| body_mask = make_masks_from_torch_ids(self.num_bodies, body_ids, body_mask, device=self.device) |
| env_mask_ = None | ||
| body_mask_ = None | ||
| if isinstance(forces, torch.Tensor) or isinstance(torques, torch.Tensor): | ||
| if forces is not None: | ||
| forces, env_mask, body_mask = self._torch_to_warp_dual_index( | ||
| forces, | ||
| self.num_instances, | ||
| self.num_bodies, | ||
| env_ids, | ||
| body_ids, | ||
| env_mask, | ||
| body_mask, | ||
| dtype=wp.float32, | ||
| forces = make_complete_data_from_torch_dual_index( | ||
| forces, self.num_instances, self.num_bodies, env_ids, body_ids, dtype=wp.vec3f, device=self.device | ||
| ) | ||
| if torques is not None: | ||
| torques, env_mask, body_mask = self._torch_to_warp_dual_index( | ||
| torques, | ||
| self.num_instances, | ||
| self.num_bodies, | ||
| env_ids, | ||
| body_ids, | ||
| env_mask, | ||
| body_mask, | ||
| dtype=wp.float32, | ||
| torques = make_complete_data_from_torch_dual_index( | ||
| torques, self.num_instances, self.num_bodies, env_ids, body_ids, dtype=wp.vec3f, device=self.device | ||
| ) | ||
| env_mask = make_masks_from_torch_ids(self.num_instances, env_ids, env_mask, device=self.device) | ||
| body_mask = make_masks_from_torch_ids(self.num_bodies, body_ids, body_mask, device=self.device) | ||
| # solve for None masks | ||
| if env_mask is None: | ||
| env_mask = self._data.ALL_ENV_MASK | ||
| if body_mask is None: | ||
| body_mask = self._data.ALL_BODY_MASK | ||
| if env_mask_ is None: | ||
| env_mask_ = self._data.ALL_ENV_MASK | ||
| if body_mask_ is None: | ||
| body_mask_ = self._data.ALL_BODY_MASK |
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.
logic: Variable naming inconsistency: env_mask_ and body_mask_ are created but env_mask and body_mask are used in the logic. The underscore variables appear unused. Are the underscore variables (env_mask_, body_mask_) intended to be used instead of the non-underscore versions in the None checks?
|
|
||
| @pytest.mark.skip(reason="For now let's not do that...") | ||
| @pytest.mark.parametrize("num_cubes", [1, 2]) | ||
| @pytest.mark.parametrize("device", ["cuda", "cpu"]) |
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.
syntax: Device parameter inconsistent - uses "cuda" instead of "cuda:0" like other tests
| @pytest.mark.parametrize("device", ["cuda", "cpu"]) | |
| @pytest.mark.parametrize("device", ["cuda:0", "cpu"]) |
… at least). There are still some errors some will be patched by latest newton.
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.
Additional Comments (8)
-
source/isaaclab/isaaclab/assets/rigid_object/rigid_object.py, line 20-30 (link)syntax: Multiple references to 'articulation' instead of 'rigid object' in docstrings and comments create confusion about the class's actual purpose
-
source/isaaclab_newton/test/assets/rigid_object/test_rigid_object.py, line 6-19 (link)syntax: Docstring incorrectly refers to 'Articulation class' throughout instead of 'RigidObject class'
-
source/isaaclab/isaaclab/sim/_impl/newton_manager.py, line 124-131 (link)style: Debug print statements should be removed before production release
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
-
source/isaaclab/isaaclab/sim/_impl/newton_manager.py, line 148-149 (link)style: Debug print statement should be removed before production release
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
-
source/isaaclab/isaaclab/sim/_impl/newton_manager.py, line 193 (link)style: Debug print statement should be removed before production release
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
-
source/isaaclab_newton/test/assets/rigid_object/test_rigid_object_data.py, line 6 (link)syntax: Docstring incorrectly refers to 'ArticulationData' instead of 'RigidObjectData'
-
source/isaaclab_newton/test/assets/rigid_object/test_rigid_object_data.py, line 245 (link)syntax: Variable named 'articulation_data' should be 'rigid_object_data' for consistency
-
source/isaaclab_newton/test/assets/rigid_object/test_rigid_object_data.py, line 254-268 (link)syntax: Multiple references to 'articulation_data' should be 'rigid_object_data'
18 files reviewed, 16 comments
| """Benchmark a single property of ArticulationData. | ||
| Args: | ||
| articulation_data: The ArticulationData instance. | ||
| mock_view: The mock view for setting random data. | ||
| property_name: Name of the property to benchmark. | ||
| config: Benchmark configuration. | ||
| Returns: | ||
| BenchmarkResult with timing statistics. | ||
| """ |
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.
syntax: Docstring incorrectly references ArticulationData instead of RigidObjectData
| """Benchmark a single property of ArticulationData. | |
| Args: | |
| articulation_data: The ArticulationData instance. | |
| mock_view: The mock view for setting random data. | |
| property_name: Name of the property to benchmark. | |
| config: Benchmark configuration. | |
| Returns: | |
| BenchmarkResult with timing statistics. | |
| """ | |
| """Benchmark a single property of RigidObjectData. | |
| Args: | |
| rigid_object_data: The RigidObjectData instance. | |
| mock_view: The mock view for setting random data. | |
| property_name: Name of the property to benchmark. | |
| config: Benchmark configuration. | |
| Returns: | |
| BenchmarkResult with timing statistics. | |
| """ |
| """Run all benchmarks for ArticulationData. | ||
| Args: | ||
| config: Benchmark configuration. | ||
| Returns: | ||
| Tuple of (List of BenchmarkResults, hardware_info dict). |
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.
syntax: Docstring incorrectly references ArticulationData instead of RigidObjectData
| """Run all benchmarks for ArticulationData. | |
| Args: | |
| config: Benchmark configuration. | |
| Returns: | |
| Tuple of (List of BenchmarkResults, hardware_info dict). | |
| """Run all benchmarks for RigidObjectData. | |
| Args: | |
| config: Benchmark configuration. | |
| Returns: | |
| Tuple of (List of BenchmarkResults, hardware_info dict). |
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| """Mock interfaces for testing and benchmarking ArticulationData class.""" |
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.
syntax: Docstring refers to 'ArticulationData class' but this file is for rigid object testing
| """Mock interfaces for testing and benchmarking ArticulationData class.""" | |
| """Mock interfaces for testing and benchmarking RigidObjectData class.""" |
| def set_root_transforms(self, state, transforms: wp.array): | ||
| print(f"Setting root transforms: {transforms}") | ||
| print(f"Root transforms: {self._root_transforms}") | ||
| self._root_transforms.assign(transforms) |
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.
style: Debug print statements should be removed before production release
| def set_root_transforms(self, state, transforms: wp.array): | |
| print(f"Setting root transforms: {transforms}") | |
| print(f"Root transforms: {self._root_transforms}") | |
| self._root_transforms.assign(transforms) | |
| def set_root_transforms(self, state, transforms: wp.array): | |
| self._root_transforms.assign(transforms) |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| tmp_pose = wp.zeros((self.num_instances,), dtype=wp.transformf, device=self._device) | ||
| tmp_velocity = wp.zeros((self.num_instances,), dtype=wp.spatial_vectorf, device=self._device) |
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.
syntax: Device parameter inconsistent - uses self._device instead of self.device like other methods
| tmp_pose = wp.zeros((self.num_instances,), dtype=wp.transformf, device=self._device) | |
| tmp_velocity = wp.zeros((self.num_instances,), dtype=wp.spatial_vectorf, device=self._device) | |
| tmp_pose = wp.zeros((self.num_instances,), dtype=wp.transformf, device=self.device) | |
| tmp_velocity = wp.zeros((self.num_instances,), dtype=wp.spatial_vectorf, device=self.device) |
| """Test zero instantiated articulation data.""" | ||
| # Setup the articulation data |
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.
syntax: Test method docstring incorrectly mentions 'articulation data' instead of 'rigid object data'
| """Test zero instantiated articulation data.""" | |
| # Setup the articulation data | |
| """Test zero instantiated rigid object data.""" | |
| # Setup the rigid object data |
| @@ -111,792 +98,28 @@ def test_zero_instantiated(self, mock_newton_manager, num_instances: int, num_do | |||
| def test_settable(self, mock_newton_manager, num_instances: int, num_dofs: int, device: str): | |||
| """Test that the articulation data is settable.""" | |||
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.
syntax: Comment incorrectly refers to 'articulation data' instead of 'rigid object data'
| """Test that the articulation data is settable.""" | |
| """Test that the rigid object data is settable.""" |
| ) | ||
| assert torch.all(wp.to_torch(rigid_object_data.default_root_vel) == torch.ones(num_instances, 6, device=device)) | ||
| # Prime the articulation data |
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.
syntax: Comment incorrectly refers to 'articulation data' instead of 'rigid object data'
| # Prime the articulation data | |
| # Prime the rigid object data |
fdf4241 to
8afadee
Compare
Description
Adds back support for Rigid bodies.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there