Пример #1
0
    def stop_arm(self):
        arm = ArmStages(self.sg)
        if self.active_state == 'stopped' or \
                self.active_state == 'initialized':
            return

        arm.stage_stop()
        self.active_state = 'stopped'
        log.info("[stop_arm] active_state:{0}".format(self.active_state))
Пример #2
0
 def home(self):
     log.debug("[act.home] [begin]")
     arm = ArmStages(self.sg)
     mqttc.publish(self.stage_topic, _stage_message("home", "begin"), 0)
     stage_result = arm.stage_home()
     mqttc.publish(self.stage_topic,
                   _stage_message("home", "end", stage_result), 0)
     log.debug("[act.home] [end]")
     return stage_result
Пример #3
0
 def sort(self):
     log.debug("[act.sort] [begin]")
     arm = ArmStages(self.sg)
     mqttc.publish(self.stage_topic, _stage_message("sort", "begin"), 0)
     stage_result = arm.stage_sort()
     mqttc.publish(self.stage_topic,
                   _stage_message("sort", "end", stage_result), 0)
     log.debug("[act.sort] [end]")
     return stage_result
Пример #4
0
    def stop_arm(self):
        arm = ArmStages(self.sg)
        if self.active_state == 'stopped' or \
                self.active_state == 'initialized':
            return

        arm.stage_stop()
        self.active_state = 'stopped'
        log.info("[stop_arm] active_state:{0}".format(
            self.active_state))
Пример #5
0
 def sort(self):
     log.debug("[act.sort] [begin]")
     arm = ArmStages(self.sg)
     self.mqtt_client.publish(
         self.stage_topic, _stage_message("sort", "begin"), 0
     )
     stage_result = arm.stage_sort()
     self.mqtt_client.publish(
         self.stage_topic, _stage_message("sort", "end", stage_result), 0
     )
     log.debug("[act.sort] [end]")
     return stage_result
Пример #6
0
 def pick(self):
     log.debug("[act.pick] [begin]")
     arm = ArmStages(self.sg)
     mqttc.publish(self.stage_topic, _stage_message("pick", "begin"), 0)
     pick_box = self.found_box
     self.found_box = NO_BOX_FOUND
     log.info("[act.pick] pick_box:{0}".format(pick_box))
     log.info("[act.pick] self.found_box:{0}".format(self.found_box))
     stage_result = arm.stage_pick(previous_results=pick_box,
                                   cartesian=False)
     mqttc.publish(self.stage_topic,
                   _stage_message("pick", "end", stage_result), 0)
     log.debug("[act.pick] [end]")
     return stage_result
Пример #7
0
    def find(self):
        log.debug("[act.find] [begin]")
        arm = ArmStages(self.sg)
        loop = True
        self.found_box = NO_BOX_FOUND
        stage_result = NO_BOX_FOUND
        self.mqtt_client.publish(
            self.stage_topic, _stage_message("find", "begin"), 0
        )
        while self.cmd_event.is_set() and loop is True:
            stage_result = arm.stage_find()
            if stage_result['x'] and stage_result['y']:  # X & Y start as none
                log.info("[act.find] found box:{0}".format(stage_result))
                self.found_box = stage_result
                log.info("[act.find] self.found_box:{0}".format(
                    self.found_box))
                loop = False
            else:
                log.info("[act.find] self.found_box:{0}".format(
                    self.found_box
                ))
                log.info("[act.find] no box:{0}".format(stage_result))
                time.sleep(1)

        # TODO get image upload working with discovery based interaction
        # # upload the image file just before stage complete
        # if 'filename' in stage_result:
        #     filename = stage_result['filename']
        #
        #     url = 'http://' + ggd_config.master_core_ip + ":"
        #     url = url + str(ggd_config.master_core_port) + "/upload"
        #     files = {'file': open(filename, 'rb')}
        #     try:
        #         log.info('[act.find] POST to URL:{0} file:{1}'.format(
        #             url, filename))
        #         r = requests.post(url, files=files)
        #         log.info("[act.find] POST image file response:{0}".format(
        #             r.status_code))
        #     except ConnectionError as ce:
        #         log.error("[act.find] Upload Image connection error:{0}".format(
        #             ce
        #         ))

        self.mqtt_client.publish(
            self.stage_topic, _stage_message("find", "end", stage_result), 0
        )

        log.info("[act.find] outside self.found_box:{0}".format(self.found_box))
        log.debug("[act.find] [end]")
        return stage_result
Пример #8
0
 def pick(self):
     log.debug("[act.pick] [begin]")
     arm = ArmStages(self.sg)
     self.mqtt_client.publish(
         self.stage_topic, _stage_message("pick", "begin"), 0
     )
     pick_box = self.found_box
     self.found_box = NO_BOX_FOUND
     log.info("[act.pick] pick_box:{0}".format(pick_box))
     log.info("[act.pick] self.found_box:{0}".format(self.found_box))
     stage_result = arm.stage_pick(previous_results=pick_box,
                                   cartesian=False)
     self.mqtt_client.publish(
         self.stage_topic, _stage_message("pick", "end", stage_result), 0
     )
     log.debug("[act.pick] [end]")
     return stage_result