Exemple #1
0
OY_node = [(0.8, 0.72, 3.0), (0.89, -0.24, 2.6)]
OY_label = {
    OY_node[0]: set(['oyr2']),
    OY_node[1]: set([
        'oyr1',
    ]),  #oyball
}
OY_init_pose = OY_node[0]
OY_symbols = set(['oyr0', 'oyr1'])
OY_motion = MotionFts(OY_label, OY_symbols, 'OY-workspace')
OY_motion.set_initial(OY_init_pose)
#B_edge=[(B_node[0],B_node[1]),(B_node[1],B_node[2]),(B_node[1],B_node[3]),(B_node[2],B_node[3]),(B_node[4],B_node[3]),(B_node[2],B_node[4])]
OY_edge = [
    (OY_node[0], OY_node[1]),
]
OY_motion.add_un_edges(OY_edge, unit_cost=10.0)
########### OY action ##########
OY_action_label = {
    'oyobsgrasp': (100, 'oyball', set(['oyobsgrasp'])),
}
OY_action = ActionModel(OY_action_label)
########### OY task ############
#OY_task = '(<> grasp) && ([]<> r1) && ([]<> r2)'
OY_task = '(<> (oyr1 && <> oyobsgrasp)) && ([]<> oyr1) && ([]<> oyr2)'
########### OY initialize ############
init['OY'] = (OY_motion, OY_action, OY_task)

#=======================================================
# Model and task for Pointing Youbot (PY)
#  pyr2         |
#           pyr3|
Exemple #2
0
B_motion = MotionFts(B_node_dict, B_symbols, 'office')
B_motion.set_initial(B_init_pose)
B_edge_list = [ # 1st column
			 ((WIDTH*RATE,HEIGHT*RATE), (WIDTH*RATE,HEIGHT*3*RATE)),
			 ((WIDTH*RATE,HEIGHT*3*RATE), (WIDTH*RATE,HEIGHT*5*RATE)),
			 # 2nd row
			 ((WIDTH*RATE,HEIGHT*3*RATE), (WIDTH*3*RATE,HEIGHT*3*RATE)),
			 ((WIDTH*3*RATE,HEIGHT*3*RATE), (WIDTH*5*RATE,HEIGHT*3*RATE)),
			 # 2nd column
			 ((WIDTH*3*RATE,HEIGHT*RATE), (WIDTH*3*RATE,HEIGHT*3*RATE)),
			 ((WIDTH*3*RATE,HEIGHT*3*RATE), (WIDTH*3*RATE,HEIGHT*5*RATE)),
			 # 3rd column
			 ((WIDTH*5*RATE,HEIGHT*RATE), (WIDTH*5*RATE,HEIGHT*3*RATE)),
			 ((WIDTH*5*RATE,HEIGHT*3*RATE), (WIDTH*5*RATE,HEIGHT*5*RATE)),
			 ]
B_motion.add_un_edges(B_edge_list,unit_cost=0.1)
###############################
########### B action ##########
B_action_dict={
			 'grasp': (100, 'ball', set(['grasp'])),
			 'throw': (60, 'basket', set(['throw']))
			}
B_action = ActionModel(B_action_dict)
###############################
########### B task ############
B_task = '(<> (grasp && <> throw)) && (<>[] r1)'
#B_task = '<> grasp && (<>[] r2)'
#######################
init['B']=(B_motion, B_action, B_task)

#####################################################
Exemple #3
0
    def __init__(self, _file):
        self.file = _file
        stream = file(self.file, 'r')
        data_file = yaml.load(stream)
        FTS = data_file['FTS']
        _map = data_file['Map']
        stream.close()

        regions = {}
        ap = set()

        ##############################
        # motion FTS

        for i in range(0, len(FTS)):
            #ap.update({FTS.keys()[i]})
            for j in range(0, len(FTS[FTS.keys()[i]]['propos'])):
                if FTS[FTS.keys()[i]]['propos'][j] not in ap:
                    ap.update({FTS[FTS.keys()[i]]['propos'][j]})
            regions.update({
                (tuple(FTS[FTS.keys()[i]]['pose']['position']),
                 tuple(FTS[FTS.keys()[i]]['pose']['orientation'])):
                set(FTS[FTS.keys()[i]]['propos'])
            })

        init_pose = ((7.77, 7.00, 0.0), (0.0, 0.0, 0.0, 1.0))

        robot_motion = MotionFts(regions, ap, _map)
        robot_motion.set_initial(init_pose)

        for i in range(0, len(FTS)):
            for j in range(0, len(FTS[FTS.keys()[i]]['edges'])):
                robot_motion.add_un_edges(
                    [[(tuple(FTS[FTS.keys()[i]]['pose']['position']),
                       tuple(FTS[FTS.keys()[i]]['pose']['orientation'])),
                      (tuple(FTS[FTS[FTS.keys()[i]]['edges'][j]['target']]
                             ['pose']['position']),
                       tuple(FTS[FTS[FTS.keys()[i]]['edges'][j]['target']]
                             ['pose']['orientation']))]],
                    unit_cost=FTS[FTS.keys()[i]]['edges'][j]['cost'])

        ##############################
        # action FTS

        ############# no action model
        # action = dict()
        ############# with action
        # for supported actions in play_motion
        # see http://wiki.ros.org/Robots/TIAGo/Tutorials/motions/play_motion##############################

        action = {}
        robot_action = ActionModel(action)

        ##############################
        # specify tasks

        robot_hard_task = ''
        robot_soft_task = ''

        robot_task = [robot_hard_task, robot_soft_task]

        self.robot_model = [robot_motion, init_pose, robot_action, robot_task]
#OY_node=[(-0.5,0.5,0.0),(-0.5,1.0,-1.57),(0.5,1.0,-1.57),(-0.0,0.5,-2.6)]
#OY_node=[(-0.0,1.0,0.0),(-0.0,1.0,-0.0),(0.5,1.3,-1.57),(-0.00,0.5,-2.6)]
OY_label={
    OY_node[0] : set(['oyr0']),
    OY_node[1]: set(['oyr1',]),
    OY_node[2]: set(['oyr2',]),
    OY_node[3]: set(['oyr3',]),
}
OY_init_pose=OY_node[0]
OY_symbols=set(['oyr0','oyr1','oyr2','oyr3'])
OY_motion=MotionFts(OY_label,OY_symbols,'OY-workspace')
OY_motion.set_initial(OY_init_pose)
#B_edge=[(B_node[0],B_node[1]),(B_node[1],B_node[2]),(B_node[1],B_node[3]),(B_node[2],B_node[3]),(B_node[4],B_node[3]),(B_node[2],B_node[4])]
OY_edge=[(OY_node[0],OY_node[1]),(OY_node[1],OY_node[2]),(OY_node[2],OY_node[3]),
(OY_node[1],OY_node[3]),]
OY_motion.add_un_edges(OY_edge,unit_cost=10.0)
########### OY action ##########
OY_action_label={
             'oyobsgrasp': (100, 'oyball', set(['oyobsgrasp'])),
            }
OY_action = ActionModel(OY_action_label)
########### OY task ############
#OY_task = '(<> grasp) && ([]<> r1) && ([]<> r2)'
OY_task = '<>(oyr1 && <> (oyr2 && <> oyobsgrasp)) && ([]<> oyr1) && ([]<> oyr2)'
########### OY initialize ############
init['OY']=(OY_motion, OY_action, OY_task)

#=======================================================
# Model and task for Pointing Youbot (PY)
#  pyr2         |
#           pyr3|
Exemple #5
0
    ((WIDTH * RATE, HEIGHT * RATE), (WIDTH * RATE, HEIGHT * 3 * RATE)),
    ((WIDTH * RATE, HEIGHT * 3 * RATE), (WIDTH * RATE, HEIGHT * 5 * RATE)),
    # 2nd row
    ((WIDTH * RATE, HEIGHT * 3 * RATE), (WIDTH * 3 * RATE, HEIGHT * 3 * RATE)),
    ((WIDTH * 3 * RATE, HEIGHT * 3 * RATE), (WIDTH * 5 * RATE,
                                             HEIGHT * 3 * RATE)),
    # 2nd column
    ((WIDTH * 3 * RATE, HEIGHT * RATE), (WIDTH * 3 * RATE, HEIGHT * 3 * RATE)),
    ((WIDTH * 3 * RATE, HEIGHT * 3 * RATE), (WIDTH * 3 * RATE,
                                             HEIGHT * 5 * RATE)),
    # 3rd column
    ((WIDTH * 5 * RATE, HEIGHT * RATE), (WIDTH * 5 * RATE, HEIGHT * 3 * RATE)),
    ((WIDTH * 5 * RATE, HEIGHT * 3 * RATE), (WIDTH * 5 * RATE,
                                             HEIGHT * 5 * RATE)),
]
B_motion.add_un_edges(B_edge_list, unit_cost=0.1)
###############################
########### B action ##########
B_action_dict = {
    'grasp': (100, 'ball', set(['grasp'])),
    'throw': (60, 'basket', set(['throw']))
}
B_action = ActionModel(B_action_dict)
###############################
########### B task ############
B_task = '(<> (grasp && <> throw)) && (<>[] r1)'
#B_task = '<> grasp && (<>[] r2)'
#######################
init['B'] = (B_motion, B_action, B_task)

#####################################################
Exemple #6
0
    (17.0, 4.0, 1.0),
    (8.0, 7.0, 1.0),
]
regions = dict()
for k in range(len(ap)):
    regions[loc[k]] = set([
        ap[k],
    ])
init_pose = loc[0]
robot_motion = MotionFts(regions, set(ap), 'hotel')
robot_motion.set_initial(list(init_pose))
edges = [(0, 1), (0, 2), (0, 4), (0, 9), (1, 4), (1, 2), (2, 4), (3, 11),
         (5, 8), (5, 11), (5, 12), (6, 11), (7, 9), (7, 12), (8, 12), (8, 11),
         (9, 12), (11, 12)]
edge_list = [(loc[e[0]], loc[e[1]]) for e in edges]
robot_motion.add_un_edges(edge_list, unit_cost=2)

##############################
# action FTS
############# no action model
action = dict()

robot_action = ActionModel(action)

robot_model = [robot_motion, init_pose, robot_action]
##############################
# complete robot model
robot_full_model = MotActModel(robot_motion, robot_action)

##############################
#specify soft and hard tasks
print(test_ap)

init_pose = ((7.77, 7.00, 0.0), (0.0, 0.0, 0.0, 1.0))
#robot_motion = MotionFts(regions, ap, 'pal_office' )
robot_motion = MotionFts(test, test_ap, 'pal_office')
robot_motion.set_initial(init_pose)
#robot_motion.add_full_edges(unit_cost = 0.1)

for i in range(0, len(data)):
    for j in range(0, len(data[data.keys()[i]]['edges'])):
        print(data[data.keys()[i]]['edges'][j]['cost'])
        #robot_motion.add_un_edges([[tuple(data[data.keys()[i]]['position']), tuple(data[data[data.keys()[i]]['edges'][j]['target']]['position'])]], unit_cost = data[data.keys()[i]]['edges'][j]['cost'])
        robot_motion.add_un_edges(
            [[(tuple(data[data.keys()[i]]['pose']['position']),
               tuple(data[data.keys()[i]]['pose']['orientation'])),
              (tuple(data[data[data.keys()[i]]['edges'][j]['target']]['pose']
                     ['position']),
               tuple(data[data[data.keys()[i]]['edges'][j]['target']]['pose']
                     ['orientation']))]],
            unit_cost=data[data.keys()[i]]['edges'][j]['cost'])

##############################
# action FTS

############# no action model
# action = dict()
############# with action
# for supported actions in play_motion
# see http://wiki.ros.org/Robots/TIAGo/Tutorials/motions/play_motion

action = {
    'col_grasp': (10, 'hm', set([