Skip to content

Commit

Permalink
xnets
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Trott committed Jul 1, 2016
1 parent f97b8bf commit 6d54b81
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion analyzer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#sh starter.sh &
export ECG_FED=FED1
export JYTHONPATH=../ecg_framework_code/build/compling.core.jar:../ecg_framework_code/src/main/nluas/language
jython -J-Xmx2g -m analyzer ../ecg_grammars/compRobots.prefs
jython -J-Xmx3g -m analyzer ../ecg_grammars/compRobots.prefs
#jython -m analyzer ../ecg_grammars/compRobots.prefs
#python3 src/main/robots/robots_ui.py AgentUI
2 changes: 1 addition & 1 deletion src/main/robots/morse/xnet_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def update_motion(self, **to):
# this isn't being called anymore, so we're not getting the proximity information?
def move(self, **to):
#print('Simulator move: ')
print(to)
#print(to)

inst = getattr(self.simulator, self.name)

Expand Down
25 changes: 23 additions & 2 deletions src/main/robots/robot_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, args):
#self.world = self.build_world("mock/world.json") #build('mock')

self._recent = []
self.recent_protagonists = []
self._wh = None
self._speed = 4
# This depends on how size is represented in the grammar.
Expand Down Expand Up @@ -232,6 +233,16 @@ def command_stop(self, parameters):
process = parameters['process']
actionary = process['actionary']
protagonist = self.get_described_object(parameters['protagonist']['objectDescriptor'])
self.stop(protagonist)
#print(protagonist.name)
# DO SOMETHING HERE...


def command_continue(self, parameters):
process = parameters['process']
actionary = process['actionary']
protagonist = self.get_described_object(parameters['protagonist']['objectDescriptor'])
self.resume(protagonist)
#print(protagonist.name)
# DO SOMETHING HERE...

Expand All @@ -255,12 +266,19 @@ def command_move(self, parameters):
# TO DO: What to do here?
#print("Command_move, no destination.")

def get_default_protagonist(self):
if len(self.recent_protagonists) > 0:
return self.recent_protagonists[-1]
return getattr(self.world, "robot1_instance")

def get_move_info(self, parameters):
information = dict(destination=None,
protagonist=None,
speed=None)

information['protagonist'] = self.get_described_object(parameters['protagonist']['objectDescriptor'])
if information['protagonist'] is None:
information['protagonist'] = self.get_default_protagonist()
information['speed'] = parameters['speed'] * self._speed
#spg = selparameters['spg']

Expand Down Expand Up @@ -354,7 +372,7 @@ def push_to_location(self, actedUpon, goal, protagonist):

def push_direction(self, heading, actedUpon, distance, protagonist):
info = self.get_push_direction_info(heading, actedUpon, distance['scaleDescriptor']['value'])
self.move(protagonist, info['x1'], info['y1'], tolerance=4)
self.move(protagonist, info['x1'], info['y1'], tolerance=2.5)
self.move(protagonist, info['x2'], info['y2'], tolerance=3, collide=True)


Expand All @@ -375,6 +393,8 @@ def get_push_info(self, parameters):
else:
heading = None
protagonist = self.get_described_object(parameters['protagonist']['objectDescriptor'])
if protagonist is None:
protagonist = self.get_default_protagonist()
goal = parameters['affectedProcess']['spg']['spgDescriptor']['goal']
distance = parameters['affectedProcess']['distance']
info = dict(goal=None,
Expand Down Expand Up @@ -616,7 +636,7 @@ def get_described_object(self, description, multiple=False):
return None
else:
message = "Sorry, I don't know what the {} is.".format(self.assemble_string(description))
self.identification_failure(message)
#self.identification_failure(message) #TESTING, for speech and unmentioned referents
return None

def tag_ntuple(self, ntuple, description, k=None):
Expand Down Expand Up @@ -1088,6 +1108,7 @@ def solve_conditional_declarative(self, ntuple):


def move(self, mover, x, y, z=1.0, speed=2, tolerance=3, collide=False):
self.recent_protagonists.append(mover)

msg = "{} is moving to ({}, {}, {}).".format(mover.name, x, y, z)
#print()
Expand Down
10 changes: 10 additions & 0 deletions src/main/robots/xnet_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ def move(self, mover, x, y, z=0.0, speed=2, tolerance=3.5, collide=False):
## print('exiting xnet solver move')
self.update_world(agent=mover)


def stop(self, mover):
## print('xnet solver stop requested')
self.solver_command_processor.set_suspended_expected(True)
mover.suspend()

def resume(self, mover):
self.solver_command_processor.set_continue_expected(False)
mover.resume()

if __name__ == "__main__":
solver = XnetMorseSolver(sys.argv[1:])
#solver = XnetRobotSolver(sys.argv[1:])

0 comments on commit 6d54b81

Please sign in to comment.