예제 #1
0
def get_work_order_msg(json_file):
    work_order = get_sorted_work_order(json_file=json_file)
    msg = dict(left=WorkOrderArray(), right=WorkOrderArray())
    abandon_target_objects = [
        'genuine_joe_plastic_stir_sticks',
        'cheezit_big_original',
        'rolodex_jumbo_pencil_cup',
        'champion_copper_plus_spark_plug',
        'oreo_mega_stuf',
    ]
    abandon_bin_objects = [
        'rolodex_jumbo_pencil_cup',
        'oreo_mega_stuf'
    ]
    bin_contents = dict(get_bin_contents(json_file=json_file))
    for bin_, target_object in work_order:
        if target_object in abandon_target_objects:
            continue
        bin_contents_bool = False
        for bin_object in bin_contents[bin_]:
            if bin_object in abandon_bin_objects:
                bin_contents_bool = True
        if bin_contents_bool:
            continue
        if bin_ in 'abdegj':
            msg['left'].array.append(WorkOrder(bin=bin_, object=target_object))
        elif bin_ in 'cfhikl':
            msg['right'].array.append(WorkOrder(bin=bin_, object=target_object))
    return msg
예제 #2
0
파일: work_order.py 프로젝트: caomw/jsk_apc
def get_work_order_msg(json_file):
    work_order = get_sorted_work_order(json_file=json_file)
    msg = dict(left=WorkOrderArray(), right=WorkOrderArray())
    abandon_target_objects = [
        'genuine_joe_plastic_stir_sticks',
        'cheezit_big_original',
        'rolodex_jumbo_pencil_cup',
        'champion_copper_plus_spark_plug',
        'oreo_mega_stuf',
    ]
    abandon_bin_objects = ['rolodex_jumbo_pencil_cup', 'oreo_mega_stuf']
    bin_contents = dict(get_bin_contents(json_file=json_file))
    for bin_, target_object in work_order:
        if target_object in abandon_target_objects:
            continue
        bin_contents_bool = False
        for bin_object in bin_contents[bin_]:
            if bin_object in abandon_bin_objects:
                bin_contents_bool = True
        if bin_contents_bool:
            continue
        if bin_ in 'abdegj':
            msg['left'].array.append(WorkOrder(bin=bin_, object=target_object))
        elif bin_ in 'cfhikl':
            msg['right'].array.append(WorkOrder(bin=bin_,
                                                object=target_object))
    return msg
예제 #3
0
def get_sorted_work_order(json_file):
    """Sort work order to maximize the score"""
    bin_contents = get_bin_contents(json_file=json_file)
    bins, objects = zip(*bin_contents)
    bin_n_contents = dict(zip(bins, map(len, objects)))
    sorted_work_order = []
    work_order = dict(get_work_order(json_file=json_file))
    for bin_, _ in sorted(bin_n_contents.items(), key=lambda x:x[1]):
        sorted_work_order.append((bin_, work_order[bin_]))
    return sorted_work_order
예제 #4
0
파일: work_order.py 프로젝트: 130s/jsk_apc
def get_sorted_work_order(json_file):
    """Sort work order to maximize the score"""
    bin_contents = get_bin_contents(json_file=json_file)
    bins, objects = zip(*bin_contents)
    bin_n_contents = dict(zip(bins, map(len, objects)))
    sorted_work_order = []
    work_order = dict(get_work_order(json_file=json_file))
    for bin_, _ in sorted(bin_n_contents.items(), key=lambda x:x[1]):
        sorted_work_order.append((bin_, work_order[bin_]))
    return sorted_work_order
예제 #5
0
 def test_bin_contents(self,  json_file=None):
     from bin_contents import get_bin_contents
     if json_file is None:
         json_file = os.path.join(pkg_path, 'data/apc-a.json')
     bin_contents = list(get_bin_contents(json_file))
     object_list = jsk_apc2015_common.data.object_list()
     for bin_, objects in bin_contents:
         self.assertIn(bin_, 'abcdefghijkl')
         for object_ in objects:
             self.assertIn(object_, object_list)
     self.assertEqual(len(bin_contents), len('abcdefghijkl'))
예제 #6
0
 def test_bin_contents(self, json_file=None):
     from bin_contents import get_bin_contents
     if json_file is None:
         json_file = os.path.join(pkg_path, 'data/apc-a.json')
     bin_contents = list(get_bin_contents(json_file))
     object_list = jsk_apc2015_common.data.object_list()
     for bin_, objects in bin_contents:
         self.assertIn(bin_, 'abcdefghijkl')
         for object_ in objects:
             self.assertIn(object_, object_list)
     self.assertEqual(len(bin_contents), len('abcdefghijkl'))
예제 #7
0
def main():
    arg_fmt = argparse.RawTextHelpFormatter
    parser = argparse.ArgumentParser(formatter_class=arg_fmt,
                                     description=main.__doc__)
    required = parser.add_argument_group('required arguments')
    required.add_argument(
        '-f', '--file', required=True,
        help='select json file.'
    )
    args = parser.parse_args(sys.argv[1:])

    cmd = "montage"
    for bin_contents in sorted(get_bin_contents(args.file)):
        bin_label = bin_contents[0]
        bin_content = bin_contents[1]
        for obj_name in bin_content:
            cmd += ' ../data/raw_img/' + obj_name + '.jpg'
        for _ in range(3 - len(bin_content)):
            cmd += ' ../data/paste_mask.png'
    cmd += ' -tile 3x12 output.png'
    os.system(cmd)
예제 #8
0
    'kong_sitting_frog_dog_toy': 1,
    'kong_air_dog_squeakair_tennis_ball': 1,
    'dr_browns_bottle_brush': 2,
    'kong_duck_dog_toy': 1,
    'laugh_out_loud_joke_book': 3,
}
SCORING = {
    'MOVE_FROM_MULTI_ITEM_BIN': 20,
    'MOVE_FROM_DOUBLE_ITEM_BIN': 15,
    'MOVE_FROM_SINGLE_ITEM_BIN': 10,
    'MOVE_NON_TARGET_ITEM': -12,
    'DAMAGE_ITEM': -5,
    'DROP_TARGET_ITEM': -3,
}

bin_contents = dict(get_bin_contents(args.json))
work_order = dict(get_work_order(args.json))

cprint('#------------------#', 'blue')
cprint('# SCORE CALCULATOR #', 'blue')
cprint('#------------------#', 'blue')


def display_score(scores):
    cprint('---------------------', 'blue')
    for type_, score in scores.items():
        if score == 0:
            continue
        score = '+{0}'.format(score) if score > 0 else str(score)
        print('{0}: {1}'.format(type_, score))
    bin_score = sum(scores.values())
        'kong_sitting_frog_dog_toy': 1,
        'kong_air_dog_squeakair_tennis_ball': 1,
        'dr_browns_bottle_brush': 2,
        'kong_duck_dog_toy': 1,
        'laugh_out_loud_joke_book': 3,
        }
SCORING = {
        'MOVE_FROM_MULTI_ITEM_BIN': 20,
        'MOVE_FROM_DOUBLE_ITEM_BIN': 15,
        'MOVE_FROM_SINGLE_ITEM_BIN': 10,
        'MOVE_NON_TARGET_ITEM': -12,
        'DAMAGE_ITEM': -5,
        'DROP_TARGET_ITEM': -3,
        }

bin_contents = dict(get_bin_contents(args.json))
work_order = dict(get_work_order(args.json))

cprint('#------------------#', 'blue')
cprint('# SCORE CALCULATOR #', 'blue')
cprint('#------------------#', 'blue')

def display_score(scores):
    cprint('---------------------', 'blue')
    for type_, score in scores.items():
        if score == 0:
            continue
        score = '+{0}'.format(score) if score > 0 else str(score)
        print('{0}: {1}'.format(type_, score))
    bin_score = sum(scores.values())
    cprint('SCORE of bin_{0}: {1}'.format(bin_.upper(), bin_score), 'magenta')
예제 #10
0
 def _init_bin_contents(self, json_file):
     bin_contents = get_bin_contents(json_file)
     self.bin_contents = dict(bin_contents)
예제 #11
0
 def _init_bin_contents(self, json_file):
     bin_contents = get_bin_contents(json_file)
     self.bin_contents = dict(bin_contents)