def clearing_polygon(self, clearing_polygon): """Set the clearing polygon for this configuration. :param clearing_polygon: The polygon for clearing. :type: A list of three or more dicts, each containing number values for keys 'x' and 'y' """ if clearing_polygon is None: self._set('clearing_polygon', clearing_polygon) elif isinstance(clearing_polygon, (list, tuple)): if len(clearing_polygon) < 3: raise ValidationError( "Length of clearing polygon entry must be greater than or equal to 3 (given " "length was %s)." % len(clearing_polygon)) for item in clearing_polygon: if not isinstance(item, dict): raise ValidationError( "Provided point '%s' for clearing polygon entry is a %s instead of a dict." % (item, type(item).__name__)) if len(item) == 2 and all(key in item for key in ('x', 'y')) and \ all(Number.is_finite(num) and Number.is_real_number(num) for num in item.values()): continue else: raise ValidationError( "Provided point %s for clearing polygon is not a length 2 dictionary " "containing real, finite numbers for 'x' and 'y'." % item) self._set('clearing_polygon', clearing_polygon) else: raise ValidationError( "Clearing polygon must be a list, tuple, or None, not a %s." % type(clearing_polygon).__name__)
def travel_distance(self, value): if not Number.is_real_number(value): raise ValidationError("Travel distance must be a number (value is %s)" % value) elif not Number.is_finite(value): raise ValidationError("Travel distance must be a finite number (value is %s)" % value) else: self.set_input("travel_distance", value)
def _validate_point(self, point): """Validate a point entry. :returns: True if the point is a dictionary with exact keys 'x' and 'y' that are each real, finite numbers. """ return isinstance(point, dict) and {'x', 'y'} == set( point.keys()) and all( Number.is_finite(num) and Number.is_real_number(num) for num in point.values())
def theta(self, theta): """Set the angle of the survey node (in radians) within the associated map. :param float theta: The survey node angle. :raise fetchcore.exceptions.ValidationError: Thrown if theta is not a finite number in between 0 and pi. """ if not Number.is_finite(theta): raise ValidationError("Theta must be a finite number (theta is %s)" % theta) else: self._set("theta", Number.bind_radians_to_pi(theta))
def goal_yaw_tolerance(self, value): if not Number.is_real_number(value): raise ValidationError( "Goal yaw tolerance must be a number (value is %s)" % value) elif not Number.is_finite(value): raise ValidationError( "Goal yaw tolerance must be a finite number (value is %s)" % value) else: self.set_input("goal_yaw_tolerance", value)
def theta(self, theta): """Set the angle of the lower-left corner of the map (in radians). :param float theta: The map angle. :raise fetchcore.exceptions.ValidationError: Thrown if theta is not a finite number in between 0 and pi. """ if not Number.is_finite(theta): raise exceptions.ValidationError( "Theta must be a finite number (theta is %s)" % theta) else: self._set("theta", Number.bind_radians_to_pi(theta))
def hint_position_tolerance(self, value): if not Number.is_real_number(value): raise ValidationError( "Hint position tolerance must be a number (value is %s)" % value) elif not Number.is_finite(value): raise ValidationError( "Hint position tolerance must be a finite number (value is %s)" % value) else: self.set_input("hint_position_tolerance", value)
def is_pose(value): """ Check if a given list represents a pose [x, y, theta] :param value: A list of numbers :return: True if the list has 3 finite numbers, False otherwise. """ try: return len(value) == 3 and all( [Number.is_finite(p) for p in value]) except TypeError: return False
def y(self, value): """Sets the Y position of the survey node within the associated map. :param value: A float. :raises ValidationError if value is not a number. :raises ValidationError if value is not a finite number. """ if Number.is_real_number(value): if not Number.is_finite(value): raise ValidationError("Y must be a finite number (value is %s)" % value) self._set("y", value) else: raise ValidationError("Y must be a number (value is %s)" % value)
def x(self, value): """Sets the X position of the point within the associated map :param value: A float :raises ValidationError if value is not a number :raises ValidationError if value is not a finite number """ if Number.is_real_number(value): if not Number.is_finite(value): raise ValidationError("X position must be a finite number (value is %s)" % value) self._set("x", value) else: raise ValidationError("X position must be a number (value is %s)" % value)
def dock_pose_x(self, x): """Sets the x-coordinate of dock position :param x: (float) X value :raises ValidationError if x is not a number :raises ValidationError if x is not a finite number """ if not Number.is_real_number(x): raise ValidationError( "X coordinate must be a number (value is %s)" % x) elif not Number.is_finite(x): raise ValidationError("X coordinate must be a finite number " "(value is %s)" % x) else: self.set_input("dock_pose_x", x)
def dock_pose_y(self, y): """Sets the y-coordinate of dock position :param y: (float) Y value :raises ValidationError if y is not a number :raises ValidationError if y is not a finite number """ if not Number.is_real_number(y): raise ValidationError( "Y coordinate must be a number (value is %s)" % y) elif not Number.is_finite(y): raise ValidationError("Y coordinate must be a finite number " "(value is %s)" % y) else: self.set_input("dock_pose_y", y)
def x(self, x): """Sets the X position of the lower-left corner of the map (in meters). :param float x: The x position. :raise fetchcore.exceptions.ValidationError: Thrown if x is not a finite number. """ if Number.is_real_number(x): if not Number.is_finite(x): raise exceptions.ValidationError( "X position must be a finite non-negative number (x is %s)" % x) self._set("x", x) else: raise exceptions.ValidationError( "X position must be a number (x is %s)" % x)
def y(self, y): """Sets the Y position of the lower-left corner of the map (in meters). :param float y: The y position. :raise fetchcore.exceptions.ValidationError: Thrown if y is not a finite number. """ if Number.is_real_number(y): if not Number.is_finite(y): raise exceptions.ValidationError( "Y position must be a finite non-negative number (y is %s)" % y) self._set("y", y) else: raise exceptions.ValidationError( "Y position must be a number (y is %s)" % y)
def dock_pose_qy(self, qy): """Sets the y component of the dock quaternion :param qy: (float) Y component :raises ValidationError if qy is not a number :raises ValidationError if qy is not a finite number """ if not Number.is_real_number(qy): raise ValidationError( "Quarternion y component must be a number (value is %s)" % qy) elif not Number.is_finite(qy): raise ValidationError( "Quaternion y component must be a finite number " "(value is %s)" % qy) else: self.set_input("dock_pose_qy", qy)
def dock_pose_qw(self, qw): """Sets the w component of the dock quaternion :param qw: (float) W component :raises ValidationError if qw is not a number :raises ValidationError if qw is not a finite number """ if not Number.is_real_number(qw): raise ValidationError( "Quarternion w component must be a number (value is %s)" % qw) elif not Number.is_finite(qw): raise ValidationError( "Quaternion w component must be a finite number " "(value is %s)" % qw) else: self.set_input("dock_pose_qw", qw)
def dock_pose_qz(self, qz): """Sets the z component of the dock quaternion :param qz: (float) Z component :raises ValidationError if qz is not a number :raises ValidationError if qz is not a finite number """ if not Number.is_real_number(qz): raise ValidationError( "Quarternion z component must be a number (value is %s)" % qz) elif not Number.is_finite(qz): raise ValidationError( "Quaternion z component must be a finite number " "(value is %s)" % qz) else: self.set_input("dock_pose_qz", qz)
def dock_pose_qx(self, qx): """Sets the x component of the dock quaternion :param qx: (float) X component :raises ValidationError if qx is not a number :raises ValidationError if qx is not a finite number """ if not Number.is_real_number(qx): raise ValidationError( "Quarternion x component must be a number (value is %s)" % qx) elif not Number.is_finite(qx): raise ValidationError( "Quaternion x component must be a finite number " "(value is %s)" % qx) else: self.set_input("dock_pose_qx", qx)