Esempio n. 1
0
    def __init__(self, robot_id, top_speed, angular_top_speed, x_offset, y_offset, theta_offset):
        Robot.__init__(self, robot_id, top_speed, angular_top_speed, x_offset, y_offset, theta_offset)

        #define max/min coordinates for orchard space
        boundaries = locations.get_orchard_boundaries()
        self.maxX = boundaries["max_x"]
        self.maxY = boundaries["max_y"]
        self.minX = boundaries["min_x"]
        self.minY = boundaries["min_y"]
        self.has_bin = False
        self.type = type(self).__name__

        # Unique variables for picker robots
        # self.picker_dict = dict()
        self.current_bin_x = 0
        self.current_bin_y = 0

        self.fruit_count = 0

        self.has_finished = False

        empty_response_pub = rospy.Publisher('empty_response_topic', empty_response, queue_size=10)

        def callback(data):
            """Execute method in response to "bin_status" message."""
            if data.is_empty:
                # Data used to calculate if it's the closest to the bin
                rospy.loginfo("Bin call: " + data.bin_id + " %.1f       %.1f" % (data.x, data.y))
                self.current_bin_x = data.x
                self.current_bin_y = data.y
            
                # rospy.loginfo(len(self.picker_dict))
                if self.is_closest() and not self.has_bin:  # and not self.slave and not data.is_carried:
                    self.has_finished = False
                    current_bin = robot_storage.getRobotWithId(data.bin_id)
                    if current_bin.designated_picker == None:
                        self.has_bin = True
                        self.add_action(NavigateAction(self.current_bin_x, self.current_bin_y))
                        rospy.loginfo("P Robot: " + self.robot_id + "    " + "Bin closest: " + data.bin_id)
                        msg = empty_response()
                        msg.robot_id = self.robot_id
                        msg.bin_id = data.bin_id
                        rospy.loginfo(self.robot_id + msg.robot_id + msg.bin_id + data.bin_id)
                        empty_response_pub.publish(msg)
                        rospy.loginfo("??????????????????////???????????????????")

        def initiate_picking(data):
            if data.robot_id == self.robot_id:
                pickerx = robot_storage.getRobotWithId(data.robot_id)
                self.x_start = self.position['x']
                self.y_start = self.position['y']
                self.add_action(NavigatePickAction(pickerx.position["x"], self.maxY + 5))

        rospy.Subscriber("bin_status_topic", bin_status, callback)

        # rospy.Subscriber("statuses", robot_status, picker_locations)

        rospy.Subscriber("latched_to_picker", empty_response, initiate_picking)
Esempio n. 2
0
 def setUp(self):
     rospy.init_node('test_person')
     self.person = Person('robot_0', 2, 0.5, 0, 0, 0)
     self.boundaries = locations.get_orchard_boundaries()
Esempio n. 3
0
 def setUp(self):
     rospy.init_node('test_person')
     self.person = Person('robot_0', 2, 0.5, 0, 0, 0)
     self.boundaries = locations.get_orchard_boundaries()
Esempio n. 4
0
    def __init__(self, robot_id, top_speed, angular_top_speed, x_offset,
                 y_offset, theta_offset):
        Robot.__init__(self, robot_id, top_speed, angular_top_speed, x_offset,
                       y_offset, theta_offset)

        #define max/min coordinates for orchard space
        boundaries = locations.get_orchard_boundaries()
        self.maxX = boundaries["max_x"]
        self.maxY = boundaries["max_y"]
        self.minX = boundaries["min_x"]
        self.minY = boundaries["min_y"]
        self.has_bin = False
        self.type = type(self).__name__

        # Unique variables for picker robots
        # self.picker_dict = dict()
        self.current_bin_x = 0
        self.current_bin_y = 0

        self.fruit_count = 0

        self.has_finished = False

        empty_response_pub = rospy.Publisher('empty_response_topic',
                                             empty_response,
                                             queue_size=10)

        def callback(data):
            """Execute method in response to "bin_status" message."""
            if data.is_empty:
                # Data used to calculate if it's the closest to the bin
                rospy.loginfo("Bin call: " + data.bin_id + " %.1f       %.1f" %
                              (data.x, data.y))
                self.current_bin_x = data.x
                self.current_bin_y = data.y

                # rospy.loginfo(len(self.picker_dict))
                if self.is_closest(
                ) and not self.has_bin:  # and not self.slave and not data.is_carried:
                    self.has_finished = False
                    current_bin = robot_storage.getRobotWithId(data.bin_id)
                    if current_bin.designated_picker == None:
                        self.has_bin = True
                        self.add_action(
                            NavigateAction(self.current_bin_x,
                                           self.current_bin_y))
                        rospy.loginfo("P Robot: " + self.robot_id + "    " +
                                      "Bin closest: " + data.bin_id)
                        msg = empty_response()
                        msg.robot_id = self.robot_id
                        msg.bin_id = data.bin_id
                        rospy.loginfo(self.robot_id + msg.robot_id +
                                      msg.bin_id + data.bin_id)
                        empty_response_pub.publish(msg)
                        rospy.loginfo(
                            "??????????????????////???????????????????")

        def initiate_picking(data):
            if data.robot_id == self.robot_id:
                pickerx = robot_storage.getRobotWithId(data.robot_id)
                self.x_start = self.position['x']
                self.y_start = self.position['y']
                self.add_action(
                    NavigatePickAction(pickerx.position["x"], self.maxY + 5))

        rospy.Subscriber("bin_status_topic", bin_status, callback)

        # rospy.Subscriber("statuses", robot_status, picker_locations)

        rospy.Subscriber("latched_to_picker", empty_response, initiate_picking)