예제 #1
0
 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)
예제 #2
0
    def __init__(self, id=None, version=None, parent=None, map=None, areas=None, name=None, created=None,
                 modified=None, **kwargs):
        """
        :param integer id: The ID of the revision (assigned automatically upon creation).
        :param integer version: The version of this revision. If NULL, it is considered to be a draft,
            unpublished version.
        :param parent: The parent revision that this revision was based off of.
        :param integer map: The map this revision is associated with.
        :param string name: The display name for this revision.
        :param created: The date and time of this revision's creation (assigned automatically).
        :param modified: The date and time this revision was last modified (updated automatically).
        :type parent: int, Revision
        :type created: str, ~datetime.datetime
        :type modified: str, ~datetime.datetime
        """
        super(Revision, self).__init__(id=id, created=created, modified=modified, **kwargs)

        self.version = version
        self.parent = parent
        self.map = map
        self.name = name

        if Number.is_integer(map):
            if not Number.is_finite_positive(map):
                raise ValidationError("Map ID must be finite positive (item is %s)." % map)
            self.endpoint = 'maps/%(map_id)s/revisions' % {'map_id': str(map)}
        else:
            raise ValidationError("Map ID must be an integer (%s is %s)." % (map, type(map).__name__))

        if areas:
            self.__areas = areas
예제 #3
0
    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__)
예제 #4
0
    def planning_robot_radius(self, planning_robot_radius):
        """Set the robot's estimated radius for planning.

        :param float planning_robot_radius: The robot radius for planning.
        :raise: fetchcore.exceptions.ValidationError: Thrown if planning_robot_radius is:

          - not a finite non-negative number.
          - None while the planning footprint type is 'radius'.
        """
        if planning_robot_radius is None:
            if self.planning_footprint_type == FootprintTypes.RADIUS:
                raise ValidationError(
                    "Planning robot radius cannot be set to None if planning footprint type is %s."
                    % FootprintTypes.RADIUS)
            self._set('planning_robot_radius', planning_robot_radius)
        elif Number.is_real_number(planning_robot_radius):
            if not Number.is_finite_non_negative(planning_robot_radius):
                raise ValidationError(
                    "Planning robot radius must be a finite non-negative number (was given as %s)."
                    % planning_robot_radius)
            self._set('planning_robot_radius', planning_robot_radius)
        else:
            raise ValidationError(
                "Planning Robot radius must be a real number (was given as %s)."
                % planning_robot_radius)
예제 #5
0
    def planning_inflation_factor(self, planning_inflation_factor):
        """Set the factor by which to inflate the robot's radius for planning.

        :param float planning_inflation_factor: The inflation factor for planning.
        :raise: fetchcore.exceptions.ValidationError: Thrown if planning_inflation_factor is:

          - not a finite non-negative number.
          - None while the planning footprint type is 'radius'.
        """
        if planning_inflation_factor is None:
            if self.planning_footprint_type == FootprintTypes.RADIUS:
                raise ValidationError(
                    "Planning robot radius cannot be set to None if planning footprint type is %s."
                    % FootprintTypes.RADIUS)
            self._set('planning_inflation_factor', planning_inflation_factor)
        elif Number.is_real_number(planning_inflation_factor):
            if not Number.is_finite_non_negative(planning_inflation_factor):
                raise ValidationError(
                    "Planning inflation factor must be a finite positive number (was given as %s)."
                    % planning_inflation_factor)
            self._set('planning_inflation_factor', planning_inflation_factor)
        else:
            raise ValidationError(
                "Planning inflation factor must be a real number (was given as %s)."
                % planning_inflation_factor)
예제 #6
0
    def modifiers(self, modifier_ids):
        """Set the the users who modified this annotation.

        :param modifier_ids: A list of user IDs.
        :type modifier_ids: list of int
        :raise: ValidationError: Thrown if modifier_ids is not a list, if each item's ID
                is not an integer, or if each item's ID in the list is not a finite positive integer.
        """
        if modifier_ids is None:
            self._set('modifiers', [])
        elif not isinstance(modifier_ids, list):
            raise ValidationError("Modifier ids must be a list, not a %s." %
                                  type(modifier_ids).__name__)
        else:
            modifier_ids = list(set(modifier_ids))
            for modifier_id in modifier_ids:
                if not Number.is_integer(modifier_id):
                    raise ValidationError(
                        "Each item in modifier IDs must be an int (%s is %s)."
                        % (modifier_id, type(modifier_id).__name__))
                elif not Number.is_finite_positive(modifier_id):
                    raise ValidationError(
                        "Each item in modifier IDs must be finite positive (item is %s)."
                        % modifier_id)
            self._set('modifiers', modifier_ids)
예제 #7
0
    def task_template_ids(self, task_template_ids):
        """Set the associated task templates IDs for this schedule.

        :param task_template_ids: A list of task template IDs.
        :type task_template_ids: list of int
        :raise: ValidationError: Thrown if task_template_ids is not a list, if each item's ID
                is not an integer, or if each item's ID in the list is not a finite positive integer.
        """
        if task_template_ids is None:
            self._set('task_templates', [])
        elif not isinstance(task_template_ids, list):
            raise ValidationError(
                "Task template ids must be a list, not a %s." %
                type(task_template_ids).__name__)
        else:
            task_template_ids = list(set(task_template_ids))
            for task_template_id in task_template_ids:
                if not Number.is_integer(task_template_id):
                    raise ValidationError(
                        "Each item in task template IDs must be an int (%s is %s)."
                        % (task_template_id, type(task_template_id).__name__))
                elif not Number.is_finite_positive(task_template_id):
                    raise ValidationError(
                        "Each item in task template IDs must be finite positive (item is %s)."
                        % task_template_id)
            self._set('task_templates', task_template_ids)
예제 #8
0
 def radius(self, value):
     if Number.is_real_number(value) and (Number.is_finite_positive(value)
                                          or value == 0):
         self._set('radius', value)
     else:
         raise ValidationError(
             "Radius must be a real, finite, positive number, not '%s'" %
             value)
예제 #9
0
    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())
예제 #10
0
    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))
예제 #11
0
 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)
예제 #12
0
    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))
예제 #13
0
 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)
예제 #14
0
    def survey_path_id(self, value):
        """Sets the ID of survey path for this action to follow.

        :param value: (integer) Survey path ID
        :raises ValidationError if value is not a positive finite integer
        """
        if Number.is_integer(value):
            if not Number.is_finite_positive(value):
                raise ValidationError("Survey path ID must be a finite positive number (value is %s)" % value)
            self.set_input("survey_path_id", value)
        else:
            raise ValidationError("Survey path ID must be a number (value is %s)" % value)
예제 #15
0
    def action_id(self, id):
        """Sets the action ID that this survey state belongs to.

        :param id: (integer) The action id of the survey state.
        :raise fetchcore.exceptions.ValidationError: Thrown if id is not a positive integer.
        """
        if Number.is_integer(id):
            if not Number.is_finite_positive(id):
                raise ValidationError("Action ID must be a finite positive number (value is %s)" % id)
            self._set("action", id)
        else:
            raise ValidationError("Action ID must be a number (value is %s)" % id)
예제 #16
0
    def map(self, map):
        """Set the map that this revision belongs to.

        :param integer map: The map.
        :raise fetchcore.exceptions.ValidationError:: Thrown if map not a finite positive integer.
        """
        if Number.is_integer(map):
            if not Number.is_finite_positive(map):
                raise ValidationError("Map ID must be finite positive (item is %s)." % map)
            self._set('map', map)
        else:
            raise ValidationError("Map ID must be an integer (%s is %s)." % (map, type(map).__name__))
예제 #17
0
    def survey_state_id(self, survey_state_id):
        """Set the survey state ID that this pose belongs to.

        :param integer survey_state_id: The survey_state ID.
        :raise fetchcore.exceptions.ValidationError: Thrown if survey_state_id not a finite positive integer.
        """
        if Number.is_integer(survey_state_id):
            if not Number.is_finite_positive(survey_state_id):
                raise ValidationError("Survey state ID must be finite positive (item is %s)." % survey_state_id)
            self._set('survey_state', survey_state_id)
        else:
            raise ValidationError("Survey state ID must be an integer (%s is %s)."
                                  % (survey_state_id, type(survey_state_id).__name__))
예제 #18
0
    def survey_path_id(self, survey_path_id):
        """Set the ID for this survey path.

        :param integer survey_path: The survey path ID.
        :raise fetchcore.exceptions.ValidationError: Thrown if survey_path_id is not a finite positive integer.
        """
        if Number.is_integer(survey_path_id):
            if not Number.is_finite_positive(survey_path_id):
                raise ValidationError("Survey Path ID must be finite positive (item is %s)." % survey_path_id)
            self._set('survey_path', survey_path_id)
        else:
            raise ValidationError("Survey Path ID must be an integer (%s is %s)."
                                  % (survey_path_id, type(survey_path_id).__name__))
예제 #19
0
    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)
예제 #20
0
    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)
예제 #21
0
    def pose_id(self, pose_id):
        """Set the associated pose ID for this queue.

        :param integer pose_id: The pose ID.
        :raise fetchcore.exceptions.ValidationError: Thrown if pose_id is not a finite positive integer.
        """
        if Number.is_integer(pose_id):
            if not Number.is_finite_positive(pose_id):
                raise ValidationError("Pose ID must be finite positive (item is %s)." % pose_id)
            self._set('pose', pose_id)
        else:
            raise ValidationError("Pose ID must be an integer (%s is %s)."
                                  % (pose_id, type(pose_id).__name__))
예제 #22
0
    def intermediate_task_template_id(self, value):
        """Sets the optional ID of the task template to run at each intermediate survey pose.

        :param value: (integer) Task template ID
        :raises ValidationError if value is not a positive finite integer
        """
        if Number.is_integer(value):
            if not Number.is_finite_positive(value):
                raise ValidationError(
                    "Intermediate task template ID must be a finite positive number (value is %s)" % value)
            self.set_input("intermediate_task_template_id", value)
        else:
            raise ValidationError("Intermediate task template ID must be a number (value is %s)" % value)
예제 #23
0
    def start_id(self, start_id):
        """Set the starting node ID for this pose.

        :param integer start_id: The survey node ID.
        :raise fetchcore.exceptions.ValidationError: Thrown if start_id is not a finite positive integer.
        """
        if Number.is_integer(start_id):
            if not Number.is_finite_positive(start_id):
                raise ValidationError("Start ID must be finite positive (item is %s)." % start_id)
            self._set('start', start_id)
        else:
            raise ValidationError("Start ID must be an integer (%s is %s)."
                                  % (start_id, type(start_id).__name__))
예제 #24
0
    def max_velocity(self, velocity):
        """Sets the max velocity that robot should go during data survey

        :param velocity: (float) The max velocity
        :raises ValidationError if velocity is not a number
        :raises ValidationError if velocity is not a non-negative finite number
        """
        if velocity and not Number.is_real_number(velocity):
            raise ValidationError("Max velocity must be a number (value is %s)" % velocity)
        elif velocity and not Number.is_finite_non_negative(velocity):
            raise ValidationError("Max velocity must be a finite non-negative number "
                                  "(value is %s)" % velocity)
        else:
            self.set_input("max_velocity", velocity)
예제 #25
0
    def map_id(self, value):
        """Set the associated map ID for this robot.

        :param value: (integer) The map ID.
        :raise ~fetchcore.exceptions.ValidationError: Thrown if value is not a finite positive integer.
        """
        if value is None:
            self._set('map', value)
        elif Number.is_integer(value):
            if not Number.is_finite_positive(value):
                raise ValidationError("Map ID must be a finite positive integer (item is %s)." % value)
            self._set('map', value)
        else:
            raise ValidationError("Map ID must be an integer (%s is %s)." % (value, type(value).__name__))
예제 #26
0
 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)
예제 #27
0
 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)
예제 #28
0
    def parent_id(self, parent_id):
        """Set the parent revision id that this revision was based off of.

        :param integer parent_id: The ID of the parent revision.
        :raise fetchcore.exceptions.ValidationError:: Thrown if parent_id not a finite positive integer.
        """
        if parent_id is None:
            self._set('parent', parent_id)
        elif Number.is_integer(parent_id):
            if not Number.is_finite_positive(parent_id):
                raise ValidationError("Parent ID must be finite positive (item is %s)." % parent_id)
            self._set('parent', parent_id)
        else:
            raise ValidationError("Parent ID must be an integer (%s is %s)." % (parent_id, type(parent_id).__name__))
예제 #29
0
    def end_id(self, end_id):
        """Set the associated end ID for this edge.

        :param integer end_id: The end ID.
        :raise fetchcore.exceptions.ValidationError: Thrown if end_id is not a finite positive integer.
        """
        if Number.is_integer(end_id):
            if not Number.is_finite_positive(end_id):
                raise ValidationError(
                    "End ID must be finite positive (item is %s)." % end_id)
            self._set('end', end_id)
        else:
            raise ValidationError("End ID must be an integer (%s is %s)." %
                                  (end_id, type(end_id).__name__))
예제 #30
0
    def survey_pose_id(self, id):
        """Sets the survey pose ID that this state represents.

        :param id: (integer) The resource id of the survey pose.
        :raise fetchcore.exceptions.ValidationError: Thrown if id is not None or a positive integer.
        """
        if id is None:
            self._set("survey_pose", id)
        elif Number.is_integer(id):
            if not Number.is_finite_positive(id):
                raise ValidationError("Survey pose ID must be a finite positive number or None (value is %s)" % id)
            self._set("survey_pose", id)
        else:
            raise ValidationError("Survey pose ID must be a number or None (value is %s)" % id)