pyrcf.components.global_planners.ui_reference_generators ======================================================== .. py:module:: pyrcf.components.global_planners.ui_reference_generators .. autoapi-nested-parse:: Module containing interface and definitions of User interfaces such as keyboard interface and joystick interface that can be used in the control loop in place of true Global planners. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/pyrcf/components/global_planners/ui_reference_generators/joystick_interface/index /autoapi/pyrcf/components/global_planners/ui_reference_generators/key_mappings/index /autoapi/pyrcf/components/global_planners/ui_reference_generators/keyboard_interface/index /autoapi/pyrcf/components/global_planners/ui_reference_generators/pb_gui_iinterface/index /autoapi/pyrcf/components/global_planners/ui_reference_generators/ui_base/index /autoapi/pyrcf/components/global_planners/ui_reference_generators/ui_utils/index Attributes ---------- .. autoapisummary:: pyrcf.components.global_planners.ui_reference_generators.DEFAULT_GAMEPAD_MAPPINGS pyrcf.components.global_planners.ui_reference_generators.DEFAULT_KEYBOARD_MAPPING Classes ------- .. autoapisummary:: pyrcf.components.global_planners.ui_reference_generators.UIBase pyrcf.components.global_planners.ui_reference_generators.DummyUI pyrcf.components.global_planners.ui_reference_generators.KeyboardGlobalPlannerInterface pyrcf.components.global_planners.ui_reference_generators.PybulletGUIGlobalPlannerInterface pyrcf.components.global_planners.ui_reference_generators.JoystickGlobalPlannerInterface Package Contents ---------------- .. py:class:: UIBase Bases: :py:obj:`pyrcf.components.global_planners.global_planner_base.GlobalMotionPlannerBase` Simple protocol and base class for a global motion planner interface. This protocol has to be respected by all classes that generate a GlobalMotionPlan object to be used in the control loop by local planners. (e.g. user interfaces such as keyboard_interface). INFO: A general 'global motion planner' is a planner that performs high-level planning that is dependent on the task the robot has to perform. For e.g. for a A->B locomotion, the global planner might generate a sequence of collision-aware waypoints for the local planner to respect. .. py:method:: process_user_input(robot_state: pyrcf.core.types.RobotState, t: float = None, dt: float = None) -> pyrcf.core.types.GlobalMotionPlan :abstractmethod: Processes user input and returns a GlobalMotionPlan object. The method that should be implemented by child classes where a user input is processed and appropriate GlobalMotionPlan is returned. :returns: the generated motion plan object. :rtype: GlobalMotionPlan .. py:method:: generate_global_plan(robot_state: pyrcf.core.types.RobotState, t: float = None, dt: float = None) -> pyrcf.core.types.GlobalMotionPlan This method is following the global planner protocol. Internally this just calls the `process_user_input()` method. :returns: the generated motion plan object. :rtype: GlobalMotionPlan .. py:class:: DummyUI(squawk: bool = True) Bases: :py:obj:`UIBase` Simple protocol and base class for a global motion planner interface. This protocol has to be respected by all classes that generate a GlobalMotionPlan object to be used in the control loop by local planners. (e.g. user interfaces such as keyboard_interface). INFO: A general 'global motion planner' is a planner that performs high-level planning that is dependent on the task the robot has to perform. For e.g. for a A->B locomotion, the global planner might generate a sequence of collision-aware waypoints for the local planner to respect. .. py:attribute:: _squawk .. py:method:: process_user_input(robot_state: pyrcf.core.types.RobotState, t: float = None, dt: float = None) -> pyrcf.core.types.GlobalMotionPlan Processes user input and returns a GlobalMotionPlan object. The method that should be implemented by child classes where a user input is processed and appropriate GlobalMotionPlan is returned. :returns: the generated motion plan object. :rtype: GlobalMotionPlan .. py:class:: KeyboardGlobalPlannerInterface(key_mappings: Dict[str, Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]] = None, default_global_plan: pyrcf.core.types.GlobalMotionPlan = GlobalMotionPlan(), window_size: Tuple[int, int] = (1000, 1000), parallel_mode: bool = False, verbose: bool = False) Bases: :py:obj:`pyrcf.components.global_planners.ui_reference_generators.ui_base.UIBase` A simple keyboard interface inheriting from the GlobalMotionPlanner format. .. py:attribute:: _global_plan .. py:attribute:: _key_mappings .. py:attribute:: _parallel_mode .. py:attribute:: _verbose .. py:attribute:: _display .. py:attribute:: _font .. py:method:: _update_global_plan_from_user_input() -> None .. py:method:: process_user_input(robot_state: pyrcf.core.types.RobotState, t: float = None, dt: float = None) -> pyrcf.core.types.GlobalMotionPlan Processes user input and returns a GlobalMotionPlan object. The method that should be implemented by child classes where a user input is processed and appropriate GlobalMotionPlan is returned. :returns: the generated motion plan object. :rtype: GlobalMotionPlan .. py:method:: shutdown() Cleanly shutdown the PyRCF component. Override in child class if required. The base class implements an empty function. .. py:class:: PybulletGUIGlobalPlannerInterface(enable_joint_sliders: bool = True, joint_lims: Mapping[str, Tuple[float, float]] = None, enable_ee_sliders: bool = False, ee_names: List[str] = None, xyz_workspace_range: Tuple[pyrcf.core.types.Vector3D, pyrcf.core.types.Vector3D] = (np.array([-1, -1, -1]), np.array([1, 1, 1])), cid: int = None, slider_read_rate: float = 10, slider_rate_clock: pyrcf.utils.time_utils.ClockBase = PythonPerfClock(), js_viz_robot_urdf: str = None, js_viz_robot_rgba: Tuple[float, float, float, float] = (1.0, 0.0, 0.0, 0.2)) Bases: :py:obj:`pyrcf.components.global_planners.ui_reference_generators.ui_base.UIBase` A Pybullet GUI interface to set joint/end-effector targets for any robot. This can be used as a GlobalPlanner (follows the GlobalMotionPlanner definition). .. py:attribute:: cid .. py:attribute:: _enable_joint_sliders .. py:attribute:: _output_plan .. py:attribute:: _joint_sliders_enabled :value: False .. py:attribute:: _enable_ee_sliders .. py:attribute:: _ee_names_identified :value: False .. py:attribute:: _xyz_workspace_range .. py:attribute:: _latest_base_pose :type: Tuple[pyrcf.core.types.Vector3D, pyrcf.core.types.QuatType] :value: None .. py:attribute:: _pb_gui_callbacks .. py:method:: _setup_ee_slider_inits(ee_names: List[str]) .. py:method:: _set_joint_targets_cb(vals: List[float]) .. py:method:: _set_ee_pose_target_cb(vals: List[float], ee_id: int) .. py:method:: _get_ee_target_pos_ori_cb(ee_id: int) .. py:method:: process_user_input(robot_state: pyrcf.core.types.RobotState, t: float = None, dt: float = None) -> pyrcf.core.types.GlobalMotionPlan Processes user input and returns a GlobalMotionPlan object. The method that should be implemented by child classes where a user input is processed and appropriate GlobalMotionPlan is returned. :returns: the generated motion plan object. :rtype: GlobalMotionPlan .. py:method:: shutdown() Cleanly shutdown the PyRCF component. Override in child class if required. The base class implements an empty function. .. py:class:: JoystickGlobalPlannerInterface(gamepad_mappings: pyrcf.components.global_planners.ui_reference_generators.key_mappings.GamePadMappings = DEFAULT_GAMEPAD_MAPPINGS, default_global_plan: pyrcf.core.types.GlobalMotionPlan = GlobalMotionPlan(), check_connection_at_init: bool = False) Bases: :py:obj:`pyrcf.components.global_planners.ui_reference_generators.ui_base.UIBase` A simple joystick interface following the GlobalMotionPlanner protocol. .. py:attribute:: _keep_alive :value: True .. py:attribute:: _runner_thread .. py:attribute:: _connection_verified :value: False .. py:attribute:: _global_plan .. py:attribute:: _mappings .. py:method:: _check_connection() .. py:method:: _read_thread() .. py:method:: process_user_input(robot_state: pyrcf.core.types.RobotState = None, t: float = None, dt: float = None) -> pyrcf.core.types.GlobalMotionPlan Processes user input and returns a GlobalMotionPlan object. The method that should be implemented by child classes where a user input is processed and appropriate GlobalMotionPlan is returned. :returns: the generated motion plan object. :rtype: GlobalMotionPlan .. py:method:: shutdown() Cleanly shutdown the PyRCF component. Override in child class if required. The base class implements an empty function. .. py:data:: DEFAULT_GAMEPAD_MAPPINGS Default joystick mapping when using JoystickInterface as global planner for sending global plan messages. NOTE: SOUTH, EAST, WEST, NORTH below indicates the keys on the right side of the joypad. (e.g. this is A, B, X, Y respectively on logitech joypad) BUG: WEST and NORTH for logitech seems to be switched!! - Start btn --> Toggle between CUSTOM and IDLE modes - South --> HOLD_POSITION - DPAD UP --> Increase joint position target for the current joint id by 0.01 units. - DPAD DOWN --> Decrease joint position target for the current joint id by 0.01 units. - DPAD LEFT --> Change the ID of the joint by -1 (affects actions of DPAD UP and DOWN buttons). - DPAD LEFT --> Change the ID of the joint by +1 (affects actions of DPAD UP and DOWN buttons). - LEFT Analog up/down --> apply linear velocity forward/backward (x axis) (max vel: 0.5 m/s) (OR) apply linear velocity up/down (z axis) (max vel: 0.5 m/s). Toggle behaviour of LEFT Analog up/down using `LB` button. - LEFT Analog right/left --> apply linear velocity right/left (base frame) (max vel: 0.5 m/s) - RIGHT Analog right/left --> apply rotational velocity (about z axis of base frame; yaw rate) (max vel: 1.0 rad/sec) (OR) apply rotational velocity (about x axis; roll rate) (max vel: 0.5 m/s). Toggle behaviour of RIGHT Analog right/left using `RB` button. - RIGHT Analog up/down --> apply rotational velocity (about y axis of global frame; pitch rate) - LB: This button changes the behaviour of the LEFT analog stick. Switches between sending linear velocity along X, and linear velocity along Z. - RB: This button changes the behaviour of the RIGHT analog stick. Switches between sending angular velocity about X, and linear velocity about Z. .. py:data:: DEFAULT_KEYBOARD_MAPPING Default key mappings when using the keyboard interface for sending global motion plan messages. - o --> TOGGLE between CUSTOM and IDLE - h --> HOLD_POSITION - w --> APPLY_LIN_VEL_DELTA(np.array([0.05, 0.0, 0.0])) - s --> APPLY_LIN_VEL_DELTA(np.array([-0.05, 0.0, 0.0])) - q --> APPLY_LIN_VEL_DELTA(np.array([0.0, 0.05, 0.0])) - e --> APPLY_LIN_VEL_DELTA(np.array([0.0, -0.05, 0.0])) - a --> APPLY_ROT_VEL_DELTA(np.array([0.0, 0.0, 0.1])) - d --> APPLY_ROT_VEL_DELTA(np.array([0.0, 0.0, -0.1])) - up --> increment selected joint by 0.01 units - down --> reduce reference joint position target for selected joint by 0.01 units - right --> increment the id of the joint to be controlled with up/down keys - left --> reduce the id of the joint to be controlled with up/down keys by 1