pyrcf.components.callback_handlers ================================== .. py:module:: pyrcf.components.callback_handlers .. autoapi-nested-parse:: Defines custom callbacks that can be run in the control loop (pre-step and post-step). Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyrcf/components/callback_handlers/base_callbacks/index /autoapi/pyrcf/components/callback_handlers/pb_gui_callbacks/index /autoapi/pyrcf/components/callback_handlers/tkinter_gui_callbacks/index Classes ------- .. autoapisummary:: pyrcf.components.callback_handlers.CustomCallbackBase pyrcf.components.callback_handlers.RateTriggeredMultiCallbacks pyrcf.components.callback_handlers.PbGUIButtonCallback pyrcf.components.callback_handlers.PbGUISliderCallback pyrcf.components.callback_handlers.PbDebugFrameVizCallback pyrcf.components.callback_handlers.PbDebugPointsCallback pyrcf.components.callback_handlers.PbMultiGUISliderSingleCallback pyrcf.components.callback_handlers.TkGUIButtonCallback pyrcf.components.callback_handlers.TkGUISliderCallback pyrcf.components.callback_handlers.TkMultiGUISliderSingleCallback Package Contents ---------------- .. py:class:: CustomCallbackBase Bases: :py:obj:`abc.ABC` Abstract base class for defining custom callbacks to be executed in the control loop. .. py:method:: run_once() -> None :abstractmethod: To be called in loop. .. py:method:: cleanup() -> None Override if custom cleaning up/shutting down is required. .. py:class:: RateTriggeredMultiCallbacks(gui_callbacks: List[CustomCallbackBase], rate: float = None, clock: pyrcf.utils.time_utils.ClockBase = PythonPerfClock()) Bases: :py:obj:`CustomCallbackBase` Execute multiple `CustomCallbackBase` callbacks at the same specified (max) frequency. .. py:attribute:: _callbacks :type: List[CustomCallbackBase] :value: [] .. py:method:: add_callback(gui_callback: CustomCallbackBase) Add an instance of PbGUISliderCallback or PbMultiGUISliderSingleCallback to the same rate trigger. :param gui_callback: The GUI callback instance to add. :type gui_callback: CustomCallbackBase .. py:method:: run_once() This method has to be called for the slider callbacks to be executed. Will only execute if the trigger rate is met. .. py:method:: cleanup() Override if custom cleaning up/shutting down is required. .. py:class:: PbGUIButtonCallback(button_name: str, callback: Callable[[], None], cid: int) Bases: :py:obj:`PbGUICallback` Create a button in pybullet and specify the callback to apply the slider value to. .. py:attribute:: _button .. py:attribute:: _callback .. py:method:: run_once() This method has to be called for checking button press and for the callback to be executed. .. py:method:: cleanup() Override if custom cleaning up/shutting down is required. .. py:class:: PbGUISliderCallback(slider_name: str, slider_lower_lim: float, slider_upper_lim: float, slider_default_val: float, callback: Callable[[float], None], cid: int, run_only_if_value_changed: bool = True, mapping_function: Callable[[float], float] = lambda x: x) Bases: :py:obj:`PbGUICallback` Create a slider in pybullet and specify the callback to apply the slider value to. .. py:attribute:: _slider .. py:attribute:: _check_first :value: True .. py:attribute:: _callback .. py:method:: run_once() -> None This method has to be called for the callback to be executed. .. py:method:: cleanup() Override if custom cleaning up/shutting down is required. .. py:class:: PbDebugFrameVizCallback(callback: Callable[[], Tuple[Vector3D, QuatType]], cid: int, line_length: float = 0.2, line_width: float = 2, duration: float = 0.0) Bases: :py:obj:`PbGUICallback` Draw a coordinate frame in pybullet that changes its pose based on the pose returned by a callback function. .. py:attribute:: _frame_viz .. py:attribute:: _callback .. py:method:: run_once() This method has to be called for for getting the pose from the callback function and updating the frame visualiser's pose. .. py:method:: cleanup() Override if custom cleaning up/shutting down is required. .. py:class:: PbDebugPointsCallback(callback: Callable[[], List[Vector3D]], cid: int, point_positions: List[Vector3D] = None, point_size: float = 1.0, rgb: Tuple[float, float, float] = (1, 0, 0), lifetime: float = 0.0) Bases: :py:obj:`PbGUICallback` Visualise point(s)/sphere(s) in pybullet exposing a callback to change its position in the world. .. py:attribute:: _points_viz .. py:attribute:: _callback .. py:method:: run_once() To be called in loop. .. py:method:: cleanup() Override if custom cleaning up/shutting down is required. .. py:class:: PbMultiGUISliderSingleCallback(slider_names: List[str], slider_lower_lims: List[float], slider_upper_lims: List[float], slider_default_vals: List[float], callback: Callable[[List[float]], None], cid: int, run_only_if_value_changed: bool = True, mapping_functions: Callable[[float], float] | List[Callable[[float], float]] = lambda x: x) Bases: :py:obj:`PbGUICallback` Create multiple sliders in pybullet and use values from all the sliders in a single callback. .. py:attribute:: _sliders :type: List[pyrcf.utils.gui_utils.pb_gui_utils.PybulletGUISlider] :value: [] .. py:attribute:: _check_first :value: True .. py:attribute:: _callback .. py:method:: run_once() This method has to be called for the callback to be executed. .. py:method:: cleanup() Override if custom cleaning up/shutting down is required. .. py:method:: get_sliders() -> List[pyrcf.utils.gui_utils.pb_gui_utils.PybulletGUISlider] Get a list of all slider objects. :returns: List of slider objects. :rtype: List[PybulletGUISlider] .. py:class:: TkGUIButtonCallback(button_name: str, callback: Callable[[], None], tk_master: pyrcf.utils.gui_utils.tkinter_gui_utils.TkinterWidgetMaster = None) Bases: :py:obj:`TkGUICallback` Create a button in Tk and specify the callback to call when button is pressed. .. py:attribute:: _button .. py:attribute:: _callback .. py:method:: run_once() This method has to be called for checking button press and for the callback to be executed. .. py:method:: remove_gui_object() .. py:class:: TkGUISliderCallback(slider_name: str, slider_lower_lim: float, slider_upper_lim: float, slider_default_val: float, callback: Callable[[float], None], tk_master: pyrcf.utils.gui_utils.tkinter_gui_utils.TkinterWidgetMaster = None, mapping_function: Callable[[float], float] = lambda x: x, slider_resolution: float = 0.1) Bases: :py:obj:`TkGUICallback` Create a slider in pybullet and specify the callback to apply the slider value to. .. py:attribute:: _slider .. py:attribute:: _callback .. py:method:: run_once() -> None This method has to be called for the callback to be executed. .. py:method:: remove_gui_object() .. py:class:: TkMultiGUISliderSingleCallback(slider_names: List[str], slider_lower_lims: List[float], slider_upper_lims: List[float], slider_default_vals: List[float], callback: Callable[[List[float]], None], tk_master: pyrcf.utils.gui_utils.tkinter_gui_utils.TkinterWidgetMaster = None, mapping_functions: Callable[[float], float] | List[Callable[[float], float]] = lambda x: x, slider_resolutions: List[float] | float = 0.1) Bases: :py:obj:`TkGUICallback` Create multiple sliders and use values from all the sliders in a single callback. .. py:attribute:: _sliders :type: List[pyrcf.utils.gui_utils.tkinter_gui_utils.TkinterGUISlider] :value: [] .. py:attribute:: _callback .. py:method:: run_once() This method has to be called for the callback to be executed. .. py:method:: remove_gui_object() .. py:method:: get_sliders() -> List[pyrcf.utils.gui_utils.tkinter_gui_utils.TkinterGUISlider]