From ec97c583f6a1ce6205d9ceffa10ed9fb89aca94d Mon Sep 17 00:00:00 2001
From: Antonio Andriella <aandriella@iri.upc.edu>
Date: Sun, 11 Oct 2020 12:25:21 +0200
Subject: [PATCH] Add reproduce end game and fix instruction method

---
 src/robot_behaviour/robot_reproducer.py | 30 +++++++++++++++----------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/robot_behaviour/robot_reproducer.py b/src/robot_behaviour/robot_reproducer.py
index 9d2e68a..69937d5 100644
--- a/src/robot_behaviour/robot_reproducer.py
+++ b/src/robot_behaviour/robot_reproducer.py
@@ -10,7 +10,6 @@ import ast
 from robot_behaviour.face_reproducer import Face
 from robot_behaviour.speech_reproducer import Speech
 from robot_behaviour.gesture_reproducer import Gesture
-import robot_behaviour.sentences as s
 
 class Robot:
   def __init__(self, speech, sentences_file, face=None, gesture=None):
@@ -433,7 +432,7 @@ class Robot:
     b_executed = True
     return b_executed
 
-  def instruction(self, counter, facial_expression):
+  def instruction(self,objective , facial_expression):
     '''The agent provides the instructions of the exercise
     Args:
     Return:
@@ -442,16 +441,23 @@ class Robot:
     '''
     print("instruction")
     b_executed = False
-    if counter >= len(self.sentences['instruction'])-1: counter = random.randint(0, len(self.sentences['instruction'])-1)
-    if self.face!=None and self.gesture==None:
-      self.speech.text_to_speech(self.sentences['instruction'][counter], locked=True)
-      rospy.sleep(0.1)
-      self.face.reproduce_face_expression(facial_expression)
-      b_executed = True
-    elif self.face==None and self.gesture!=None:
-      assert "Error Instruction does not contemplate any gesture"
-    else:
-      assert "Error Instruction does not contemplate any gesture"
+    self.speech.text_to_speech(self.sentences[objective][0], locked=True)
+    rospy.sleep(20)
+    self.face.reproduce_face_expression(facial_expression)
+
+  def end_game(self, facial_expression):
+    '''The agent provides the instructions of the exercise
+    Args:
+    Return:
+      Bool:
+      if the action has been executed successfully
+    '''
+    print("end_game")
+    b_executed = False
+    self.speech.text_to_speech(self.sentences['end_game'][0], locked=True)
+    rospy.sleep(0.1)
+    self.face.reproduce_face_expression(facial_expression)
+
 
   def cancel_action(self):
     if self.gesture != None:
-- 
GitLab