Download llm_panda/core/sim_engine.py from C2-151/Robot: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/C2-151/Robot/resolve/main/llm_panda/core/sim_engine.py
- Command line
-
hf download hf://spaces/C2-151/Robot/llm_panda/core/sim_engine.py
-
curl -L -o sim_engine.py https://huggingface.co/spaces/C2-151/Robot/resolve/main/llm_panda/core/sim_engine.py
1.1 kB
| import pybullet as pb | |
| import pybullet_data | |
| from llm_panda import config | |
| class SimEngine: | |
| """Manages the lifecycle of the PyBullet simulation.""" | |
| def __init__(self, gui=False, real_time=False): | |
| self.gui = gui | |
| self.real_time = real_time | |
| self.client = None | |
| def connect(self): | |
| self.client = pb.connect(pb.GUI if self.gui else pb.DIRECT) | |
| pb.setAdditionalSearchPath(pybullet_data.getDataPath()) | |
| pb.setGravity(0, 0, config.GRAVITY) | |
| pb.setTimeStep(config.SIM_TIMESTEP) | |
| if self.gui: | |
| pb.configureDebugVisualizer(pb.COV_ENABLE_GUI, 0) | |
| pb.resetDebugVisualizerCamera(1.2, 50, -35, [0.5, 0.0, 0.2]) | |
| if self.real_time: | |
| pb.setRealTimeSimulation(1) | |
| return self.client | |
| def disconnect(self): | |
| if self.client is not None: | |
| try: | |
| pb.disconnect(self.client) | |
| except Exception: | |
| pass | |
| self.client = None | |
| def step(self): | |
| if self.client is not None: | |
| pb.stepSimulation(self.client) | |