Exemplo n.º 1
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__)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
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())
Exemplo n.º 7
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)
Exemplo n.º 8
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)
Exemplo n.º 9
0
    def distance_ratio(self, distance_ratio):
        """Sets the distance along the edge where this pose sits (bound between 0 and 1).

        :param float distance_ratio: The distance ratio.
        :raise fetchcore.exceptions.ValidationError: Thrown if distance_ratio is not a finite number in between 0 and 1.
        """
        if not Number.is_real_number(distance_ratio):
            raise ValidationError("Distance ratio must be a number (distance_ratio is %s)" % distance_ratio)
        elif distance_ratio < 0 or distance_ratio > 1:
            raise ValidationError("Distance ratio must be between 0 and 1 (distance_ratio is %s)" % distance_ratio)
        else:
            self._set("distance_ratio", distance_ratio)
Exemplo n.º 10
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)
Exemplo n.º 11
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)
Exemplo n.º 12
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)
Exemplo n.º 13
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)
Exemplo n.º 14
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)
Exemplo n.º 15
0
    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)
Exemplo n.º 16
0
    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)
Exemplo n.º 17
0
    def resolution(self, resolution):
        """Set the resolution of the map in meters/pixel.

        :param float resolution: The map resolution.
        :raise fetchcore.exceptions.ValidationError: Thrown if resolution is not a finite non-negative number.
        """
        if Number.is_real_number(resolution):
            if not Number.is_finite_non_negative(resolution):
                raise exceptions.ValidationError(
                    "Resolution must be a finite non-negative number (resolution is %s)"
                    % resolution)
            self._set("resolution", resolution)
        else:
            raise exceptions.ValidationError(
                "Resolution must be a number (resolution is %s)" % resolution)
Exemplo n.º 18
0
    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)
Exemplo n.º 19
0
 def max_velocity(self, value):
     """
     :param value: A new maximum linear velocity for robots in this system.
     :raise ValidationError if value is:
         - Not a number
         - A negative number
     """
     if not Number.is_real_number(value) or isinstance(value, bool):
         raise ValidationError(
             "Max velocity must be a number (max velocity is %s)" % value)
     elif value < 0.3 or value > 1.5:
         raise ValidationError(
             "Max velocity must be between 0.3 and 1.5 (max velocity is %s)"
             % value)
     else:
         self._set("max_velocity", value)
Exemplo n.º 20
0
    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)
Exemplo n.º 21
0
    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)
Exemplo n.º 22
0
    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)
Exemplo n.º 23
0
    def value(self, value):
        """Sets the scaled value in the range [0, 1] associated with the area

        :param value: A number in between 0 and 1
        :raises ValidationError if value is not a number or none
        :raises ValidationError if value is not greater than or equal to zero and less than or equal to one
        """
        if Number.is_real_number(value) or value is None:
            if not Number.is_finite_non_negative(value) and value is not None:
                raise ValidationError(
                    "Value must be in between 0 and 1 (value is %s)" % value)
            if value > 1.0 and value is not None:
                raise ValidationError(
                    "Value must be in between 0 and 1 (value is %s)" % value)
            self._set("value", value)
        else:
            raise ValidationError("Value must be a number (value is %s" %
                                  value)
Exemplo n.º 24
0
    def volume(self, volume):
        """Sets the volume that sound should be played at

        :param volume: (float) The volume
        :raises ValidationError if volume is not a number
        :raises ValidationError if volume is not a non-negative finite number
        """
        if volume and not Number.is_real_number(volume):
            raise ValidationError("Volume must be a number (value is %s)" %
                                  volume)
        elif volume and not Number.is_finite_non_negative(volume):
            raise ValidationError(
                "Volume must be a finite non-negative number "
                "(value is %s)" % volume)
        elif not 0 <= volume <= 1:
            raise ValidationError(
                "Volume must be between 0 and 1 (value is %s)" % volume)
        else:
            self.set_input("volume", volume)
Exemplo n.º 25
0
    def task_id(self, task_id):
        """Set the task ID for the task that generated this log.

        :param int task_id: The ID of the task that generated this log.
        :raise: fetchcore.exceptions.ValidationError Thrown if the ID is not a finite positive number.
        """
        # Task ID is optional, we can unset it
        if task_id is None:
            self._set('task', task_id)
        elif not Number.is_real_number(task_id):
            raise ValidationError("Task ID must be a number (value is %s)." %
                                  str(task_id))
        elif not Number.is_finite_positive(task_id):
            raise ValidationError(
                "Task ID must be a finite positive number (value is %s)." %
                str(task_id))
        elif not Number.is_integer(task_id):
            raise ValidationError("Task ID must be an integer (value is %s)." %
                                  str(task_id))
        else:
            self._set('task', task_id)
Exemplo n.º 26
0
    def laser_clearing_robot_radius(self, laser_clearing_robot_radius):
        """Set the robot's estimated radius for laser_clearing.

        :param float laser_clearing_robot_radius: The robot radius for laser_clearing.
        :raise: fetchcore.exceptions.ValidationError: Thrown if laser_clearing_robot_radius is:

          - not a finite non-negative number.
        """
        if laser_clearing_robot_radius is None:
            self._set('laser_clearing_robot_radius',
                      laser_clearing_robot_radius)
        elif Number.is_real_number(laser_clearing_robot_radius):
            if not Number.is_finite_non_negative(laser_clearing_robot_radius):
                raise ValidationError(
                    "Robot radius must be a finite non-negative number (was given as %s)."
                    % laser_clearing_robot_radius)
            self._set('laser_clearing_robot_radius',
                      laser_clearing_robot_radius)
        else:
            raise ValidationError(
                "Laser clearing robot radius must be a real number (was given as %s)."
                % laser_clearing_robot_radius)
Exemplo n.º 27
0
    def laser_clearing_inflation_factor(self, laser_clearing_inflation_factor):
        """Set the factor by which to inflate the robot's radius for laser_clearing.

        :param float laser_clearing_inflation_factor: The inflation factor for laser_clearing.
        :raise: fetchcore.exceptions.ValidationError: Thrown if laser_clearing_inflation_factor is:

          - not a finite non-negative number.
        """
        if laser_clearing_inflation_factor is None:
            self._set('laser_clearing_inflation_factor',
                      laser_clearing_inflation_factor)
        elif Number.is_real_number(laser_clearing_inflation_factor):
            if not Number.is_finite_non_negative(
                    laser_clearing_inflation_factor):
                raise ValidationError(
                    "Laser clearing inflation factor must be a finite positive number (was given as %s)."
                    % laser_clearing_inflation_factor)
            self._set('laser_clearing_inflation_factor',
                      laser_clearing_inflation_factor)
        else:
            raise ValidationError(
                "Laser clearing inflation factor must be a real number (was given as %s)."
                % laser_clearing_inflation_factor)