Skip to content

Commit

Permalink
making changes to get learning from demo working
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuslima committed Aug 31, 2023
1 parent 2afa07a commit f5852f5
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions App/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self):
self.show_demo = None
self.total_reward = 0
self.demo_idx = 1
self.action = 'noop'
self.action = 0
self.modality = self.config.get('modality')
self.framerate = self.config.get('startingFrameRate', 30)
self.frameId = 0
Expand Down Expand Up @@ -250,17 +250,15 @@ async def handle_command(self, message):
print('Pass this?')
if command == 'start':
self.play = True
if self.action == 'increase':
self.demo_idx+=1
elif self.action == 'decrease':
self.demo_idx-=1

print('using demo', self.demo_idx)

# if self.modality == 'pref':
# self.show_demo = True
# #await self.render_all_frames()
# #await self.render_policy()

if self.modality == 'pref':
if self.action == 'increase':
self.demo_idx+=1
elif self.action == 'decrease':
self.demo_idx-=1

print('using demo', self.demo_idx)

elif command == 'stop':
self.end()
elif command == 'reset':
Expand All @@ -273,6 +271,9 @@ async def handle_command(self, message):
self.handle_feedback(command)
self.handle_pref(command)

elif command == 'left' or 'right' or 'up' or 'bad':
self.handle_action(command)



async def render_all_frames(self):
Expand All @@ -290,6 +291,7 @@ def handle_action(self, action:str):
Translates action to int and resets action buffer if action !=0
'''
#action = action.strip().lower()
print('inside handle action')
print(action)
if self.modality == 'pref':
if action == 'ArrowRight':
Expand All @@ -303,11 +305,7 @@ def handle_action(self, action:str):

elif self.modality == 'demo':
self.action = 0
if action == 'KEYDOWN':
#print('USER: GOOD')
self.action = '0'

elif action == 'ArrowRight':
if action == 'ArrowRight':
#print('USER: GOOD')
self.action = 2
elif action == 'ArrowLeft':
Expand Down Expand Up @@ -401,8 +399,8 @@ async def take_step(self):
done = self.agent.step(self.humanfeedback)

elif self.modality == 'demo':
print('self.humanAction', self.humanAction)
done = self.agent.step(self.humanAction)
print('self.humanAction', self.action)
done = self.agent.step(self.action)



Expand Down

0 comments on commit f5852f5

Please sign in to comment.