pycram.validation.goal_validator

Contents

pycram.validation.goal_validator#

Attributes#

Classes#

GoalValidator

A class to validate the goal by tracking the goal achievement progress.

PoseGoalValidator

A class to validate the pose goal by tracking the goal achievement progress.

MultiPoseGoalValidator

A class to validate the multi-pose goal by tracking the goal achievement progress.

PositionGoalValidator

A class to validate the position goal by tracking the goal achievement progress.

MultiPositionGoalValidator

A class to validate the multi-position goal by tracking the goal achievement progress.

OrientationGoalValidator

A class to validate the orientation goal by tracking the goal achievement progress.

MultiOrientationGoalValidator

A class to validate the multi-orientation goal by tracking the goal achievement progress.

JointPositionGoalValidator

A class to validate the joint position goal by tracking the goal achievement progress.

MultiJointPositionGoalValidator

A class to validate the multi-joint position goal by tracking the goal achievement progress.

Functions#

validate_object_pose(pose_setter_func)

A decorator to validate the object pose.

validate_multiple_object_poses(pose_setter_func)

A decorator to validate multiple object poses.

validate_joint_position(position_setter_func)

A decorator to validate the joint position.

validate_multiple_joint_positions(position_setter_func)

A decorator to validate the joint positions, this function does not validate the virtual joints,

create_multiple_joint_goal_validator(...)

Validate the multiple joint goals, and wait until the goal is achieved.

Module Contents#

pycram.validation.goal_validator.Joint#
pycram.validation.goal_validator.OptionalArgCallable#
class pycram.validation.goal_validator.GoalValidator(error_checker: pycram.validation.error_checkers.ErrorChecker, current_value_getter: OptionalArgCallable, acceptable_percentage_of_goal_achieved: typing_extensions.Optional[float] = 0.8)#

A class to validate the goal by tracking the goal achievement progress.

raise_error: typing_extensions.Optional[bool] = False#

Whether to raise an error if the goal is not achieved.

total_wait_time: typing_extensions.Optional[datetime.timedelta] = None#

The total wait time that was spent waiting for the goal to be achieved.

error_checker: pycram.validation.error_checkers.ErrorChecker#
current_value_getter: typing_extensions.Callable[[typing_extensions.Optional[typing_extensions.Any]], typing_extensions.Any]#
acceptable_percentage_of_goal_achieved: typing_extensions.Optional[float] = 0.8#
goal_value: typing_extensions.Optional[typing_extensions.Any] = None#
initial_error: typing_extensions.Optional[numpy.ndarray] = None#
current_value_getter_input: typing_extensions.Optional[typing_extensions.Any] = None#
register_goal_and_wait_until_achieved(goal_value: typing_extensions.Any, current_value_getter_input: typing_extensions.Optional[typing_extensions.Any] = None, initial_value: typing_extensions.Optional[typing_extensions.Any] = None, acceptable_error: typing_extensions.Optional[typing_extensions.Union[float, typing_extensions.Iterable[float]]] = None, max_wait_time: typing_extensions.Optional[float] = 1, time_per_read: typing_extensions.Optional[float] = 0.01) None#

Register the goal value and wait until the target is reached.

Parameters:
  • goal_value – The goal value.

  • current_value_getter_input – The values that are used as input to the current value getter.

  • initial_value – The initial value.

  • acceptable_error – The acceptable error.

  • max_wait_time – The maximum time to wait.

  • time_per_read – The time to wait between each read.

wait_until_goal_is_achieved(max_wait_time: typing_extensions.Optional[datetime.timedelta] = timedelta(seconds=2), time_per_read: typing_extensions.Optional[datetime.timedelta] = timedelta(milliseconds=10)) None#

Wait until the target is reached.

Parameters:
  • max_wait_time – The maximum time to wait.

  • time_per_read – The time to wait between each read.

reset() None#

Reset the goal validator.

property _acceptable_error: numpy.ndarray#

The acceptable error.

property acceptable_error: numpy.ndarray#

The acceptable error.

property tiled_acceptable_error: typing_extensions.Optional[numpy.ndarray]#

The tiled acceptable error.

register_goal(goal_value: typing_extensions.Any, current_value_getter_input: typing_extensions.Optional[typing_extensions.Any] = None, initial_value: typing_extensions.Optional[typing_extensions.Any] = None, acceptable_error: typing_extensions.Optional[typing_extensions.Union[float, typing_extensions.Iterable[float]]] = None)#

Register the goal value.

Parameters:
  • goal_value – The goal value.

  • current_value_getter_input – The values that are used as input to the current value getter.

  • initial_value – The initial value.

  • acceptable_error – The acceptable error.

update_initial_error(goal_value: typing_extensions.Any, initial_value: typing_extensions.Optional[typing_extensions.Any] = None) None#

Calculate the initial error.

Parameters:
  • goal_value – The goal value.

  • initial_value – The initial value.

property current_value: typing_extensions.Any#

The current value of the monitored variable.

property current_error: numpy.ndarray#

The current error.

calculate_error(value_1: typing_extensions.Any, value_2: typing_extensions.Any) numpy.ndarray#

Calculate the error between two values.

Parameters:
  • value_1 – The first value.

  • value_2 – The second value.

Returns:

The error.

property percentage_of_goal_achieved: float#

The relative (relative to the acceptable error) achieved percentage of goal.

property actual_percentage_of_goal_achieved: float#

The percentage of goal achieved.

property relative_current_error: numpy.ndarray#

The relative current error (relative to the acceptable error).

property relative_initial_error: numpy.ndarray#

The relative initial error (relative to the acceptable error).

get_relative_error(error: typing_extensions.Any, threshold: typing_extensions.Optional[float] = 0.001) numpy.ndarray#

Get the relative error by comparing the error with the acceptable error and filtering out the errors that are less than the threshold.

Parameters:
  • error – The error.

  • threshold – The threshold.

Returns:

The relative error.

property goal_achieved: bool#

Check if the goal is achieved.

property is_current_error_acceptable: bool#

Check if the error is acceptable.

property goal_not_achieved_message#

Message to be displayed when the goal is not achieved.

class pycram.validation.goal_validator.PoseGoalValidator(current_pose_getter: OptionalArgCallable = None, acceptable_error: typing_extensions.Union[typing_extensions.Tuple[float], typing_extensions.Iterable[typing_extensions.Tuple[float]]] = (0.001, np.pi / 180), acceptable_percentage_of_goal_achieved: typing_extensions.Optional[float] = 0.8, is_iterable: typing_extensions.Optional[bool] = False)#

Bases: GoalValidator

A class to validate the pose goal by tracking the goal achievement progress.

class pycram.validation.goal_validator.MultiPoseGoalValidator(current_poses_getter: OptionalArgCallable = None, acceptable_error: typing_extensions.Union[typing_extensions.Tuple[float], typing_extensions.Iterable[typing_extensions.Tuple[float]]] = (0.01, 5 * np.pi / 180), acceptable_percentage_of_goal_achieved: typing_extensions.Optional[float] = 0.8)#

Bases: PoseGoalValidator

A class to validate the multi-pose goal by tracking the goal achievement progress.

class pycram.validation.goal_validator.PositionGoalValidator(current_position_getter: OptionalArgCallable = None, acceptable_error: typing_extensions.Optional[float] = 0.001, acceptable_percentage_of_goal_achieved: typing_extensions.Optional[float] = 0.8, is_iterable: typing_extensions.Optional[bool] = False)#

Bases: GoalValidator

A class to validate the position goal by tracking the goal achievement progress.

class pycram.validation.goal_validator.MultiPositionGoalValidator(current_positions_getter: OptionalArgCallable = None, acceptable_error: typing_extensions.Optional[float] = 0.001, acceptable_percentage_of_goal_achieved: typing_extensions.Optional[float] = 0.8)#

Bases: PositionGoalValidator

A class to validate the multi-position goal by tracking the goal achievement progress.

class pycram.validation.goal_validator.OrientationGoalValidator(current_orientation_getter: OptionalArgCallable = None, acceptable_error: typing_extensions.Optional[float] = np.pi / 180, acceptable_percentage_of_goal_achieved: typing_extensions.Optional[float] = 0.8, is_iterable: typing_extensions.Optional[bool] = False)#

Bases: GoalValidator

A class to validate the orientation goal by tracking the goal achievement progress.

class pycram.validation.goal_validator.MultiOrientationGoalValidator(current_orientations_getter: OptionalArgCallable = None, acceptable_error: typing_extensions.Optional[float] = np.pi / 180, acceptable_percentage_of_goal_achieved: typing_extensions.Optional[float] = 0.8)#

Bases: OrientationGoalValidator

A class to validate the multi-orientation goal by tracking the goal achievement progress.

class pycram.validation.goal_validator.JointPositionGoalValidator(current_position_getter: OptionalArgCallable = None, acceptable_error: typing_extensions.Optional[float] = None, acceptable_revolute_joint_position_error: float = np.pi / 180, acceptable_prismatic_joint_position_error: float = 0.001, acceptable_percentage_of_goal_achieved: float = 0.8, is_iterable: bool = False)#

Bases: GoalValidator

A class to validate the joint position goal by tracking the goal achievement progress.

acceptable_orientation_error#
acceptable_position_error = 0.001#
register_goal(goal_value: typing_extensions.Any, joint_type: pycram.datastructures.enums.JointType, current_value_getter_input: typing_extensions.Optional[typing_extensions.Any] = None, initial_value: typing_extensions.Optional[typing_extensions.Any] = None, acceptable_error: typing_extensions.Optional[float] = None)#

Register the goal value.

Parameters:
  • goal_value – The goal value.

  • joint_type – The joint type (e.g. REVOLUTE, PRISMATIC).

  • current_value_getter_input – The values that are used as input to the current value getter.

  • initial_value – The initial value.

  • acceptable_error – The acceptable error.

class pycram.validation.goal_validator.MultiJointPositionGoalValidator(current_positions_getter: OptionalArgCallable = None, acceptable_error: typing_extensions.Optional[typing_extensions.Iterable[float]] = None, acceptable_revolute_joint_position_error: float = np.pi / 180, acceptable_prismatic_joint_position_error: float = 0.001, acceptable_percentage_of_goal_achieved: float = 0.8)#

Bases: GoalValidator

A class to validate the multi-joint position goal by tracking the goal achievement progress.

acceptable_orientation_error#
acceptable_position_error = 0.001#
register_goal(goal_value: typing_extensions.Any, joint_type: typing_extensions.Iterable[pycram.datastructures.enums.JointType], current_value_getter_input: typing_extensions.Optional[typing_extensions.Any] = None, initial_value: typing_extensions.Optional[typing_extensions.Any] = None, acceptable_error: typing_extensions.Optional[typing_extensions.Iterable[float]] = None)#

Register the goal value.

Parameters:
  • goal_value – The goal value.

  • current_value_getter_input – The values that are used as input to the current value getter.

  • initial_value – The initial value.

  • acceptable_error – The acceptable error.

pycram.validation.goal_validator.validate_object_pose(pose_setter_func)#

A decorator to validate the object pose.

Parameters:

pose_setter_func – The function to set the pose of the object.

pycram.validation.goal_validator.validate_multiple_object_poses(pose_setter_func)#

A decorator to validate multiple object poses.

Parameters:

pose_setter_func – The function to set multiple poses of the objects.

pycram.validation.goal_validator.validate_joint_position(position_setter_func)#

A decorator to validate the joint position.

Parameters:

position_setter_func – The function to set the joint position.

pycram.validation.goal_validator.validate_multiple_joint_positions(position_setter_func)#

A decorator to validate the joint positions, this function does not validate the virtual joints, as in multiverse the virtual joints take command velocities and not positions, so after their goals are set, they are zeroed thus can’t be validated. (They are actually validated by the robot pose in case of virtual mobile base joints)

Parameters:

position_setter_func – The function to set the joint positions.

pycram.validation.goal_validator.create_multiple_joint_goal_validator(robot: pycram.world_concepts.world_object.Object, joint_positions: typing_extensions.Union[typing_extensions.Dict[Joint, float], typing_extensions.Dict[str, float]]) MultiJointPositionGoalValidator#

Validate the multiple joint goals, and wait until the goal is achieved.

Parameters:
  • robot – The robot object.

  • joint_positions – The joint positions to validate.