Skip to content

Commit f21de35

Browse files
committed
wip
1 parent ff2cc1b commit f21de35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+43
-113
lines changed

docs/source/resources/robot/cobotmagic.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ CobotMagic is a versatile dual-arm collaborative robot developed by AgileX Robot
3939
from embodichain.lab.sim import SimulationManager, SimulationManagerCfg
4040
from embodichain.lab.sim.robots import CobotMagicCfg
4141

42-
config = SimulationManagerCfg(headless=False, sim_device="cpu")
42+
config = SimulationManagerCfg(headless=False, sim_device="cpu", num_envs=2)
4343
sim = SimulationManager(config)
44-
sim.build_multiple_arenas(2) # Supports parallel simulation in multiple arenas
4544
sim.set_manual_update(False)
4645

4746
robot = sim.add_robot(cfg=CobotMagicCfg().from_dict({}))

docs/source/tutorial/create_scene.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ Command-line arguments are parsed using ``argparse`` to allow for easy customiza
3131
.. literalinclude:: ../../../scripts/tutorials/sim/create_scene.py
3232
:language: python
3333
:start-at: # Parse command line arguments
34-
:end-at: sim.build_multiple_arenas(args.num_envs, space=3.0)
34+
:end-at: sim = SimulationManager(sim_cfg)
3535

3636
There are two kinds of physics mode in :class:`SimulationManager`:
3737

3838
- `manual`: The physics updates only when the user calls the :meth:`SimulationManager.update` function. This mode is used for robot learning tasks where precise control over simulation steps is required. Enabled by setting :meth:`SimulationManager.set_manual_update` to True.
3939
- `auto`: The physics updates in a standalone thread, which enable asynchronous rendering and physics stepping. This mode is suitable for visualizations and demos for digital twins applications. This is the default mode.
4040

41-
If `num_envs` is greater than 1, :meth:`SimulationManager.build_multiple_arenas` should be used to create multiple simulation arenas.
42-
4341
Adding objects to the scene
4442
---------------------------
4543

docs/source/tutorial/create_softbody.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ The first step is to configure the simulation environment. This is done using th
3232
:start-at: # Configure the simulation
3333
:end-at: print("[INFO]: Scene setup complete!")
3434

35-
If ``num_envs`` is greater than 1, :meth:`SimulationManager.build_multiple_arenas` should be used to create multiple simulation arenas.
36-
3735
Adding a soft body to the scene
3836
-------------------------------
3937

docs/source/tutorial/rl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ To start training, run:
182182

183183
.. code-block:: bash
184184
185-
python embodichain/agents/rl/train.py --config configs/agents/rl/push_cube/train_config.json
185+
python -m embodichain.agents.rl.train --config configs/agents/rl/push_cube/train_config.json
186186
187187
Outputs
188188
-------

embodichain/lab/gym/envs/base_env.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ def _setup_scene(self, **kwargs):
208208
logger.log_info(
209209
f"Initializing {self.num_envs} environments on {self.sim_cfg.sim_device}."
210210
)
211-
if self.num_envs > 1:
212-
self.sim.build_multiple_arenas(self.num_envs)
213211

214212
self.robot = self._setup_robot(**kwargs)
215213
if self.robot is None:

embodichain/lab/sim/robots/cobotmagic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,8 @@ def build_pk_serial_chain(
207207

208208
torch.set_printoptions(precision=5, sci_mode=False)
209209

210-
config = SimulationManagerCfg(headless=False, sim_device="cuda")
210+
config = SimulationManagerCfg(headless=False, sim_device="cuda", num_envs=2)
211211
sim = SimulationManager(config)
212-
sim.build_multiple_arenas(2)
213212

214213
config = {
215214
"init_pos": [0.0, 0.0, 1.0],

embodichain/lab/sim/robots/dexforce_w1/cfg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ def build_pk_serial_chain(
353353

354354
config = SimulationManagerCfg(headless=True, sim_device="cpu")
355355
sim = SimulationManager(config)
356-
sim.build_multiple_arenas(1)
357356

358357
cfg = DexforceW1Cfg.from_dict(
359358
{

embodichain/lab/sim/sim_manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ class SimulationManagerCfg:
125125
cpu_num: int = 1
126126
"""The number of CPU threads to use for the simulation engine."""
127127

128+
num_envs: int = 1
129+
"""The number of parallel environments (arenas) to simulate."""
130+
128131
arena_space: float = 5.0
129132
"""The distance between each arena when building multiple arenas."""
130133

@@ -243,6 +246,8 @@ def __init__(
243246
# Set physics to manual update mode by default.
244247
self.set_manual_update(True)
245248

249+
self._build_multiple_arenas(sim_config.num_envs)
250+
246251
@property
247252
def num_envs(self) -> int:
248253
"""Get the number of arenas in the simulation.
@@ -500,7 +505,7 @@ def close_window(self) -> None:
500505
self._world.close_window()
501506
self.is_window_opened = False
502507

503-
def build_multiple_arenas(self, num: int, space: float | None = None) -> None:
508+
def _build_multiple_arenas(self, num: int, space: float | None = None) -> None:
504509
"""Build multiple arenas in a grid pattern.
505510
506511
This interface is used for vectorized simulation.

examples/sim/demo/grasp_cup_to_caffe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def initialize_simulation(args) -> SimulationManager:
8383
sim_device=args.device,
8484
enable_rt=args.enable_rt,
8585
physics_dt=1.0 / 100.0,
86+
num_envs=args.num_envs,
87+
arena_space=2.5,
8688
)
8789
sim = SimulationManager(config)
8890

89-
sim.build_multiple_arenas(args.num_envs, space=2.5)
90-
9191
if args.enable_rt:
9292
light = sim.add_light(
9393
cfg=LightCfg(

examples/sim/gizmo/gizmo_camera.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ def main():
4040
parser = argparse.ArgumentParser(
4141
description="Create and simulate a camera with gizmo in SimulationManager"
4242
)
43-
parser.add_argument(
44-
"--num_envs", type=int, default=1, help="Number of environments to simulate"
45-
)
4643
parser.add_argument(
4744
"--device",
4845
type=str,
@@ -72,10 +69,6 @@ def main():
7269
sim = SimulationManager(sim_cfg)
7370
sim.set_manual_update(False)
7471

75-
# Build multiple arenas if requested
76-
if args.num_envs > 1:
77-
sim.build_multiple_arenas(args.num_envs, space=3.0)
78-
7972
# Add some objects to the scene for camera to observe
8073
for i in range(5):
8174
cube_cfg = RigidObjectCfg(

0 commit comments

Comments
 (0)