pyrcf.utils.sim_utils

Utility tools that are specific to and can be used only with simulated instances of a robot.

Submodules

Classes

PybulletRobotVisualizer

Visualizer for a PybulletRobot instance to test joint positioning etc.

PybulletDebugRobot

A debugger robot visualiser for bullet robots. These robots are meant to be used for

PbDebugRobotWithJointCallback

Abstract base class for defining custom callbacks to be executed in the control loop.

Package Contents

class pyrcf.utils.sim_utils.PybulletRobotVisualizer(pb_sim_interface: pybullet_robot.BulletRobot, joint_lower_lims: Mapping[str, float], joint_upper_lims: Mapping[str, float], starting_joint_positions: Mapping[str, float] = None, ignore_joints_with_str: List[str] = None)

Visualizer for a PybulletRobot instance to test joint positioning etc.

See examples/utils_demo/demo_bullet_robot_visualizer.py.

Warning

DO NOT use other GUI utils for pybullet (other sliders, buttons etc), when using this. This class uses the removeAllUserParameters parameters exposed in pybullet, which means it can remove every debug item created externally.

TODO: fix this to only remove self-created items.

sim_robot
_init_j = None
_ignore_joints_with_str = ['_wheel']
_default_base_pose
_base_pose_target
_enable_stepping = False
_j_names = []
_j_lower_lims = []
_j_upper_lims = []
_ok_to_run = True
_read_button_thread = None
run(sim_step_rate: float = 240, slider_update_rate: float = 10, additional_callbacks: List[Callable[[], None]] = None)

Run the visualizer thread (non-blocking).

Parameters:
  • sim_step_rate (float, optional) – The desired rate (Hz) for calling step simulation (This is not the timestep used in the physics of the simulation). Defaults to 240 (technically this should make it realtime).

  • slider_update_rate (float, optional) – Update rate (Hz) for reading the joint sliders in pybullet GUI to update robot states. Defaults to 10.

close()

Close the visualizer.

classmethod fromBulletRobot(pb_robot: pyrcf.components.robot_interfaces.simulation.pybullet_robot.PybulletRobot, starting_joint_positions: Mapping[str, float] = None, ignore_joints_with_str: List[str] = None) PybulletRobotVisualizer

Visualizer for a PybulletRobot instance to test joint positioning etc.

See examples/utils_demo/demo_bullet_robot_visualizer.py

Parameters:
  • pb_robot (PybulletRobot) – The PybulletRobot instance to load.

  • starting_joint_positions (Mapping[str, float], optional) – Mapping from joint names to starting positions to be used during the visualisation. Defaults to zeros.

  • ignore_joints_with_str (List[str], optional) – List of substrings to look for in joint names, matching joints will be ignored from the joint sliders GUI (useful for joints such as wheels). Defaults to [“_wheel”] if None provided.

class pyrcf.utils.sim_utils.PybulletDebugRobot(urdf_path: str, cid: int = 0, base_position: numpy.ndarray = np.zeros(3), base_orientation: numpy.array = np.array([0, 0, 0, 1]), rgba: Tuple[float, float, float, float] | None = (0, 0, 0, 0.3))

A debugger robot visualiser for bullet robots. These robots are meant to be used for visualising ideal motion plans etc. for debugging (e.g. as a control loop debugger, implemented in utils.ctrl_loop_debuggers.BulletRobotPlanDebugger).

_cid = 0
_viz_robot_id
_visible = True
_actuated_joint_names = []
_joint_name_to_index
disable_visualisation()
set_visual_rgba(rgba: Tuple[float, float, float, float])
enable_visualisation()
toggle_visualisation()
set_base_pose(position: numpy.ndarray, orientation: numpy.ndarray)
set_joint_positions(joint_positions: numpy.ndarray, joint_names: List[str] = None)
close()
class pyrcf.utils.sim_utils.PbDebugRobotWithJointCallback(urdf_path: str, cid: int, joint_names: List[str], get_joint_positions_callback: Callable[[], numpy.ndarray], get_base_pose_callback: Callable[[], Tuple[Vector3D, QuatType]] = lambda : ..., base_position: numpy.ndarray = np.zeros(3), base_orientation: numpy.array = np.array([0, 0, 0, 1]), rgba: Tuple[float, float, float, float] | None = (0, 0, 0, 0.3))

Bases: pyrcf.components.callback_handlers.base_callbacks.CustomCallbackBase

Abstract base class for defining custom callbacks to be executed in the control loop.

_viz_robot
_joint_names
_js_callback
_bpose_callback
run_once()

This method has to be called for setting the joint positions. This will run the callback method to get the desired joint positions.

cleanup()

Override if custom cleaning up/shutting down is required.