pyrcf.components.global_planners.ui_reference_generators

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

Attributes

DEFAULT_GAMEPAD_MAPPINGS

Default joystick mapping when using JoystickInterface as global planner for sending

DEFAULT_KEYBOARD_MAPPING

Default key mappings when using the keyboard interface for sending global motion

Classes

UIBase

Simple protocol and base class for a global motion planner interface.

DummyUI

Simple protocol and base class for a global motion planner interface.

KeyboardGlobalPlannerInterface

A simple keyboard interface inheriting from the GlobalMotionPlanner format.

PybulletGUIGlobalPlannerInterface

A Pybullet GUI interface to set joint/end-effector targets for any robot.

JoystickGlobalPlannerInterface

A simple joystick interface following the GlobalMotionPlanner protocol.

Package Contents

class pyrcf.components.global_planners.ui_reference_generators.UIBase

Bases: 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.

abstract 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.

Return type:

GlobalMotionPlan

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.

Return type:

GlobalMotionPlan

class pyrcf.components.global_planners.ui_reference_generators.DummyUI(squawk: bool = True)

Bases: 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.

_squawk
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.

Return type:

GlobalMotionPlan

class pyrcf.components.global_planners.ui_reference_generators.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: pyrcf.components.global_planners.ui_reference_generators.ui_base.UIBase

A simple keyboard interface inheriting from the GlobalMotionPlanner format.

_global_plan
_key_mappings
_parallel_mode
_verbose
_display
_font
_update_global_plan_from_user_input() None
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.

Return type:

GlobalMotionPlan

shutdown()

Cleanly shutdown the PyRCF component. Override in child class if required. The base class implements an empty function.

class pyrcf.components.global_planners.ui_reference_generators.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: 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).

cid
_enable_joint_sliders
_output_plan
_joint_sliders_enabled = False
_enable_ee_sliders
_ee_names_identified = False
_xyz_workspace_range
_latest_base_pose: Tuple[pyrcf.core.types.Vector3D, pyrcf.core.types.QuatType] = None
_pb_gui_callbacks
_setup_ee_slider_inits(ee_names: List[str])
_set_joint_targets_cb(vals: List[float])
_set_ee_pose_target_cb(vals: List[float], ee_id: int)
_get_ee_target_pos_ori_cb(ee_id: int)
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.

Return type:

GlobalMotionPlan

shutdown()

Cleanly shutdown the PyRCF component. Override in child class if required. The base class implements an empty function.

class pyrcf.components.global_planners.ui_reference_generators.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: pyrcf.components.global_planners.ui_reference_generators.ui_base.UIBase

A simple joystick interface following the GlobalMotionPlanner protocol.

_keep_alive = True
_runner_thread
_connection_verified = False
_global_plan
_mappings
_check_connection()
_read_thread()
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.

Return type:

GlobalMotionPlan

shutdown()

Cleanly shutdown the PyRCF component. Override in child class if required. The base class implements an empty function.

pyrcf.components.global_planners.ui_reference_generators.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.

pyrcf.components.global_planners.ui_reference_generators.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