Ark
Loading...
Searching...
No Matches
pybullet_backend.PyBulletBackend Class Reference
Inheritance diagram for pybullet_backend.PyBulletBackend:
ark.system.simulation.simulator_backend.SimulatorBackend

Public Member Functions

None initialize (self)
 Initialize the PyBullet world.
bool is_ready (self)
 Check whether the backend has finished initialization.
None set_gravity (self, tuple[float] gravity)
 Set the world gravity.
None set_time_step (self, float time_step)
 Set the simulation timestep.
 add_robot (self, str name, Dict[str, Any] robot_config)
 ROBOTS, SENSORS AND OBJECTS ####.
None add_sim_component (self, str name, Dict[str, Any] obj_config)
 Add a generic simulated object.
None add_sensor (self, str name, Dict[str, Any] sensor_config)
 Instantiate and register a sensor.
None remove (self, str name)
 Remove a component from the simulator.
None step (self)
 Advance the simulation by one timestep.
 save_render (self)
 Render the scene and write the image to disk.
None reset_simulator (self)
 Reset the entire simulator state.
float get_current_time (self)
 Return the current simulation time.
 shutdown_backend (self)
 Disconnect all components and shut down the backend.
Public Member Functions inherited from ark.system.simulation.simulator_backend.SimulatorBackend
None __init__ (self, Dict[str, Any] global_config)
 Create and initialize the backend.

Public Attributes

 client = self._connect_pybullet(self.global_config)
 save_render_config = self.global_config["simulator"].get("save_render", None)
 save_path = Path(self.save_render_config.get("save_path", "output/save_render"))
 save_interval = self.save_render_config.get("save_interval", 1 / 30)
 overwrite_file = self.save_render_config.get("overwrite_file", False)
 extrinsics = self.save_render_config.get("extrinsics", default_extrinsics)
 intrinsics = self.save_render_config.get("intrinsics", default_intrinsics)
Public Attributes inherited from ark.system.simulation.simulator_backend.SimulatorBackend
dict robot_ref = {}
dict object_ref = {}
dict sensor_ref = {}
bool ready = False
 global_config = global_config

Protected Member Functions

 _connect_pybullet (self, dict[str, Any] config)
 Create and return the Bullet client.
 _all_available (self)
 SIMULATION ####.
Protected Member Functions inherited from ark.system.simulation.simulator_backend.SimulatorBackend
None _step_sim_components (self)
 Step all registered components.
None _spin_sim_components (self)
 Spin components in manual mode.

Protected Attributes

float _rendered_time = -1.0
 _time_step = time_step
Protected Attributes inherited from ark.system.simulation.simulator_backend.SimulatorBackend
float _simulation_time = 0.0

Detailed Description

Backend wrapper around the PyBullet client.

This class handles scene creation, stepping the simulation and managing
simulated components such as robots, objects and sensors.

Member Function Documentation

◆ _all_available()

pybullet_backend.PyBulletBackend._all_available ( self)
protected

SIMULATION ####.

Check whether all registered components are active.

Returns
True if no component is suspended. @rtype bool

◆ _connect_pybullet()

pybullet_backend.PyBulletBackend._connect_pybullet ( self,
dict[str, Any] config )
protected

Create and return the Bullet client.

config must contain the connection_mode under the simulator section. Optionally mp4 can be provided to enable video recording.

Parameters
configGlobal configuration dictionary.
Returns
Initialized :class:BulletClient instance. @rtype BulletClient

◆ add_robot()

pybullet_backend.PyBulletBackend.add_robot ( self,
str name,
Dict[str, Any] robot_config )

ROBOTS, SENSORS AND OBJECTS ####.

Instantiate and register a robot in the simulation.

Parameters
nameIdentifier for the robot.
robot_configRobot specific configuration dictionary.

Reimplemented from ark.system.simulation.simulator_backend.SimulatorBackend.

◆ add_sensor()

None pybullet_backend.PyBulletBackend.add_sensor ( self,
str name,
Dict[str, Any] sensor_config )

Instantiate and register a sensor.

Parameters
nameName of the sensor component.
sensor_configSensor configuration dictionary.

Reimplemented from ark.system.simulation.simulator_backend.SimulatorBackend.

◆ add_sim_component()

None pybullet_backend.PyBulletBackend.add_sim_component ( self,
str name,
Dict[str, Any] obj_config )

Add a generic simulated object.

Parameters
nameName of the object.
obj_configObject specific configuration dictionary.

Reimplemented from ark.system.simulation.simulator_backend.SimulatorBackend.

◆ get_current_time()

float pybullet_backend.PyBulletBackend.get_current_time ( self)

Return the current simulation time.

Returns
Elapsed simulation time in seconds. @rtype float

◆ initialize()

None pybullet_backend.PyBulletBackend.initialize ( self)

Initialize the PyBullet world.

The method creates the Bullet client, configures gravity and time step and loads all robots, objects and sensors defined in self.global_config. Optional frame capture settings are applied as well.

Reimplemented from ark.system.simulation.simulator_backend.SimulatorBackend.

◆ is_ready()

bool pybullet_backend.PyBulletBackend.is_ready ( self)

Check whether the backend has finished initialization.

Returns
True once all components were created and the simulator is ready for stepping. @rtype bool

Reimplemented from ark.system.simulation.simulator_backend.SimulatorBackend.

◆ remove()

None pybullet_backend.PyBulletBackend.remove ( self,
str name )

Remove a component from the simulator.

Parameters
nameName of the robot, object or sensor to remove.

Reimplemented from ark.system.simulation.simulator_backend.SimulatorBackend.

◆ reset_simulator()

None pybullet_backend.PyBulletBackend.reset_simulator ( self)

Reset the entire simulator state.

All robots, objects and sensors are destroyed and the backend is re-initialized using self.global_config.

Reimplemented from ark.system.simulation.simulator_backend.SimulatorBackend.

◆ save_render()

pybullet_backend.PyBulletBackend.save_render ( self)

Render the scene and write the image to disk.

The image is saved either as render.png when overwriting or with the current simulation time as filename when not.

◆ set_gravity()

None pybullet_backend.PyBulletBackend.set_gravity ( self,
tuple[float] gravity )

Set the world gravity.

Parameters
gravityTuple (gx, gy, gz) specifying gravity in m/s^2.

Reimplemented from ark.system.simulation.simulator_backend.SimulatorBackend.

◆ set_time_step()

None pybullet_backend.PyBulletBackend.set_time_step ( self,
float time_step )

Set the simulation timestep.

Parameters
time_stepLength of a single simulation step in seconds.

◆ shutdown_backend()

pybullet_backend.PyBulletBackend.shutdown_backend ( self)

Disconnect all components and shut down the backend.

This should be called at program termination to cleanly close the simulator and free all resources.

Reimplemented from ark.system.simulation.simulator_backend.SimulatorBackend.

◆ step()

None pybullet_backend.PyBulletBackend.step ( self)

Advance the simulation by one timestep.

The method updates all registered components, advances the physics engine and optionally saves renders when enabled.

Reimplemented from ark.system.simulation.simulator_backend.SimulatorBackend.

Member Data Documentation

◆ _rendered_time

pybullet_backend.PyBulletBackend._rendered_time = -1.0
protected

◆ _time_step

pybullet_backend.PyBulletBackend._time_step = time_step
protected

◆ client

pybullet_backend.PyBulletBackend.client = self._connect_pybullet(self.global_config)

◆ extrinsics

pybullet_backend.PyBulletBackend.extrinsics = self.save_render_config.get("extrinsics", default_extrinsics)

◆ intrinsics

pybullet_backend.PyBulletBackend.intrinsics = self.save_render_config.get("intrinsics", default_intrinsics)

◆ overwrite_file

pybullet_backend.PyBulletBackend.overwrite_file = self.save_render_config.get("overwrite_file", False)

◆ save_interval

pybullet_backend.PyBulletBackend.save_interval = self.save_render_config.get("save_interval", 1 / 30)

◆ save_path

pybullet_backend.PyBulletBackend.save_path = Path(self.save_render_config.get("save_path", "output/save_render"))

◆ save_render_config

pybullet_backend.PyBulletBackend.save_render_config = self.global_config["simulator"].get("save_render", None)

The documentation for this class was generated from the following file: