pyrcf.components.global_planners.ui_reference_generators.ui_utils
Helper functions for updating provided GlobalMotionPlan objects for UI Interfaces.
Classes
Helper functions for updating provided GlobalMotionPlan objects (internal use only). |
|
Helper to bind a button to change the value of different joints incrementally. |
|
Helper tool to make holding a button change the behaviour of another button/trigger. |
|
Helper class for creating keyboard mapppings for keyboard_interface. |
|
Helper class for creating mapppings for non-binary analog keys (e.g. analog gamepad stick). |
Functions
|
Get a docstring for a given Mapping from string to callable. |
Module Contents
- class pyrcf.components.global_planners.ui_reference_generators.ui_utils._GlobalPlanModifiers
Helper functions for updating provided GlobalMotionPlan objects (internal use only).
- static set_linear_velocity(global_plan: pyrcf.core.types.GlobalMotionPlan, linear_velocity: numpy.ndarray, scaling: numpy.ndarray, prev_vel_scaling: numpy.ndarray) pyrcf.core.types.GlobalMotionPlan
- static set_rotational_velocity(global_plan: pyrcf.core.types.GlobalMotionPlan, rotational_velocity: numpy.ndarray, scaling: numpy.ndarray, prev_vel_scaling: numpy.ndarray) pyrcf.core.types.GlobalMotionPlan
- static set_plan_mode(global_plan: pyrcf.core.types.GlobalMotionPlan, planner_mode: pyrcf.core.types.PlannerMode)
- static toggle_plan_mode(global_plan: pyrcf.core.types.GlobalMotionPlan, planner_modes: List[pyrcf.core.types.PlannerMode])
- static increment_linear_velocity(global_plan: pyrcf.core.types.GlobalMotionPlan, linear_velocity: numpy.ndarray) pyrcf.core.types.GlobalMotionPlan
- static increment_rotational_velocity(global_plan: pyrcf.core.types.GlobalMotionPlan, rotational_velocity: numpy.ndarray) pyrcf.core.types.GlobalMotionPlan
- static increment_relative_position(global_plan: pyrcf.core.types.GlobalMotionPlan, position_delta: numpy.ndarray)
- static increment_joint_position(global_plan: pyrcf.core.types.GlobalMotionPlan, joint_id: int, position_delta: float)
- class pyrcf.components.global_planners.ui_reference_generators.ui_utils.GlobalPlanJointPositionIncrementer(update_only_if_planner_activated: bool = True)
Helper to bind a button to change the value of different joints incrementally. One button can be used to increment the value of the joint by a specific number. Another button(s) can be used to change the index of the joint being modified.
- _check_and_update
- joint_id = 0
- _check_ready(global_plan: pyrcf.core.types.GlobalMotionPlan)
- increment_joint_target(global_plan: pyrcf.core.types.GlobalMotionPlan, position_delta: float)
Use as binding for a button in the format: { <button_id>: partial(obj.increment_joint_target, position_delta=value) }
- increase_joint_id(global_plan: pyrcf.core.types.GlobalMotionPlan)
Change the id of the joint being modified by incrementing the index by 1. Use the handle to this function directly as binding for a button in the format: { <button_id>: obj.increase_joint_id }
- decrease_joint_id(global_plan: pyrcf.core.types.GlobalMotionPlan)
Change the id of the joint being modified by reducing the index by 1. Use the handle to this function directly as binding for a button in the format: { <button_id>: obj.decrease_joint_id }
- class pyrcf.components.global_planners.ui_reference_generators.ui_utils.Hold2SwapBindings(default_binding: Callable[[pyrcf.core.types.GlobalMotionPlan, Any], pyrcf.core.types.GlobalMotionPlan], alternate_binding: Callable[[pyrcf.core.types.GlobalMotionPlan, Any], pyrcf.core.types.GlobalMotionPlan])
Helper tool to make holding a button change the behaviour of another button/trigger.
- _default_binding
- _alternate_binding
- _trigger_held = False
- trigger_swap(_any: Any)
Set this function as the binding for the trigger hold button (“button B”).
- use_binding(*args, **kwargs)
Set this function as the binding for the main button (“button A”).
- class pyrcf.components.global_planners.ui_reference_generators.ui_utils.Key2GlobalPlanHelper
Helper class for creating keyboard mapppings for keyboard_interface.
Provides static methods/objects that can be used for easily creating lambdas for creating key mappings (to be used for keyboard_interface)
Each of the following will return a callable in the appropriate signature and can be used directly for the keyboard_interface. (see DEFAULT_KEYBOARD_MAPPING defined below)
- Available objects/methods (static):
CUSTOM
IDLE
HOLD_POSITION
APPLY_LIN_VEL(linear_velocity: np.ndarray)
APPLY_ROT_VEL(rotational_velocity: np.ndarray)
APPLY_LIN_VEL_DELTA(linear_velocity: np.ndarray)
APPLY_ROT_VEL_DELTA(rotational_velocity: np.ndarray)
- CUSTOM: Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
static object that returns a callable. Sets the planner_mode to CUSTOM (controller activate).
- IDLE: Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
static object that returns a callable. Sets the planner_mode to IDLE.
- HOLD_POSITION: Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
static object that returns a callable. Sets the planner_mode to HOLD_POSITION.
- TOGGLE_CUSTOM_IDLE: Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
- static APPLY_LIN_VEL(linear_velocity: numpy.ndarray) Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
Static method that returns a callable for setting linear velocity (takes one argument).
- Parameters:
linear_velocity (np.ndarray) – linear velocity (in base frame) to be set (m/sec)
- Returns:
- returns a callable that can be used by
the keyboard_interface.
- Return type:
Callable[[GlobalMotionPlan], GlobalMotionPlan]
- static APPLY_ROT_VEL(rotational_velocity: numpy.ndarray) Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
Static method that returns a callable for setting rotational velocity (takes one argument).
- Parameters:
rotational_velocity (np.ndarray) – rotational velocity (in base frame) to be set (rad/sec)
- Returns:
- returns a callable that can be used by
the keyboard_interface.
- Return type:
Callable[[GlobalMotionPlan], GlobalMotionPlan]
- static APPLY_LIN_VEL_DELTA(linear_velocity: numpy.ndarray) Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
- Static method that returns a callable for INCREMENTING current linear velocity (takes
one argument).
- Parameters:
linear_velocity (np.ndarray) – linear velocity (in base frame) to be added (can be negative) (m/sec)
- Returns:
- returns a callable that can be used by
the keyboard_interface.
- Return type:
Callable[[GlobalMotionPlan], GlobalMotionPlan]
- static APPLY_ROT_VEL_DELTA(rotational_velocity: numpy.ndarray) Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
- Static method that returns a callable for INCREMENTING current rotational velocity
(takes one argument).
- Parameters:
rotational_velocity (np.ndarray) – rotational velocity (in base frame) to be added (can be negative) (rad/sec)
- Returns:
- returns a callable that can be used by
the keyboard_interface.
- Return type:
Callable[[GlobalMotionPlan], GlobalMotionPlan]
- static APPLY_RELATIVE_POS_DELTA(position_delta: numpy.ndarray) Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
Static method that returns a callable for INCREMENTING position in teleop frame (takes one argument).
- Parameters:
position_delta (np.ndarray) – values to be added to current position of the robot base in the teleop frame
- Returns:
- returns a callable that can be used by
the keyboard_interface.
- Return type:
Callable[[GlobalMotionPlan], GlobalMotionPlan]
- static APPLY_JOINT_POS_DELTA(joint_id: int, position_delta: float) Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
Static method that returns a callable for INCREMENTING joint position for the specified joint id.
- Parameters:
position_delta (float) – value to be added to current joint position
- Returns:
- returns a callable that can be used by
the keyboard_interface.
- Return type:
Callable[[GlobalMotionPlan], GlobalMotionPlan]
- class pyrcf.components.global_planners.ui_reference_generators.ui_utils.Analog2GlobalPlanHelper
Helper class for creating mapppings for non-binary analog keys (e.g. analog gamepad stick).
Provides static methods/objects that can be used for easily creating lambdas for creating key mappings (to be used for non-binary analog keys)
Each of the following will return a callable in the appropriate signature and can be used directly for the non-binary analog keys. (see DEFAULT_KEYBOARD_MAPPING defined below)
- Available objects/methods (static):
CUSTOM
IDLE
HOLD_POSITION
APPLY_LIN_VEL(linear_velocity: np.ndarray)
APPLY_ROT_VEL(rotational_velocity: np.ndarray)
APPLY_LIN_VEL_DELTA(linear_velocity: np.ndarray)
APPLY_ROT_VEL_DELTA(rotational_velocity: np.ndarray)
- static APPLY_LIN_VEL_SCALED(max_linear_velocity: numpy.ndarray, prev_vel_scaling: numpy.ndarray) Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
Static method that returns a callable for setting linear velocity (takes 2 arguments).
- Parameters:
max_linear_velocity (np.ndarray) – max linear velocity (in base frame) to be set (m/sec)
prev_vel_scaling (np.ndarray) – scaling to use on previous velocity. This is added to the new scaled linear velocity input.
- Returns:
- returns a
callable that can be used by the joystick_interface with 2 arguments (global plan, analog np.ndarray scale value for each axis, np.ndarray scale value for previous value in the global plan message).
- Return type:
Callable[[GlobalMotionPlan, np.ndarray, np.ndarray], GlobalMotionPlan]
- static APPLY_ROT_VEL_SCALED(max_rotational_velocity: numpy.ndarray, prev_vel_scaling: numpy.ndarray) Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]
Static method that returns a callable for setting rotational velocity (takes 2 arguments).
- Parameters:
max_rotational_velocity (np.ndarray) – max rotational velocity (in base frame) to be set (m/sec)
prev_vel_scaling (np.ndarray) – scaling to use on previous velocity. This is added to the new scaled rotational velocity input.
- Returns:
- returns a
callable that can be used by the joystick_interface with 2 arguments (global plan, analog np.ndarray scale value for each axis, np.ndarray scale value for previous value in the global plan message).
- Return type:
Callable[[GlobalMotionPlan, np.ndarray, np.ndarray], GlobalMotionPlan]
- pyrcf.components.global_planners.ui_reference_generators.ui_utils.get_keymapping_doc(key_mappings: Dict[str, Callable[[pyrcf.core.types.GlobalMotionPlan], pyrcf.core.types.GlobalMotionPlan]])
Get a docstring for a given Mapping from string to callable.