Envs API
Documentation for simulation environments and task definitions.
embodied_gen.envs.pick_embodiedgen
PickEmbodiedGen
PickEmbodiedGen(*args, robot_uids: str | list[str] = 'panda', robot_init_qpos_noise: float = 0.02, num_envs: int = 1, reconfiguration_freq: int = None, **kwargs)
Bases: BaseEnv
PickEmbodiedGen as gym env example for object pick-and-place tasks.
This environment simulates a robot interacting with 3D assets in the embodiedgen generated scene in SAPIEN. It supports multi-environment setups, dynamic reconfiguration, and hybrid rendering with 3D Gaussian Splatting.
Example
Use gym.make to create the PickEmbodiedGen-v1 parallel environment.
import gymnasium as gym
env = gym.make(
"PickEmbodiedGen-v1",
num_envs=cfg.num_envs,
render_mode=cfg.render_mode,
enable_shadow=cfg.enable_shadow,
layout_file=cfg.layout_file,
control_mode=cfg.control_mode,
camera_cfg=dict(
camera_eye=cfg.camera_eye,
camera_target_pt=cfg.camera_target_pt,
image_hw=cfg.image_hw,
fovy_deg=cfg.fovy_deg,
),
)
Initializes the PickEmbodiedGen environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Variable length argument list for the base class. |
()
|
|
robot_uids
|
str | list[str]
|
The robot(s) to use in the environment. |
'panda'
|
robot_init_qpos_noise
|
float
|
Noise added to the robot's initial joint positions. |
0.02
|
num_envs
|
int
|
The number of parallel environments to create. |
1
|
reconfiguration_freq
|
int
|
How often to reconfigure the scene. If None, it is set based on num_envs. |
None
|
**kwargs
|
Additional keyword arguments for environment setup, including layout_file, replace_objs, enable_grasp, etc. |
{}
|
Source code in embodied_gen/envs/pick_embodiedgen.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
compute_dense_reward
compute_dense_reward(obs: any, action: Tensor, info: dict)
Computes a dense reward for the current step.
The reward is a composite of reaching, grasping, placing, and maintaining a static final pose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
any
|
The current observation. |
required |
action
|
Tensor
|
The action taken in the current step. |
required |
info
|
dict
|
A dictionary containing evaluation information from |
required |
Returns:
| Type | Description |
|---|---|
|
A tensor containing the dense reward for each environment. |
Source code in embodied_gen/envs/pick_embodiedgen.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | |
compute_normalized_dense_reward
compute_normalized_dense_reward(obs: any, action: Tensor, info: dict)
Computes a dense reward normalized to be between 0 and 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs
|
any
|
The current observation. |
required |
action
|
Tensor
|
The action taken in the current step. |
required |
info
|
dict
|
A dictionary containing evaluation information from |
required |
Returns:
| Type | Description |
|---|---|
|
A tensor containing the normalized dense reward for each environment. |
Source code in embodied_gen/envs/pick_embodiedgen.py
602 603 604 605 606 607 608 609 610 611 612 613 614 615 | |
compute_robot_init_pose
staticmethod
compute_robot_init_pose(layouts: list[str], num_envs: int, z_offset: float = 0.0) -> list[list[float]]
Computes the initial pose for the robot in each environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layouts
|
list[str]
|
A list of file paths to the environment layouts. |
required |
num_envs
|
int
|
The number of environments. |
required |
z_offset
|
float
|
An optional vertical offset to apply to the robot's position to prevent collisions. |
0.0
|
Returns:
| Type | Description |
|---|---|
list[list[float]]
|
A list of initial poses ([x, y, z, qw, qx, qy, qz]) for the robot |
list[list[float]]
|
in each environment. |
Source code in embodied_gen/envs/pick_embodiedgen.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
evaluate
evaluate()
Evaluates the current state of the environment.
Checks for task success criteria such as whether the object is grasped, placed at the goal, and if the robot is static.
Returns:
| Type | Description |
|---|---|
|
A dictionary containing boolean tensors for various success |
|
|
metrics, including 'is_grasped', 'is_obj_placed', and overall |
|
|
'success'. |
Source code in embodied_gen/envs/pick_embodiedgen.py
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | |
hybrid_render
hybrid_render()
Renders a hybrid image by blending simulated foreground with a background.
The foreground is rendered with an alpha channel and then blended with the pre-rendered Gaussian Splatting background image.
Returns:
| Type | Description |
|---|---|
|
A torch tensor of the final blended RGB images. |
Source code in embodied_gen/envs/pick_embodiedgen.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | |
init_env_layouts
staticmethod
init_env_layouts(layout_file: str, num_envs: int, replace_objs: bool) -> list[LayoutInfo]
Initializes and saves layout files for each environment instance.
For each environment, this method creates a layout configuration. If
replace_objs is True, it generates new object placements for each
subsequent environment. The generated layouts are saved as new JSON
files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout_file
|
str
|
Path to the base layout JSON file. |
required |
num_envs
|
int
|
The number of environments to create layouts for. |
required |
replace_objs
|
bool
|
If True, generates new object placements for each environment after the first one using BFS placement. |
required |
Returns:
| Type | Description |
|---|---|
list[LayoutInfo]
|
A list of file paths to the generated layout for each environment. |
Source code in embodied_gen/envs/pick_embodiedgen.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
render
render()
Renders the environment based on the configured render_mode.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
NotImplementedError
|
If the |
Returns:
| Type | Description |
|---|---|
|
The rendered output, which varies depending on the render mode. |
Source code in embodied_gen/envs/pick_embodiedgen.py
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
render_gs3d_images
render_gs3d_images(layouts: list[str], num_envs: int, init_quat: list[float]) -> dict[str, np.ndarray]
Renders background images using a pre-trained Gaussian Splatting model.
This method pre-renders the static background for each environment from the perspective of all cameras to be used for hybrid rendering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layouts
|
list[str]
|
A list of file paths to the environment layouts. |
required |
num_envs
|
int
|
The number of environments. |
required |
init_quat
|
list[float]
|
An initial quaternion to orient the Gaussian Splatting model. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
A dictionary mapping a unique key (e.g., 'camera-env_idx') to the |
dict[str, ndarray]
|
rendered background image as a numpy array. |
Source code in embodied_gen/envs/pick_embodiedgen.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
render_rgb_array
render_rgb_array(camera_name: str = None, return_alpha: bool = False)
Renders an RGB image from the human-facing render camera.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_name
|
str
|
The name of the camera to render from. If None, uses all human render cameras. |
None
|
return_alpha
|
bool
|
Whether to include the alpha channel in the output. |
False
|
Returns:
| Type | Description |
|---|---|
|
A numpy array representing the rendered image(s). If multiple |
|
|
cameras are used, the images are tiled. |
Source code in embodied_gen/envs/pick_embodiedgen.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | |
render_sensors
render_sensors()
Renders images from all on-board sensor cameras.
Returns:
| Type | Description |
|---|---|
|
A tiled image of all sensor outputs as a numpy array. |
Source code in embodied_gen/envs/pick_embodiedgen.py
478 479 480 481 482 483 484 485 486 487 488 489 | |