Example #1
0
    def bin_info_publlish(self, event):
        json = rospy.get_param('~json', None)

        # update bin_info_arr only when rosparam: json is changd
        if self.json_file != json:
            if not os.path.isfile(json) or json[-4:] != 'json':
                rospy.logwarn('wrong json file name')
                return
            self.json_file = json

            # get bbox from rosparam
            self.from_shelf_param('upper')
            self.from_shelf_param('lower')

            # get contents of bin from json
            self.bin_contents_dict = jsk_apc2016_common.get_bin_contents(
                self.json_file)
            self.targets_dict = jsk_apc2016_common.get_work_order(
                self.json_file)

            # create bin_msg
            self.create_bin_info_arr()

        self.bin_info_arr.header.stamp = rospy.Time.now()
        self.pub_bin_info_arr.publish(self.bin_info_arr)
Example #2
0
 def __init__(self):
     rp = rospkg.RosPack()
     input_path = rospy.get_param('~json', None)
     if input_path is None:
         jsk_logwarn('must set json file path to param ~json')
         return
     with open(input_path, 'r') as f:
         self.output_data = json.load(f)
     self.tote_contents = self.output_data['tote_contents']
     self.bin_contents = self.output_data['bin_contents']
     self.work_order = jsk_apc2016_common.get_work_order(input_path)
     self.output_path = osp.join(
             rp.get_path('jsk_2016_01_baxter_apc'),
             'output',
             'output_' + osp.basename(input_path))
     self.arm_state = {}
     self.arm_target_bin = {}
     self.finished_bin_list = []
     with open(self.output_path, 'w') as f:
         json.dump(self.output_data, f, sort_keys=True, indent=4)
Example #3
0
    def __init__(self):
        self.bbox_dict = {}
        self.bin_contents_dict = {}
        self.targets_dict = {}
        self.cam_direction_dict = {}
        self.json_file = None

        pub_bin_info_arr = rospy.Publisher('~bin_array', BinInfoArray, queue_size=1)
        pub_bbox_arr = rospy.Publisher('~bbox_array', BoundingBoxArray, queue_size=1)
        rate = rospy.Rate(rospy.get_param('rate', 1))
        while not rospy.is_shutdown():
            json = rospy.get_param('~json', None)

            # update bin_info_arr only when rosparam: json is changd
            if self.json_file != json:
                if not os.path.isfile(json) or json[-4:] != 'json':
                    rospy.logwarn('wrong json file name')
                    rate.sleep()
                    continue
                self.json_file = json

                # get bbox from rosparam
                self.from_shelf_param('upper')
                self.from_shelf_param('lower')

                # create bounding box array
                self.bbox_array = self.get_bounding_box_array(self.bbox_dict)

                # get contents of bin from json
                self.bin_contents_dict = jsk_apc2016_common.get_bin_contents(self.json_file)
                self.targets_dict = jsk_apc2016_common.get_work_order(self.json_file)

                # create bin_msg
                self.create_bin_info_arr()

            self.bbox_array.header.stamp = rospy.Time.now()
            self.bin_info_arr.header.stamp = rospy.Time.now()
            pub_bbox_arr.publish(self.bbox_array)
            pub_bin_info_arr.publish(self.bin_info_arr)
            rate.sleep()