MCPcopy Create free account
hub / github.com/TeleHuman/PBHC / BaseSimulator

Class BaseSimulator

humanoidverse/simulator/base_simulator/base_simulator.py:6–171  ·  view source on GitHub ↗

Base class for robotic simulation environments, providing a framework for simulation setup, environment creation, and control over robotic assets and simulation properties.

Source from the content-addressed store, hash-verified

4import torch
5
6class BaseSimulator:
7 """
8 Base class for robotic simulation environments, providing a framework for simulation setup,
9 environment creation, and control over robotic assets and simulation properties.
10 """
11 def __init__(self, config, device):
12 """
13 Initializes the base simulator with configuration settings and simulation device.
14
15 Args:
16 config (dict): Configuration dictionary for the simulation.
17 device (str): Device type for simulation ('cpu' or 'cuda').
18 """
19 self.config = config
20 self.sim_device = device
21 self.headless = False
22
23 self._rigid_body_pos: torch.Tensor
24 self._rigid_body_rot: torch.Tensor
25 self._rigid_body_vel: torch.Tensor
26 self._rigid_body_ang_vel: torch.Tensor
27
28 # ----- Configuration Setup Methods -----
29
30 def set_headless(self, headless):
31 """
32 Sets the headless mode for the simulator.
33
34 Args:
35 headless (bool): If True, runs the simulation without graphical display.
36 """
37 self.headless = headless
38
39 def setup(self):
40 """
41 Initializes the simulator parameters and environment. This method should be implemented
42 by subclasses to set specific simulator configurations.
43 """
44 raise NotImplementedError("The 'setup' method must be implemented in subclasses.")
45
46 # ----- Terrain Setup Methods -----
47
48 def setup_terrain(self, mesh_type):
49 """
50 Configures the terrain based on specified mesh type.
51
52 Args:
53 mesh_type (str): Type of terrain mesh ('plane', 'heightfield', 'trimesh').
54 """
55 raise NotImplementedError("The 'setup_terrain' method must be implemented in subclasses.")
56
57 # ----- Robot Asset Setup Methods -----
58
59 def load_assets(self, robot_config):
60 """
61 Loads the robot assets into the simulation environment.
62 save self.num_dofs, self.num_bodies, self.dof_names, self.body_names
63 Args:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected