concepts.simulator.pybullet.client.BulletClient#

class BulletClient[source]#

Bases: object

A wrapper for the pybullet client.

Methods

absolute_timeout(duration)

add_debug_coordinate_system(pos, principle_axes)

add_debug_cube(center, extent, color[, ...])

add_debug_line(start_pos, end_pos, color[, ...])

add_debug_ray(start_pos, delta, color[, ...])

add_debug_text(text, pos, color[, name, ...])

add_nonphysics_step_callback(cb)

connect([suppress_warnings])

disable_rendering([disable_rendering, ...])

disable_stdout([activate])

disable_world_update()

Temporarily disable the world update.

disconnect()

get_mouse_events()

has_gui()

is_connected()

is_stable([velocity_threshold, ...])

load_mjcf(xml_path[, pos, quat, body_name, ...])

load_sdf(xml_path[, scale, notify_world_update])

load_urdf(xml_path[, pos, quat, body_name, ...])

load_urdf_template(xml_path, replaces[, ...])

loads_mjcf(xml_content[, pos, quat, save_to])

perform_collision_detection()

register_debug_item(name, item_id)

remove_body(body_id)

remove_debug_item(item_id)

remove_nonphysics_step_callback(cb)

reset_world()

set_enable_realtime_rendering([...])

set_rendering(enable)

set_rendering_fps([render_fps])

step([steps, realtime_rendering])

step_until_stable([max_steps, ...])

timeout(duration)

update_viewer()

update_viewer_twice()

wait_for_duration(duration)

wait_for_user([message])

wait_forever()

with_fps([fps, render_fps, realtime_rendering])

Attributes

DEFAULT_ASSETS_ROOT

DEFAULT_ENGINE_PARAMETERS

DEFAULT_FPS

DEFAULT_GRAVITY

world

Alias for self.w.

debug_items

The debug items that are added to the world.

__init__(assets_root=None, is_gui=False, *, fps=None, render_fps=None, gravity=None, connect=True, client_id=-1, width=960, height=960, additional_title=None, save_video=None, enable_realtime_rendering=None, enable_debug_gui=False, engine_parameters=None)[source]#

Initialize the BulletClient.

Parameters:
  • assets_root (str | None) – the root directory of the assets (by default it is the assets directory in the concepts package).

  • is_gui (bool) – whether to enable the GUI.

  • fps (int | None) – the physics simulation FPS (default: 120).

  • render_fps (int | None) – the rendering FPS (default: 120).

  • gravity (Tuple[float] | float | None) – the gravity vector (default: (0, 0, -9.8)).

  • connect (bool) – whether to connect to the server immediately.

  • client_id (int) – the client id to connect to. If this is set to -1, a new client id will be created.

  • save_video (str | None) – the path to save the video.

  • width (int | None) – the width of the window.

  • height (int | None) – the height of the window.

  • additional_title (str | None) – the additional title of the window.

  • enable_debug_gui (bool) – whether to enable the debug GUI.

  • enable_realtime_rendering (bool | None) – whether to enable realtime rendering (default: True if render_fps is set, otherwise False).

  • engine_parameters (Dict[str, Any] | None) – additional engine parameters.

__new__(**kwargs)#
absolute_timeout(duration)[source]#
Parameters:

duration (float)

add_debug_coordinate_system(pos, principle_axes, size=0.1, name=None, life_time=0)[source]#
Parameters:

size (float)

Return type:

Tuple[int, …]

add_debug_cube(center, extent, color, name=None, life_time=0)[source]#
Return type:

Tuple[int, …]

add_debug_line(start_pos, end_pos, color, name=None, life_time=0)[source]#
Return type:

int

add_debug_ray(start_pos, delta, color, length=1.0, name=None, life_time=0)[source]#
Parameters:

length (float)

Return type:

int

add_debug_text(text, pos, color, name=None, life_time=0)[source]#
Return type:

int

add_nonphysics_step_callback(cb)[source]#
connect(suppress_warnings=True)[source]#
Parameters:

suppress_warnings (bool)

disable_rendering(disable_rendering=True, reset=False, suppress_stdout=False)[source]#
Parameters:
  • disable_rendering (bool)

  • reset (bool)

  • suppress_stdout (bool)

disable_stdout(activate=True)[source]#
Parameters:

activate (bool)

disable_world_update()[source]#

Temporarily disable the world update. Specifically, when loading a new model, the world object self.w will not be updated. This function also disables rendering of the pybullet debug renderer. Thus, this functionality is useful when loading a large number of models.

disconnect()[source]#
get_mouse_events()[source]#
Return type:

List[MouseEvent]

has_gui()[source]#
is_connected()[source]#
is_stable(velocity_threshold=1e-3, angular_velocity_threshold=1e-3, joint_velocity_threshold=1e-3)[source]#
Parameters:
  • velocity_threshold (float)

  • angular_velocity_threshold (float)

  • joint_velocity_threshold (float)

load_mjcf(xml_path, pos=(0, 0, 0), quat=(0, 0, 0, 1), body_name=None, group='__UNSET__', static=False, notify_world_update=True)[source]#
Return type:

int

load_sdf(xml_path, scale=1.0, notify_world_update=True)[source]#
Return type:

int

load_urdf(xml_path, pos=(0, 0, 0), quat=(0, 0, 0, 1), body_name=None, group='__UNSET__', static=False, scale=1.0, rgba=None, notify_world_update=True)[source]#
Parameters:
  • body_name (str | None)

  • group (str | None)

  • scale (float)

Return type:

int

load_urdf_template(xml_path, replaces, pos=None, quat=None, **kwargs)[source]#
Parameters:
Return type:

int

loads_mjcf(xml_content, pos=None, quat=None, save_to=None, **kwargs)[source]#
Return type:

int

perform_collision_detection()[source]#
register_debug_item(name, item_id)[source]#
Parameters:
Return type:

int | Tuple[int, …]

remove_body(body_id)[source]#
remove_debug_item(item_id)[source]#
Parameters:

item_id (str | int | Tuple[int, ...])

remove_nonphysics_step_callback(cb)[source]#
reset_world()[source]#
set_enable_realtime_rendering(enable_realtime_rendering=None)[source]#
Parameters:

enable_realtime_rendering (bool | None)

set_rendering(enable)[source]#
Parameters:

enable (bool)

set_rendering_fps(render_fps=None)[source]#
Parameters:

render_fps (int | None)

step(steps=1, realtime_rendering=None)[source]#
Parameters:

realtime_rendering (bool | None)

step_until_stable(max_steps=int(1e6), velocity_threshold=1e-3, angular_velocity_threshold=1e-3, joint_velocity_threshold=1e-3)[source]#
Parameters:
  • max_steps (int)

  • velocity_threshold (float)

  • angular_velocity_threshold (float)

  • joint_velocity_threshold (float)

timeout(duration)[source]#
Parameters:

duration (float)

update_viewer()[source]#
update_viewer_twice()[source]#
wait_for_duration(duration)[source]#
wait_for_user(message='Press enter to continue...')[source]#
wait_forever()[source]#
with_fps(fps=None, render_fps=None, realtime_rendering=None)[source]#
Parameters:
  • fps (int | None)

  • render_fps (int | None)

  • realtime_rendering (bool | None)

DEFAULT_ASSETS_ROOT = '/Users/jiayuanm/Projects/Concepts/concepts/assets'#
DEFAULT_ENGINE_PARAMETERS = {'numSolverIterations': 10}#
DEFAULT_FPS = 240#
DEFAULT_GRAVITY = (0, 0, -9.8)#
debug_items: Dict[str, int | Tuple[int, ...]]#

The debug items that are added to the world. The key is the name of the item, and the value is the item id.

property world#

Alias for self.w.