Adapt DexSim v0.4.2 for EmbodiChain #301
Merged
Merged
Conversation
Bump dexsim_engine to 0.4.2 and align articulation target/current qpos/qvel getters and setters with the renamed DexSim entity API. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates EmbodiChain’s simulation wrappers to match DexSim v0.4.2’s split “current vs target” joint-state API, and bumps the dexsim_engine dependency accordingly.
Changes:
- Bump
dexsim_enginedependency from0.4.1to0.4.2. - Update
ArticulationCPU joint-state target accessors (target_qpos,target_qvel) to use DexSim’s new explicit getters. - Update joint velocity setting paths to use DexSim’s explicit “current/target” setters.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pyproject.toml | Bumps dexsim_engine to 0.4.2. |
| embodichain/lab/sim/objects/robot.py | Routes Robot.set_qvel through the updated articulation velocity setter. |
| embodichain/lab/sim/objects/articulation.py | Aligns CPU getters/setters with DexSim v0.4.2 explicit current/target joint APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1147
to
+1148
|
|
||
| def set_qvel( | ||
| def set_current_qvel( |
Comment on lines
+1187
to
1191
| self._entities[env_idx].set_target_qvel | ||
| if target | ||
| else self._entities[env_idx].set_qvel | ||
| else self._entities[env_idx].set_current_qvel | ||
| ) | ||
| setter(qvel[i].numpy(), local_joint_ids) |
Comment on lines
1148
to
1151
| def set_current_qvel( | ||
| self, | ||
| qvel: torch.Tensor, | ||
| joint_ids: Sequence[int] | None = None, |
Comment on lines
271
to
277
| # Fetch target_qpos from CPU entities | ||
| return torch.as_tensor( | ||
| np.array( | ||
| [ | ||
| entity.get_current_qpos(is_target=True) | ||
| for entity in self.entities | ||
| ], | ||
| [entity.get_target_qpos() for entity in self.entities], | ||
| ), | ||
| dtype=torch.float32, | ||
| device=self.device, |
Comment on lines
+1580
to
+1587
| local_env_ids = self._all_indices if env_ids is None else env_ids | ||
| if self.device.type == "cpu": | ||
| zero_joint_data = np.zeros((len(local_env_ids), self.dof), dtype=np.float32) | ||
| for i, env_idx in enumerate(local_env_ids): | ||
| self._entities[env_idx].set_qvel(zero_joint_data[i]) | ||
| self._entities[env_idx].set_current_qvel(zero_joint_data[i]) | ||
| self._entities[env_idx].set_current_qf(zero_joint_data[i]) | ||
| else: | ||
| zeros = torch.zeros( | ||
| (len(local_env_ids), self.dof), dtype=torch.float32, device=self.device | ||
| ) | ||
| indices = self.body_data.gpu_indices[local_env_ids] | ||
| self._ps.gpu_apply_joint_data( | ||
| data=zeros, | ||
| gpu_indices=indices, | ||
| data_type=ArticulationGPUAPIWriteType.JOINT_VELOCITY, | ||
| ) | ||
| self._ps.gpu_apply_joint_data( | ||
| data=zeros, | ||
| gpu_indices=indices, | ||
| data_type=ArticulationGPUAPIWriteType.JOINT_TARGET_VELOCITY, | ||
| ) | ||
| self._ps.gpu_apply_joint_data( | ||
| data=zeros, | ||
| gpu_indices=indices, | ||
| data_type=ArticulationGPUAPIWriteType.JOINT_FORCE, | ||
| ) | ||
| self.set_qvel(torch.zeros(self.dof, device=self.device), env_ids=local_env_ids) | ||
| self.set_qvel( | ||
| torch.zeros(self.dof, device=self.device), | ||
| env_ids=local_env_ids, | ||
| target=True, | ||
| ) | ||
| self.set_qf(torch.zeros(self.dof, device=self.device), env_ids=local_env_ids) |
Comment on lines
+1187
to
1191
| self._entities[env_idx].set_target_qvel | ||
| if target | ||
| else self._entities[env_idx].set_qvel | ||
| else self._entities[env_idx].set_current_qvel | ||
| ) | ||
| setter(qvel[i].numpy(), local_joint_ids) |
Comment on lines
+12
to
+18
| name: Activate conda py311 environment | ||
| shell: bash -l {0} | ||
| run: | | ||
| source activate py311 | ||
| echo "$CONDA_PREFIX/bin" >> "$GITHUB_PATH" | ||
| python --version | ||
| which python pip |
Comment on lines
1580
to
+1584
| local_env_ids = self._all_indices if env_ids is None else env_ids | ||
| if self.device.type == "cpu": | ||
| zero_joint_data = np.zeros((len(local_env_ids), self.dof), dtype=np.float32) | ||
| for i, env_idx in enumerate(local_env_ids): | ||
| self._entities[env_idx].set_qvel(zero_joint_data[i]) | ||
| self._entities[env_idx].set_current_qvel(zero_joint_data[i]) | ||
| self._entities[env_idx].set_current_qf(zero_joint_data[i]) | ||
| else: | ||
| zeros = torch.zeros( | ||
| (len(local_env_ids), self.dof), dtype=torch.float32, device=self.device | ||
| ) | ||
| indices = self.body_data.gpu_indices[local_env_ids] | ||
| self._ps.gpu_apply_joint_data( | ||
| data=zeros, | ||
| gpu_indices=indices, | ||
| data_type=ArticulationGPUAPIWriteType.JOINT_VELOCITY, | ||
| ) | ||
| self._ps.gpu_apply_joint_data( | ||
| data=zeros, | ||
| gpu_indices=indices, | ||
| data_type=ArticulationGPUAPIWriteType.JOINT_TARGET_VELOCITY, | ||
| ) | ||
| self._ps.gpu_apply_joint_data( | ||
| data=zeros, | ||
| gpu_indices=indices, | ||
| data_type=ArticulationGPUAPIWriteType.JOINT_FORCE, | ||
| ) | ||
| zeros = torch.zeros((len(local_env_ids), self.dof), device=self.device) | ||
| self.set_qvel(zeros, env_ids=local_env_ids) | ||
| self.set_qvel(zeros, env_ids=local_env_ids, target=True) | ||
| self.set_qf(zeros, env_ids=local_env_ids) |
Comment on lines
1098
to
1105
| if self.device.type == "cpu": | ||
| for i, env_idx in enumerate(local_env_ids): | ||
| setter = ( | ||
| self._entities[env_idx].set_current_qpos | ||
| self._entities[env_idx].set_target_qpos | ||
| if target | ||
| else self._entities[env_idx].set_qpos | ||
| else self._entities[env_idx].set_current_qpos | ||
| ) | ||
| setter(qpos[i].numpy(), local_joint_ids.numpy()) |
Comment on lines
1184
to
1191
| if self.device.type == "cpu": | ||
| for i, env_idx in enumerate(local_env_ids): | ||
| setter = ( | ||
| self._entities[env_idx].set_current_qvel | ||
| self._entities[env_idx].set_target_qvel | ||
| if target | ||
| else self._entities[env_idx].set_qvel | ||
| else self._entities[env_idx].set_current_qvel | ||
| ) | ||
| setter(qvel[i].numpy(), local_joint_ids) |
Comment on lines
+6
to
+12
| - name: Activate conda py311 environment | ||
| shell: bash -l {0} | ||
| run: | | ||
| source activate py311 | ||
| echo "$CONDA_PREFIX/bin" >> "$GITHUB_PATH" | ||
| python --version | ||
| which python pip |
yuecideng
added a commit
that referenced
this pull request
Jun 15, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR adapts EmbodiChain to DexSim v0.4.2 by bumping the
dexsim_enginedependency and aligning articulation joint state accessors with the renamed DexSim entity API.DexSim v0.4.2 separates current vs. target joint state into explicit methods (
get_target_qpos,get_target_qvel,set_current_qpos,set_target_qpos,set_current_qvel,set_target_qvel) instead of the previousget_current_qpos(is_target=True)/set_qpos/set_qvelpattern. EmbodiChain'sArticulationandRobotwrappers are updated accordingly.Dependencies:
dexsim_engine==0.4.2Type of change
Screenshots
N/A — backend API alignment only.
Checklist
black .command to format the code base.🤖 Generated with Claude Code
Made with Cursor