pyrcf.utils.sim_utils ===================== .. py:module:: pyrcf.utils.sim_utils .. autoapi-nested-parse:: Utility tools that are specific to and can be used only with simulated instances of a robot. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyrcf/utils/sim_utils/pybullet_debug_robot/index /autoapi/pyrcf/utils/sim_utils/pybullet_robot_visualizer/index Classes ------- .. autoapisummary:: pyrcf.utils.sim_utils.PybulletRobotVisualizer pyrcf.utils.sim_utils.PybulletDebugRobot pyrcf.utils.sim_utils.PbDebugRobotWithJointCallback Package Contents ---------------- .. py:class:: 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. .. py:attribute:: sim_robot .. py:attribute:: _init_j .. py:attribute:: _ignore_joints_with_str .. py:attribute:: _default_base_pose .. py:attribute:: _base_pose_target .. py:attribute:: _enable_stepping :value: False .. py:attribute:: _j_names :value: [] .. py:attribute:: _j_lower_lims :value: [] .. py:attribute:: _j_upper_lims :value: [] .. py:attribute:: _ok_to_run :value: True .. py:attribute:: _read_button_thread :value: None .. py:method:: run(sim_step_rate: float = 240, slider_update_rate: float = 10, additional_callbacks: List[Callable[[], None]] = None) Run the visualizer thread (non-blocking). :param sim_step_rate: 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). :type sim_step_rate: float, optional :param slider_update_rate: Update rate (Hz) for reading the joint sliders in pybullet GUI to update robot states. Defaults to 10. :type slider_update_rate: float, optional .. py:method:: close() Close the visualizer. .. py:method:: 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 :classmethod: Visualizer for a PybulletRobot instance to test joint positioning etc. See `examples/utils_demo/demo_bullet_robot_visualizer.py` :param pb_robot: The PybulletRobot instance to load. :type pb_robot: PybulletRobot :param starting_joint_positions: Mapping from joint names to starting positions to be used during the visualisation. Defaults to zeros. :type starting_joint_positions: Mapping[str, float], optional :param ignore_joints_with_str: 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. :type ignore_joints_with_str: List[str], optional .. py:class:: 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`). .. py:attribute:: _cid .. py:attribute:: _viz_robot_id .. py:attribute:: _link_ids .. py:attribute:: _visible :value: True .. py:attribute:: _pb_keys :value: ['jointIndex', 'jointName', 'jointType'] .. py:attribute:: num_js .. py:attribute:: j_infos .. py:attribute:: jinfo .. py:attribute:: _actuated_joint_names :value: [] .. py:attribute:: joint_ids .. py:attribute:: _joint_name_to_index .. py:method:: disable_visualisation() .. py:method:: set_visual_rgba(rgba: Tuple[float, float, float, float]) .. py:method:: enable_visualisation() .. py:method:: toggle_visualisation() .. py:method:: set_base_pose(position: numpy.ndarray, orientation: numpy.ndarray) .. py:method:: set_joint_positions(joint_positions: numpy.ndarray, joint_names: List[str] = None) .. py:method:: close() .. py:class:: 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: None, 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: :py:obj:`pyrcf.components.callback_handlers.base_callbacks.CustomCallbackBase` Abstract base class for defining custom callbacks to be executed in the control loop. .. py:attribute:: _viz_robot .. py:attribute:: _joint_names .. py:attribute:: _js_callback .. py:attribute:: _bpose_callback .. py:method:: 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. .. py:method:: cleanup() Override if custom cleaning up/shutting down is required.