Repository navigation
Adds support for varying resolution to shadow hand vision task - #4866
Conversation
Greptile SummaryThis PR makes the Shadow Hand vision task's Key changes:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[ShadowHandVisionEnv.__init__] --> B["Read cfg.tiled_camera.height / width"]
B --> C["FeatureExtractor.__init__(height, width)"]
C --> D["FeatureExtractorNetwork.__init__(height, width)"]
D --> E["_conv_out × 4 layers\n(h1,w1) → (h2,w2) → (h3,w3) → (h4,w4)"]
E --> F["LayerNorm([16, h1, w1])\nLayerNorm([32, h2, w2])\nLayerNorm([64, h3, w3])\nLayerNorm([128, h4, w4])"]
F --> G["AdaptiveAvgPool2d(1)\n→ always (N,128,1,1)"]
G --> H["Linear(128, 27)\n→ keypoint embedding"]
I[ArticulationData._initialize_sim_data] --> J["get_attribute body_inertia\n→ raw (N, B, 3, 3) warp array"]
J --> K{"ndim == 4?"}
K -- yes --> L["wp.array(ptr, shape=(N,B,9),\nstrides=(s0,s1,s3), copy=False)"]
K -- no --> M["use array as-is"]
N[NewtonManager.step] --> O{"cls._graph is not None?"}
O -- yes --> P["wp.capture_launch(cls._graph)"]
O -- no --> Q["wp.ScopedDevice → cls._simulate()"]
Last reviewed commit: 46d2c35 |
| def _conv_out(size: int, kernel: int, stride: int, padding: int = 0) -> int: | ||
| """Compute the spatial output size of a single convolutional layer.""" | ||
| return (size + 2 * padding - kernel) // stride + 1 |
There was a problem hiding this comment.
No minimum resolution validation
_conv_out uses floor division and can return 0 or negative values for very small inputs (e.g., _conv_out(5, 6, 2) → (5 - 6) // 2 + 1 = 0). With four stacked convolutions (kernels 6, 4, 4, 3), the minimum valid side is ~40 px. If a user passes a smaller resolution the error surfaces inside nn.LayerNorm construction with an opaque PyTorch message rather than a clear user-facing one.
Consider adding an early check in FeatureExtractorNetwork.__init__:
if h4 <= 0 or w4 <= 0:
raise ValueError(
f"Image resolution {height}x{width} is too small for the CNN architecture "
f"(requires at least ~40x40). Got spatial sizes after all conv layers: "
f"h4={h4}, w4={w4}."
)
Description
The shadow hand vision task had been using a fixed camera resolution.
For benchmarking purposes, we want to run the environment at different resolutions. Adding support to the Feature Extractor to allow for arbitrary input resolution.
Also fixes an issue with Newton inertia shape.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there