Skip to content

Conversation

@yuecideng
Copy link
Contributor

@yuecideng yuecideng commented Dec 24, 2025

Description

  • Add cpu_num to SimulationCfg and set default value to 1. This change will reduce the current cpu workload while maintains the similar performance.
  • Add some overwrite interfaces for Robot with control part name supported. This improve user friendly experience.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)

Screenshots

Please attach before and after screenshots of the change if applicable.

Checklist

  • I have run the black . command to format the code base.
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Dependencies have been updated, if applicable.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances simulation configuration and robot control interfaces by adding CPU thread control and improving user-friendliness for controlling specific robot parts.

  • Added cpu_num parameter to SimulationManagerCfg with default value of 1 to control CPU thread usage
  • Added control part name interfaces to Robot class for getter/setter methods (qpos, qvel, qf) and limit getters
  • Updated import path for SimResources from embodichain.data.assets to embodichain.data.dataset

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 15 comments.

File Description
embodichain/lab/sim/sim_manager.py Adds cpu_num configuration field and applies it to world config; updates import path for SimResources
embodichain/lab/sim/objects/robot.py Adds new methods to get/set joint states and limits for specific control parts by name
embodichain/lab/sim/objects/articulation.py Improves documentation for the get_qpos method with return type details
tests/sim/objects/test_robot.py Adds test case for new control part getter/setter functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +140 to +144
if name not in self.control_parts:
logger.log_error(
f"The control part '{name}' does not exist in the robot's control parts {self.control_parts}."
)
return self._control_groups[name].link_names
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The error handling pattern using logger.log_error() doesn't prevent execution from continuing. After logging the error, the code will attempt to access self._control_groups[name] which will raise a KeyError if the name doesn't exist. Consider either raising an exception or returning early after logging the error.

Copilot uses AI. Check for mistakes.
Comment on lines +220 to +225
if not self.control_parts or name not in self.control_parts:
logger.log_error(
f"The control part '{name}' does not exist in the robot's control parts."
)
part_joint_ids = self.get_joint_ids(name=name)
return qf_limits[local_env_ids][:, part_joint_ids, :]
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The error handling pattern using logger.log_error() doesn't prevent execution from continuing. After logging the error, the code will proceed to call get_joint_ids() which may fail or return incorrect results. Consider either raising an exception or returning early after logging the error.

Copilot uses AI. Check for mistakes.
Comment on lines 184 to 185
Returns:
torch.Tensor: Joint velocity limits with shape (N, dof, 2), where N is the number of environments.
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The indentation for the Returns section is inconsistent. It should have one space after the asterisk, matching the Args section format above.

Copilot uses AI. Check for mistakes.
Comment on lines +166 to +171
if not self.control_parts or name not in self.control_parts:
logger.log_error(
f"The control part '{name}' does not exist in the robot's control parts."
)
part_joint_ids = self.get_joint_ids(name=name)
return qpos_limits[local_env_ids][:, part_joint_ids, :]
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The error handling pattern using logger.log_error() doesn't prevent execution from continuing. After logging the error, the code will proceed to call get_joint_ids() which may fail or return incorrect results. Consider either raising an exception or returning early after logging the error.

Copilot uses AI. Check for mistakes.
Comment on lines +299 to +304
if not self.control_parts or name not in self.control_parts:
logger.log_error(
f"The control part '{name}' does not exist in the robot's control parts."
)
part_joint_ids = self.get_joint_ids(name=name)
return qpos[:, part_joint_ids]
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The error handling pattern using logger.log_error() doesn't prevent execution from continuing. After logging the error, the code will proceed to call get_joint_ids() which may fail or return incorrect results. Consider either raising an exception or returning early after logging the error.

Copilot uses AI. Check for mistakes.
"""Get the current positions (qpos) of the articulation.
Returns:
torch.Tensor: torch.Tensor: Joint positions with shape (N, dof), where N is the number of environments.
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The docstring has a duplicate "torch.Tensor:" in the Returns section. The return type should only be stated once.

Suggested change
torch.Tensor: torch.Tensor: Joint positions with shape (N, dof), where N is the number of environments.
torch.Tensor: Joint positions with shape (N, dof), where N is the number of environments.

Copilot uses AI. Check for mistakes.
Comment on lines 211 to 212
Returns:
torch.Tensor: Joint effort limits with shape (N, dof, 2), where N is the number of environments.
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The indentation for the Returns section is inconsistent. It should have one space after the asterisk, matching the Args section format above.

Copilot uses AI. Check for mistakes.
Comment on lines +362 to +367
if not self.control_parts or name not in self.control_parts:
logger.log_error(
f"The control part '{name}' does not exist in the robot's control parts."
)
part_joint_ids = self.get_joint_ids(name=name)
return qvel[:, part_joint_ids]
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The error handling pattern using logger.log_error() doesn't prevent execution from continuing. After logging the error, the code will proceed to call get_joint_ids() which may fail or return incorrect results. Consider either raising an exception or returning early after logging the error.

Copilot uses AI. Check for mistakes.
dummy_qpos = torch.max(
torch.min(dummy_qpos, left_qpos_limits[:, :, 1]), left_qpos_limits[:, :, 0]
)
self.robot.set_qpos(qpos=dummy_qpos, name="left_arm")
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The test doesn't verify that the qpos values were actually set correctly. After calling set_qpos, the test should retrieve the qpos again and verify that it matches the values that were set.

Copilot uses AI. Check for mistakes.
Comment on lines 157 to 158
Returns:
torch.Tensor: Joint position limits with shape (N, dof, 2), where N is the number of environments.
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The indentation for the Returns section is inconsistent. It should have one space after the asterisk, matching the Args section format above.

Copilot uses AI. Check for mistakes.
@yuecideng yuecideng requested review from chase6305 and yhnsu December 25, 2025 03:25
@yuecideng yuecideng merged commit 49350a3 into main Dec 25, 2025
5 checks passed
@yuecideng yuecideng deleted the yueci/add-interface-robot branch December 25, 2025 07:00
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.

2 participants