-
Notifications
You must be signed in to change notification settings - Fork 9
Tyx/split robot left right #142
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -180,10 +180,11 @@ def compute_semantic_mask( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Compute the semantic mask for the specified scene entity. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Note: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The semantic mask is defined as (B, H, W, 3) where the three channels represents: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - robot channel: the instance id of the robot is set to 1 (0 if not robot) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The semantic mask is defined as (B, H, W, len(SemanticMask)) where these channels represents: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - background channel: the instance id of the background is set to 1 (0 if not background) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - foreground channel: the instance id of the foreground objects is set to 1 (0 if not foreground) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - robot left-side channel: the instance id of the robot left-side is set to 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - robot right-side channel: the instance id of the robot right-side is set to 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env: The environment instance. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -209,13 +210,30 @@ def compute_semantic_mask( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mask = obs["sensor"][entity_cfg.uid]["mask"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| robot_uids = env.robot.get_user_ids() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| left_robot_uids = torch.cat( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env.robot.get_user_ids(link_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for link_name in env.robot.link_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if link_name.startswith("left_") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| right_robot_uids = torch.cat( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env.robot.get_user_ids(link_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for link_name in env.robot.link_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if link_name.startswith("right_") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+213
to
229
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| left_robot_uids = torch.cat( | |
| [ | |
| env.robot.get_user_ids(link_name) | |
| for link_name in env.robot.link_names | |
| if link_name.startswith("left_") | |
| ], | |
| -1, | |
| ) | |
| right_robot_uids = torch.cat( | |
| [ | |
| env.robot.get_user_ids(link_name) | |
| for link_name in env.robot.link_names | |
| if link_name.startswith("right_") | |
| ], | |
| -1, | |
| ) | |
| # Get all robot user IDs once and slice by left/right link indices. | |
| all_robot_uids = env.robot.get_user_ids() | |
| left_link_indices = [ | |
| i | |
| for i, link_name in enumerate(env.robot.link_names) | |
| if link_name.startswith("left_") | |
| ] | |
| right_link_indices = [ | |
| i | |
| for i, link_name in enumerate(env.robot.link_names) | |
| if link_name.startswith("right_") | |
| ] | |
| if left_link_indices: | |
| left_robot_uids = all_robot_uids[left_link_indices] | |
| else: | |
| left_robot_uids = all_robot_uids.new_empty((0,)) | |
| if right_link_indices: | |
| right_robot_uids = all_robot_uids[right_link_indices] | |
| else: | |
| right_robot_uids = all_robot_uids.new_empty((0,)) |
Copilot
AI
Feb 18, 2026
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.
The semantic mask documentation and construction are now out of sync with the behavior: this code returns 4 channels (background/foreground/robot_left/robot_right), but the docstring above still describes 3 channels and the return shape as (num_envs, height, width). Also, hard-coding masks = [None, None, None, None] is brittle—prefer allocating based on len(SemanticMask) to avoid future enum changes silently breaking this function.
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.
Renaming/removing
SemanticMask.ROBOTis a breaking API change for any downstream code that imports that enum member or expects label value2to mean "robot" in general. If backward compatibility matters, consider keepingROBOT = ROBOT_LEFTas an alias (or deprecating it) while introducingROBOT_LEFT/ROBOT_RIGHT, and document how consumers should migrate.