only one environment spawns in the simulation, even though --num_envs 10 #4270
Replies: 1 comment
-
|
With How cloning is supposed to workWhen For a direct RL env, the recommended pattern is exactly what Cartpole uses: @configclass
class MyQuadrupedEnvCfg(DirectRLEnvCfg):
# robot(s)
robot_cfg: ArticulationCfg = MY_QUAD_CFG.replace(
prim_path="/World/envs/env_.*/Robot" # note regex
)
# scene
scene: InteractiveSceneCfg = InteractiveSceneCfg(
num_envs=10,
env_spacing=4.0,
replicate_physics=True,
clone_in_fabric=True,
)And in the env: class MyQuadrupedEnv(DirectRLEnv):
cfg: MyQuadrupedEnvCfg
def _setup_scene(self):
# spawn robot ONCE in env_0 via Articulation, then let scene clone
self.robot = Articulation(self.cfg.robot_cfg)
# ground plane only once at /World/ground
spawn_ground_plane(prim_path="/World/ground", cfg=GroundPlaneCfg())
# let InteractiveScene perform the cloning; do NOT do your own per-env cloning
self.scene.clone_environments(copy_from_source=False)
# no manual env-spacing here; env origins come from scene.env_originsThis is exactly the structure in the official Cartpole direct tutorial, where they use Why your workaround “fixes” it
So the behavior you see (one “good” env plus one buried robot) usually indicates:
What to change in your quadruped envTo keep
Ensure your robot_cfg: ArticulationCfg = MY_QUAD_CFG.replace(
prim_path="/World/envs/env_0/Robot" # WRONG: only env_0
)
# instead:
robot_cfg: ArticulationCfg = MY_QUAD_CFG.replace(
prim_path="/World/envs/env_.*/Robot" # CORRECT
)This tells the cloner that the robot lives under an env root, and it will generate In def _setup_scene(self):
self.robot = Articulation(self.cfg.robot_cfg)
spawn_ground_plane(prim_path="/World/ground", cfg=GroundPlaneCfg())
self.scene.clone_environments(copy_from_source=False)Do not manually spawn or clone robots per env when Follow the Cartpole pattern for initial pose: def _reset_idx(self, env_ids: Sequence[int] | None):
if env_ids is None:
env_ids = self.robot._ALL_INDICES
super()._reset_idx(env_ids)
default_root_state = self.robot.data.default_root_state[env_ids]
# IMPORTANT: shift by env origins; do NOT hard-code spacings
default_root_state[:, :3] += self.scene.env_origins[env_ids]
self.robot.write_root_pose_to_sim(default_root_state[:, :7], env_ids)
self.robot.write_root_velocity_to_sim(default_root_state[:, 7:], env_ids)This ensures each clone gets the proper per-env offset and avoids all robots collapsing at (0,0,0).2 Footnotes
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
A little bit of context: i am trying to set up RL for a quadruped robot. My direct environments consist of a ground plane, the robot, and light.
Problem: I set --num_envs 10, and when using print(env_ids), as well as printing xyz position, i get a reading on all 10 environments. However, in the 3D simulation, only one environment is loaded in, and one robot is for some reason "half-buried" in the ground plane at 0,0,0. Currently, env_spacing = 1.0, and changing it makes no difference.
Here is the image of that single robot and the "half-buried" robot, which is also missing its legs, for some reason. It is visible from the right of the image that there is only one environment running in the simulation, meaning that isaaclab creates the other environments and somehow does not load them into the simulation (i don't know how this works, so i am hypothesizing).

I noticed that when setting clone_in_fabric = False and (optionally) replicate_physics = False, this issue seems to go away. For my purposes, however, I want to have clone_in_fabric = True and replicate_physics = True as well, besides the cartpole tutorial has them set as such and does not have problems with cloning environments.
any help would be appreciated
Beta Was this translation helpful? Give feedback.
All reactions