def solve_push_move(self, ntuple): color = None size = None world = self.world home_pos = world.robot1_instance.pos print('solver: begin move_to_destination') for parameters in ntuple.parameters: protagonist = parameters.causer heading = parameters.affectedProcess.heading goal = parameters.affectedProcess.goal distance = parameters.causalProcess.distance.value inst = protagonist #getattr(self.world, protagonist) obj = self.get_described_obj( parameters.causalProcess.acted_upon['objectDescriptor']) if goal: print("not yet supported. try pushing a box in a direction") if heading: n = float(distance) print(obj.pos) addpos = vector_mul(-6, self.headings[heading]) self.move_precise(inst, obj.pos.x + addpos[0], obj.pos.y + addpos[1]) addpos = vector_mul(-3, self.headings[heading]) self.move_push(inst, obj.pos.x + addpos[0], obj.pos.y + addpos[1], 2) addpos = vector_mul(4, self.headings[heading]) self.move_push(inst, obj.pos.x + addpos[0], obj.pos.y + addpos[1], 2)
def push_direction(self, heading, inst, obj, n): """ Pushes in a certain direction. Used to simplify "solve push move" function. """ addpos = vector_mul(-6, self.headings[heading]) self.move_precise(inst, obj.pos.x + addpos[0], obj.pos.y + addpos[1]) addpos = vector_mul(-3, self.headings[heading]) self.move_push(inst, obj.pos.x + addpos[0], obj.pos.y + addpos[1], 2) #this is the part where it actually pushes forward. I think to make it right, you would need to repalce the following line: #addpos = vector_mul(4, self.headings[heading]) #with this line addpos = vector_mul(n, self.headings[heading]) self.move_push(inst, obj.pos.x + addpos[0], obj.pos.y + addpos[1],2 )
def push_direction(self, heading, inst, obj, n): """ Pushes in a certain direction. Used to simplify "solve push move" function. """ addpos = vector_mul(-6, self.headings[heading]) self.move_precise(inst, obj.pos.x + addpos[0], obj.pos.y + addpos[1]) addpos = vector_mul(-3, self.headings[heading]) self.move_push(inst, obj.pos.x + addpos[0], obj.pos.y + addpos[1], 2) #this is the part where it actually pushes forward. I think to make it right, you would need to repalce the following line: #addpos = vector_mul(4, self.headings[heading]) #with this line addpos = vector_mul(n, self.headings[heading]) self.move_push(inst, obj.pos.x + addpos[0], obj.pos.y + addpos[1], 2)
def solve_move(self, ntuple): print('mock solver: begin move') world = self.world home_pos = world.robot1_instance.pos for parameters in ntuple.parameters: acted_upon = parameters.acted_upon heading = parameters.heading direction = parameters.direction goal = parameters.goal inst = getattr(world, acted_upon) if goal: # TODO: super/subtype relations missing! if goal.ontological_category.type() == 'location': print('| move(x={x}, y={y}, z=0.0)'.format(x=goal.xCoord, y=goal.yCoord)) self.setpos(inst, (float(goal.xCoord), float(goal.yCoord), 0.0)) else: # We assume it's an object, like a box or a block obj = getattr(world, goal.referent.type()) print('| move(x={x}, y={y}, z={z})'.format(x=obj.pos.x, y=obj.pos.y, z=obj.pos.z)) self.setpos(inst, (obj.pos.x, obj.pos.y, obj.pos.z)) elif direction == 'home': print('| move(x={x}, y={y}, z=0.0)'.format(x=home_pos.x, y=home_pos.y)) self.setpos(inst, (home_pos.x, home_pos.y, home_pos.z)) elif heading: n = float(parameters.distance.value) pos = self.getpos(inst) newpos = vector_add(pos, vector_mul(n, self.headings[heading])) print('| move(x={0[0]}, y={0[1]}, z={0[2]})'.format(newpos)) self.setpos(inst, newpos) print('mock solver: end move')
def solve_move(self, parameters): color = None size = None world = self.world print('solver: begin move_to_destination') #for parameters in ntuple.parameters: protagonist = self.get_described_obj(parameters.protagonist['objectDescriptor']) speed = parameters.speed * 6 heading = parameters.heading goal = parameters.goal direction = parameters.direction inst =protagonist #getattr(self.world, protagonist) if goal: # TODO: super/subtype relations missing! # print(goal) if 'location' in goal: #inst.move(x=float(goal['location'][0]), y=float(goal['location'][1]), z=0.0) if goal['location'] == 'home': self.move(inst, self.home_pos.x, self.home_pos.y, self.home_pos.z, tolerance= 2, speed=speed) else: self.move(inst,float(goal['location'][0]), float(goal['location'][1]), 0.0, speed=speed) elif goal == 'home': self.move(inst, home_pos.x, home_pos.y, home_pos.z, speed=speed) elif 'referent' in goal: obj = getattr(self.world, goal['referent']) #inst.move(x=obj.pos.x, y=obj.pos.y, z=obj.pos.z) self.move(inst, obj.pos.x, obj.pos.y, obj.pos.z, speed=speed) elif ('partDescriptor' in goal): if goal['partDescriptor']['relation']['type'] == 'side': loc = self.get_described_part_pos(goal['partDescriptor'],inst) if (loc): self.move(inst, loc[0], loc[1], tolerance= 2, speed=speed) else: if ('objectDescriptor') in goal: properties = goal['objectDescriptor'] obj = self.get_described_obj(properties, multiple=True) if (obj): self.move(inst, obj.pos.x, obj.pos.y, obj.pos.z, speed=speed) elif ('locationDescriptor') in goal: properties = goal['locationDescriptor'] loc = self.get_described_loc_pos(properties,getattr(self.world, inst)) if (loc): self.move(inst, loc[0], loc[1], speed=speed) elif heading: n = float(parameters.distance.value) print(inst) name = getattr(inst, 'name') #pos = getattr(inst, 'pos') #self.getpos(inst) pos = self.getpos(name) newpos = vector_add(pos, vector_mul(n, self.headings[heading])) self.move(inst, newpos[0], newpos[1], newpos[2], speed=speed) print('solver: end move_to_destination')
def solve_move(self, ntuple): world = self.world home_pos = world.robot1_instance.pos print('solver: begin move_to_destination') if debug: print(len(ntuple.parameters)) for parameters in ntuple.parameters: if debug: print(parameters) acted_upon = parameters.acted_upon heading = parameters.heading goal = parameters.goal direction = parameters.direction inst = getattr(self.world, acted_upon) if goal: # TODO: super/subtype relations missing! if debug: print("goal is") if debug: print(goal) if goal.ontological_category.type() == 'location': inst.move(x=float(goal.xCoord), y=float(goal.yCoord), z=0.0) else: # We assume it's an object, like a box or a block if debug: print("self.world") if debug: print(self.world) if debug: print("goal.referent.type()") if debug: print(goal.referent.type()) obj = getattr(self.world, goal.referent.type()) if debug: print("obj is") if debug: print(obj) if debug: print("color type is") if debug: print(goal.extensions.boundedObject) #if debug: print (goal.extensions.property.ontological_category.type()) #color = getattr(self.world, goal.extensions.property.ontological_category.type()) inst.move(x=obj.pos.x, y=obj.pos.y, z=obj.pos.z) elif direction == 'home': ## print('| move(x={x}, y={y}, z=0.0)'.format(x=home_pos.x, y=home_pos.y)) inst.move(x=home_pos.x, y=home_pos.y, z=home_pos.z) elif heading: n = float(parameters.distance.value) pos = self.getpos(inst) newpos = vector_add(pos, vector_mul(n, self.headings[heading])) inst.move(x=newpos[0], y=newpos[1], z=newpos[2]) print('solver: end move_to_destination')
def solve_move(self, ntuple): world = self.world home_pos = world.robot1_instance.pos print('solver: begin move_to_destination') if debug: print(len(ntuple.parameters)) for parameters in ntuple.parameters: if debug: print(parameters) acted_upon = parameters.acted_upon heading = parameters.heading goal = parameters.goal direction = parameters.direction inst = getattr(self.world, acted_upon) if goal: # TODO: super/subtype relations missing! if debug: print("goal is") if debug: print(goal) if goal.ontological_category.type() == 'location': inst.move(x=float(goal.xCoord), y=float(goal.yCoord), z=0.0) else: # We assume it's an object, like a box or a block if debug: print("self.world") if debug: print(self.world) if debug: print("goal.referent.type()") if debug: print(goal.referent.type()) obj = getattr(self.world, goal.referent.type()) if debug: print("obj is") if debug: print(obj) if debug: print("color type is") if debug: print (goal.extensions.boundedObject) #if debug: print (goal.extensions.property.ontological_category.type()) #color = getattr(self.world, goal.extensions.property.ontological_category.type()) inst.move(x=obj.pos.x, y=obj.pos.y, z=obj.pos.z) elif direction == 'home': ## print('| move(x={x}, y={y}, z=0.0)'.format(x=home_pos.x, y=home_pos.y)) inst.move(x=home_pos.x, y=home_pos.y, z=home_pos.z) elif heading: n = float(parameters.distance.value) pos = self.getpos(inst) newpos = vector_add(pos, vector_mul(n, self.headings[heading])) inst.move(x=newpos[0], y=newpos[1], z=newpos[2]) print('solver: end move_to_destination')
def solve_move(self, ntuple): color = None size = None world = self.world home_pos = world.robot1_instance.pos print('solver: begin move_to_destination') for parameters in ntuple.parameters: protagonist = parameters.protagonist speed = parameters.speed * 6 heading = parameters.heading goal = parameters.goal direction = parameters.direction inst = protagonist #getattr(self.world, protagonist) if goal: # TODO: super/subtype relations missing! # print(goal) if 'location' in goal: #inst.move(x=float(goal['location'][0]), y=float(goal['location'][1]), z=0.0) if goal['location'] == 'home': self.move(inst, home_pos.x, home_pos.y, home_pos.z, tolerance=2, speed=speed) else: self.move(inst, float(goal['location'][0]), float(goal['location'][1]), 0.0, speed=speed) elif goal == 'home': self.move(inst, home_pos.x, home_pos.y, home_pos.z, speed=speed) elif 'referent' in goal: obj = getattr(self.world, goal['referent']) #inst.move(x=obj.pos.x, y=obj.pos.y, z=obj.pos.z) self.move(inst, obj.pos.x, obj.pos.y, obj.pos.z, speed=speed) elif ('partDescriptor' in goal): if goal['partDescriptor']['relation']['type'] == 'side': loc = self.get_described_part_pos( goal['partDescriptor'], inst) if (loc): self.move(inst, loc[0], loc[1], tolerence=2, speed=speed) else: if ('objectDescriptor') in goal: properties = goal['objectDescriptor'] obj = self.get_described_obj(properties, multiple=True) if (obj): self.move(inst, obj.pos.x, obj.pos.y, obj.pos.z, speed=speed) elif ('locationDescriptor') in goal: properties = goal['locationDescriptor'] loc = self.get_described_loc_pos( properties, getattr(self.world, inst)) if (loc): self.move(inst, loc[0], loc[1], speed=speed) elif heading: n = float(parameters.distance.value) pos = self.getpos(inst) newpos = vector_add(pos, vector_mul(n, self.headings[heading])) self.move(inst, newpos[0], newpos[1], newpos[2], speed=speed) print('solver: end move_to_destination')