Commit 04d8d49b authored by Boksebeld, N.H.J.'s avatar Boksebeld, N.H.J.
Browse files

Changed Bouncer program after testing

parent 1f2de6cc
......@@ -17,102 +17,7 @@
def onInput_onStop(self):
self.onUnload() #~ it is recommended to call onUnload of this box in a onStop method, as the code written in onUnload is used to stop the box as well
pass]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Resource name="All motors" type="Lock" timeout="0" /><Resource name="Stiffness" type="Lock" timeout="0" /></Box><Box name="Basic Awareness" id="4" localization="8" tooltip="This box is an interface to the module ALBasicAwareness.&#x0A;&#x0A;It is a simple way to make the robot establish and keep eye contact with people.&#x0A;&#x0A;V1.1.0" x="454" y="234"><bitmap>media/images/box/tracker/basicawareness.png</bitmap><script language="4"><content><![CDATA[class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
#put initialization code here
try:
self.awareness = ALProxy('ALBasicAwareness')
except Exception as e:
self.awareness = None
self.logger.error(e)
self.memory = ALProxy('ALMemory')
self.isRunning = False
self.trackedHuman = -1
import threading
self.subscribingLock = threading.Lock()
self.BIND_PYTHON(self.getName(), "setParameter")
def onUnload(self):
if self.isRunning:
if self.awareness:
self.awareness.stopAwareness()
self.setALMemorySubscription(False)
self.isRunning = False
def onInput_onStart(self):
if self.isRunning:
return # already running, nothing to do
self.isRunning = True
self.trackedHuman = -1
if self.awareness:
self.awareness.setEngagementMode(self.getParameter('Engagement Mode'))
self.awareness.setTrackingMode(self.getParameter('Tracking Mode'))
self.awareness.setStimulusDetectionEnabled('Sound', self.getParameter('Sound Stimulus'))
self.awareness.setStimulusDetectionEnabled('Movement', self.getParameter('Movement Stimulus'))
self.awareness.setStimulusDetectionEnabled('People', self.getParameter('People Stimulus'))
self.awareness.setStimulusDetectionEnabled('Touch', self.getParameter('Touch Stimulus'))
self.setALMemorySubscription(True)
self.awareness.startAwareness()
def onInput_onStop(self):
if not self.isRunning:
return # already stopped, nothing to do
self.onUnload()
self.onStopped()
def setParameter(self, parameterName, newValue):
GeneratedClass.setParameter(self, parameterName, newValue)
if self.awareness:
if parameterName == 'Sound Stimulus':
self.awareness.setStimulusDetectionEnabled('Sound', newValue)
elif parameterName == 'Movement Stimulus':
self.awareness.setStimulusDetectionEnabled('Movement', newValue)
elif parameterName == 'People Stimulus':
self.awareness.setStimulusDetectionEnabled('People', newValue)
elif parameterName == 'Touch Stimulus':
self.awareness.setStimulusDetectionEnabled('Touch', newValue)
# callbacks for ALBasicAwareness events
def onStimulusDetected(self, eventName, stimulusName, subscriberIdentifier):
self.StimulusDetected(stimulusName)
def onHumanTracked(self, eventName, humanID, subscriberIdentifier):
self.trackedHuman = humanID
self.HumanTracked(humanID)
def onHumanLost(self, eventName, subscriberIdentifier):
self.HumanLost(self.trackedHuman)
self.trackedHuman = -1
def setALMemorySubscription(self, subscribe):
self.subscribingLock.acquire()
if subscribe:
self.memory.subscribeToEvent('ALBasicAwareness/StimulusDetected', self.getName(), 'onStimulusDetected')
self.memory.subscribeToEvent('ALBasicAwareness/HumanTracked', self.getName(), 'onHumanTracked')
self.memory.subscribeToEvent('ALBasicAwareness/HumanLost', self.getName(), 'onHumanLost')
else:
self.memory.unsubscribeToEvent('ALBasicAwareness/StimulusDetected', self.getName())
self.memory.unsubscribeToEvent('ALBasicAwareness/HumanTracked', self.getName())
self.memory.unsubscribeToEvent('ALBasicAwareness/HumanLost', self.getName())
self.subscribingLock.release()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Starts the Basic Awareness with the given Engagement and Tracking mode parameters, using the given stimuli." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Stops the Basic Awareness." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Output name="StimulusDetected" type="3" type_size="1" nature="2" inner="0" tooltip="This output is stimulated when BasicAwareness detects a stimulus amongst the tracked stimulus.&#x0A;&#x0A;The output data is the stimulus&apos; name." id="5" /><Output name="HumanTracked" type="2" type_size="1" nature="2" inner="0" tooltip="This output is triggered when ALBasicAwareness detects a stimulus that is confirmed to be a human.&#x0A;&#x0A;The output data is the ID corresponding to the tracked human. It is shared with PeoplePerception and can be used there. This output is triggered with -1 if ALBasicAwareness tried to detect a human but failed." id="6" /><Output name="HumanLost" type="2" type_size="1" nature="2" inner="0" tooltip="This output is triggered when the human currently tracked is lost.&#x0A;&#x0A; The output data is the ID corresponding to the lost human. It can be reused in PeoplePerception." id="7" /><Parameter name="Engagement Mode" inherits_from_parent="0" content_type="3" value="FullyEngaged" default_value="Unengaged" custom_choice="0" tooltip='The engagement mode specifies how &quot;focused&quot; the robot is on the engaged person.' id="8"><Choice value="Unengaged" /><Choice value="FullyEngaged" /><Choice value="SemiEngaged" /></Parameter><Parameter name="Tracking Mode" inherits_from_parent="0" content_type="3" value="Head" default_value="Head" custom_choice="0" tooltip="The tracking mode describes how the robot keeps eye contact with an engaged person." id="9"><Choice value="Head" /><Choice value="BodyRotation" /><Choice value="WholeBody" /></Parameter><Parameter name="Sound Stimulus" inherits_from_parent="0" content_type="0" value="0" default_value="1" tooltip="" id="10" /><Parameter name="Movement Stimulus" inherits_from_parent="0" content_type="0" value="0" default_value="1" tooltip="" id="11" /><Parameter name="People Stimulus" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="12" /><Parameter name="Touch Stimulus" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="13" /></Box><Box name="Face Tracker" id="1" localization="-1" tooltip="This box makes the robot track a face with different modes." x="662" y="409"><bitmap>media/images/box/interaction/target_face.png</bitmap><script language="4"><content><![CDATA[import time
pass]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Resource name="All motors" type="Lock" timeout="0" /><Resource name="Stiffness" type="Lock" timeout="0" /></Box><Box name="Face Tracker" id="1" localization="-1" tooltip="This box makes the robot track a face with different modes." x="662" y="409"><bitmap>media/images/box/interaction/target_face.png</bitmap><script language="4"><content><![CDATA[import time
class MyClass(GeneratedClass):
def __init__(self):
......@@ -253,9 +158,9 @@ class MyClass(GeneratedClass):
def onInput_onStart(self, p):
p = self.typeConversion(p)
if(p == self.typeConversion(Touch)):
if(p == self.typeConversion("TabletTouch")):
self.output_1(p)
elif(p == self.typeConversion(People)):
elif(p == self.typeConversion("People")):
self.output_2(p)
else:
self.onDefault()
......@@ -268,7 +173,7 @@ class MyClass(GeneratedClass):
p = pint
except:
p = str(p)
return p]]></content></script><pluginContent><keywords><keyword>Touch</keyword><keyword>People</keyword><keyword></keyword></keywords></pluginContent><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="0" type_size="1" nature="1" inner="0" tooltip="Value to test." id="2" /><Output name="onDefault" type="1" type_size="1" nature="2" inner="0" tooltip="If the input value does not match any value set on the box." id="3" /><Output name="output_1" type="0" type_size="1" nature="2" inner="0" tooltip="This IO has been automatically added by box. Read box tooltip for more information." id="4" /><Output name="output_2" type="0" type_size="1" nature="2" inner="0" tooltip="This IO has been automatically added by box. Read box tooltip for more information." id="5" /></Box><Box name="Say" id="6" localization="8" tooltip="Say some text. The text can be localized." x="923" y="28"><bitmap>media/images/box/interaction/say.png</bitmap><script language="4"><content><![CDATA[import time
return p]]></content></script><pluginContent><keywords><keyword>&quot;TabletTouch&quot;</keyword><keyword>&quot;People&quot;</keyword><keyword></keyword></keywords></pluginContent><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="0" type_size="1" nature="1" inner="0" tooltip="Value to test." id="2" /><Output name="onDefault" type="1" type_size="1" nature="2" inner="0" tooltip="If the input value does not match any value set on the box." id="3" /><Output name="output_1" type="0" type_size="1" nature="2" inner="0" tooltip="This IO has been automatically added by box. Read box tooltip for more information." id="4" /><Output name="output_2" type="0" type_size="1" nature="2" inner="0" tooltip="This IO has been automatically added by box. Read box tooltip for more information." id="5" /></Box><Box name="Say" id="6" localization="8" tooltip="Say some text. The text can be localized." x="798" y="54"><bitmap>media/images/box/interaction/say.png</bitmap><script language="4"><content><![CDATA[import time
class MyClass(GeneratedClass):
def __init__(self):
......@@ -309,7 +214,7 @@ class MyClass(GeneratedClass):
self.bIsRunning = False
def onInput_onStop(self):
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this Input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this Input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when Box behavior is finished." id="4" /><Parameter name="Voice shaping (%)" inherits_from_parent="1" content_type="1" value="119" default_value="100" min="50" max="150" tooltip='Used to modify at runtime the voice feature (tone, speed). In a slighty&#x0A;different way than pitch and speed, it gives a kind of &quot;gender or age&#x0A;modification&quot; effect.&#x0A;&#x0A;For instance, a quite good male derivation of female voice can be&#x0A;obtained setting this parameter to 78%.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the&#x0A;speed parameter. For example, if you want to decrease by 20% the voice&#x0A;shaping, you will have to increase by 20% the speed to keep a constant&#x0A;average speed.' id="5" /><Parameter name="Speed (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="200" tooltip="Changes the speed of the voice.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the voice&#x0A;shaping parameter. For example, if you want to increase by 20% the speed, you&#x0A;will have to decrease by 20% the voice shaping to keep a constant average&#x0A;speed." id="6" /><Parameter name="Text" inherits_from_parent="0" content_type="5" value="Don&apos;t touch me!" default_value="" tooltip="The text you want to say. Don&apos;t forget to translate it!" id="7" /></Box><Box name="BothArmsUpAndDown_HeadShake_01" id="7" localization="8" tooltip="ID : #01D 0002&#x0A;&#x0A;===================&#x0A;&#x0A;Tags : &#x0A;- Never&#x0A;- Negative&#x0A;- Can&apos;t&#x0A;- Error&#x0A;&#x0A;===================&#x0A;&#x0A;Common dialog : Yes&#x0A;&#x0A;===================&#x0A;&#x0A;Start stance : Center&#x0A;End stance : Center" x="891" y="188"><bitmap>media/images/box/movement/move.png</bitmap><script language="4"><content><![CDATA[]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Timeline enable="1" fps="25" start_frame="1" end_frame="-1" size="73"><ActuatorList model=""><ActuatorCurve name="value" actuator="HeadPitch" mute="0" unit="0"><Key frame="12" value="-33.6947" /><Key frame="28" value="-13.1947" /><Key frame="73" value="-25.8562" /></ActuatorCurve><ActuatorCurve name="value" actuator="HeadYaw" mute="0" unit="0"><Key frame="12" value="0" /><Key frame="36" value="0" /><Key frame="43" value="9.1" /><Key frame="51" value="-9.1" /><Key frame="57" value="3" /><Key frame="64" value="-15.1" /><Key frame="73" value="-0.441859" /></ActuatorCurve><ActuatorCurve name="value" actuator="HipPitch" mute="0" unit="0"><Key frame="28" value="-16.3318" /><Key frame="43" value="4.41214" /><Key frame="67" value="-2.08216" /></ActuatorCurve><ActuatorCurve name="value" actuator="HipRoll" mute="0" unit="0"><Key frame="28" value="-0.398331" /><Key frame="43" value="-0.398331" /><Key frame="67" value="-0.398331" /></ActuatorCurve><ActuatorCurve name="value" actuator="KneePitch" mute="0" unit="0"><Key frame="28" value="9.21804" /><Key frame="43" value="-2.70441" /><Key frame="67" value="-0.91902" /></ActuatorCurve><ActuatorCurve name="value" actuator="LElbowRoll" mute="0" unit="0"><Key frame="12" value="-65.2623" /><Key frame="18" value="-72.1594" /><Key frame="23" value="-72.1594" /><Key frame="36" value="-39.4" /><Key frame="51" value="-74.3" /><Key frame="67" value="-24.4315" /></ActuatorCurve><ActuatorCurve name="value" actuator="LElbowYaw" mute="0" unit="0"><Key frame="12" value="-59.7607" /><Key frame="23" value="-54.1" /><Key frame="28" value="-54.1" /><Key frame="51" value="-119.5" /><Key frame="67" value="-69.7884" /></ActuatorCurve><ActuatorCurve name="value" actuator="LHand" mute="0" unit="1"><Key frame="12" value="0.384736" /><Key frame="43" value="0.62" /><Key frame="51" value="0.92" /><Key frame="67" value="0.3096" /></ActuatorCurve><ActuatorCurve name="value" actuator="LShoulderPitch" mute="0" unit="0"><Key frame="12" value="74.8891" /><Key frame="23" value="69.9" /><Key frame="28" value="69.9" /><Key frame="39" value="80.4" /><Key frame="51" value="78.9" /><Key frame="67" value="85.3405" /></ActuatorCurve><ActuatorCurve name="value" actuator="LShoulderRoll" mute="0" unit="0"><Key frame="12" value="11.2991" /><Key frame="36" value="15" /><Key frame="51" value="31.1" /><Key frame="67" value="10.0173" /></ActuatorCurve><ActuatorCurve name="value" actuator="LWristYaw" mute="0" unit="0"><Key frame="12" value="-4.96666" /><Key frame="51" value="-53.9" /><Key frame="67" value="5.00743" /></ActuatorCurve><ActuatorCurve name="value" actuator="RElbowRoll" mute="0" unit="0"><Key frame="12" value="65.2671" /><Key frame="18" value="77.7786" /><Key frame="23" value="77.7786" /><Key frame="36" value="39.4" /><Key frame="51" value="74.3" /><Key frame="67" value="23.9968" /></ActuatorCurve><ActuatorCurve name="value" actuator="RElbowYaw" mute="0" unit="0"><Key frame="12" value="59.7539" /><Key frame="23" value="54.1" /><Key frame="28" value="54.1" /><Key frame="51" value="119.5" /><Key frame="67" value="69.4321" /></ActuatorCurve><ActuatorCurve name="value" actuator="RHand" mute="0" unit="1"><Key frame="12" value="0.295756" /><Key frame="43" value="0.62" /><Key frame="51" value="0.92" /><Key frame="67" value="0.3068" /></ActuatorCurve><ActuatorCurve name="value" actuator="RShoulderPitch" mute="0" unit="0"><Key frame="12" value="74.9067" /><Key frame="23" value="69.9" /><Key frame="28" value="69.9" /><Key frame="39" value="80.4" /><Key frame="51" value="78.9" /><Key frame="67" value="85.0816" /></ActuatorCurve><ActuatorCurve name="value" actuator="RShoulderRoll" mute="0" unit="0"><Key frame="12" value="-11.7157" /><Key frame="36" value="-15" /><Key frame="51" value="-31.1" /><Key frame="67" value="-9.58261" /></ActuatorCurve><ActuatorCurve name="value" actuator="RWristYaw" mute="0" unit="0"><Key frame="12" value="5.97644" /><Key frame="51" value="80" /><Key frame="67" value="6.4137" /></ActuatorCurve></ActuatorList></Timeline><Resource name="Standing" type="Lock" timeout="1" /><Resource name="All motors" type="Lock" timeout="1" /></Box><Box name="Get Expression" id="5" localization="8" tooltip="This box returns the detected facial expression of the person in front of the robot.&#x0A;The detection fails when there are more or less than one person in front of the robot or when the timeout is exceeded.&#x0A;&#x0A;It is possible to set up the Confidence Threshold and the Timeout parameters for this box. &#x0A;Furthermore it is possible to select the required emotions:&#x0A;- neutral&#x0A;- happy&#x0A;- surprised&#x0A;- angry&#x0A;- sad" x="845" y="326"><bitmap>media/images/box/interaction/emotion.png</bitmap><script language="4"><content><![CDATA[class MyClass(GeneratedClass):
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this Input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this Input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when Box behavior is finished." id="4" /><Parameter name="Voice shaping (%)" inherits_from_parent="1" content_type="1" value="117" default_value="100" min="50" max="150" tooltip='Used to modify at runtime the voice feature (tone, speed). In a slighty&#x0A;different way than pitch and speed, it gives a kind of &quot;gender or age&#x0A;modification&quot; effect.&#x0A;&#x0A;For instance, a quite good male derivation of female voice can be&#x0A;obtained setting this parameter to 78%.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the&#x0A;speed parameter. For example, if you want to decrease by 20% the voice&#x0A;shaping, you will have to increase by 20% the speed to keep a constant&#x0A;average speed.' id="5" /><Parameter name="Speed (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="200" tooltip="Changes the speed of the voice.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the voice&#x0A;shaping parameter. For example, if you want to increase by 20% the speed, you&#x0A;will have to decrease by 20% the voice shaping to keep a constant average&#x0A;speed." id="6" /><Parameter name="Text" inherits_from_parent="0" content_type="5" value="Don&apos;t touch me!" default_value="" tooltip="The text you want to say. Don&apos;t forget to translate it!" id="7" /></Box><Box name="BothArmsUpAndDown_HeadShake_01" id="7" localization="8" tooltip="ID : #01D 0002&#x0A;&#x0A;===================&#x0A;&#x0A;Tags : &#x0A;- Never&#x0A;- Negative&#x0A;- Can&apos;t&#x0A;- Error&#x0A;&#x0A;===================&#x0A;&#x0A;Common dialog : Yes&#x0A;&#x0A;===================&#x0A;&#x0A;Start stance : Center&#x0A;End stance : Center" x="950" y="149"><bitmap>media/images/box/movement/move.png</bitmap><script language="4"><content><![CDATA[]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Timeline enable="1" fps="25" start_frame="1" end_frame="-1" size="73"><ActuatorList model=""><ActuatorCurve name="value" actuator="HeadPitch" mute="0" unit="0"><Key frame="12" value="-33.6947" /><Key frame="28" value="-13.1947" /><Key frame="73" value="-25.8562" /></ActuatorCurve><ActuatorCurve name="value" actuator="HeadYaw" mute="0" unit="0"><Key frame="12" value="0" /><Key frame="36" value="0" /><Key frame="43" value="9.1" /><Key frame="51" value="-9.1" /><Key frame="57" value="3" /><Key frame="64" value="-15.1" /><Key frame="73" value="-0.441859" /></ActuatorCurve><ActuatorCurve name="value" actuator="HipPitch" mute="0" unit="0"><Key frame="28" value="-16.3318" /><Key frame="43" value="4.41214" /><Key frame="67" value="-2.08216" /></ActuatorCurve><ActuatorCurve name="value" actuator="HipRoll" mute="0" unit="0"><Key frame="28" value="-0.398331" /><Key frame="43" value="-0.398331" /><Key frame="67" value="-0.398331" /></ActuatorCurve><ActuatorCurve name="value" actuator="KneePitch" mute="0" unit="0"><Key frame="28" value="9.21804" /><Key frame="43" value="-2.70441" /><Key frame="67" value="-0.91902" /></ActuatorCurve><ActuatorCurve name="value" actuator="LElbowRoll" mute="0" unit="0"><Key frame="12" value="-65.2623" /><Key frame="18" value="-72.1594" /><Key frame="23" value="-72.1594" /><Key frame="36" value="-39.4" /><Key frame="51" value="-74.3" /><Key frame="67" value="-24.4315" /></ActuatorCurve><ActuatorCurve name="value" actuator="LElbowYaw" mute="0" unit="0"><Key frame="12" value="-59.7607" /><Key frame="23" value="-54.1" /><Key frame="28" value="-54.1" /><Key frame="51" value="-119.5" /><Key frame="67" value="-69.7884" /></ActuatorCurve><ActuatorCurve name="value" actuator="LHand" mute="0" unit="1"><Key frame="12" value="0.384736" /><Key frame="43" value="0.62" /><Key frame="51" value="0.92" /><Key frame="67" value="0.3096" /></ActuatorCurve><ActuatorCurve name="value" actuator="LShoulderPitch" mute="0" unit="0"><Key frame="12" value="74.8891" /><Key frame="23" value="69.9" /><Key frame="28" value="69.9" /><Key frame="39" value="80.4" /><Key frame="51" value="78.9" /><Key frame="67" value="85.3405" /></ActuatorCurve><ActuatorCurve name="value" actuator="LShoulderRoll" mute="0" unit="0"><Key frame="12" value="11.2991" /><Key frame="36" value="15" /><Key frame="51" value="31.1" /><Key frame="67" value="10.0173" /></ActuatorCurve><ActuatorCurve name="value" actuator="LWristYaw" mute="0" unit="0"><Key frame="12" value="-4.96666" /><Key frame="51" value="-53.9" /><Key frame="67" value="5.00743" /></ActuatorCurve><ActuatorCurve name="value" actuator="RElbowRoll" mute="0" unit="0"><Key frame="12" value="65.2671" /><Key frame="18" value="77.7786" /><Key frame="23" value="77.7786" /><Key frame="36" value="39.4" /><Key frame="51" value="74.3" /><Key frame="67" value="23.9968" /></ActuatorCurve><ActuatorCurve name="value" actuator="RElbowYaw" mute="0" unit="0"><Key frame="12" value="59.7539" /><Key frame="23" value="54.1" /><Key frame="28" value="54.1" /><Key frame="51" value="119.5" /><Key frame="67" value="69.4321" /></ActuatorCurve><ActuatorCurve name="value" actuator="RHand" mute="0" unit="1"><Key frame="12" value="0.295756" /><Key frame="43" value="0.62" /><Key frame="51" value="0.92" /><Key frame="67" value="0.3068" /></ActuatorCurve><ActuatorCurve name="value" actuator="RShoulderPitch" mute="0" unit="0"><Key frame="12" value="74.9067" /><Key frame="23" value="69.9" /><Key frame="28" value="69.9" /><Key frame="39" value="80.4" /><Key frame="51" value="78.9" /><Key frame="67" value="85.0816" /></ActuatorCurve><ActuatorCurve name="value" actuator="RShoulderRoll" mute="0" unit="0"><Key frame="12" value="-11.7157" /><Key frame="36" value="-15" /><Key frame="51" value="-31.1" /><Key frame="67" value="-9.58261" /></ActuatorCurve><ActuatorCurve name="value" actuator="RWristYaw" mute="0" unit="0"><Key frame="12" value="5.97644" /><Key frame="51" value="80" /><Key frame="67" value="6.4137" /></ActuatorCurve></ActuatorList></Timeline><Resource name="Standing" type="Lock" timeout="1" /><Resource name="All motors" type="Lock" timeout="1" /></Box><Box name="Get Expression" id="5" localization="8" tooltip="This box returns the detected facial expression of the person in front of the robot.&#x0A;The detection fails when there are more or less than one person in front of the robot or when the timeout is exceeded.&#x0A;&#x0A;It is possible to set up the Confidence Threshold and the Timeout parameters for this box. &#x0A;Furthermore it is possible to select the required emotions:&#x0A;- neutral&#x0A;- happy&#x0A;- surprised&#x0A;- angry&#x0A;- sad" x="845" y="326"><bitmap>media/images/box/interaction/emotion.png</bitmap><script language="4"><content><![CDATA[class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
......@@ -427,7 +332,7 @@ class MyClass(GeneratedClass):
d.cancel()
def onInput_onStop(self):
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="3" type_size="1" nature="1" inner="0" tooltip='Returns the facial expression of the person in front of the robot. &#x0A;- &quot;neutral&quot;&#x0A;- &quot;happy&quot;&#x0A;- &quot;surprised&quot;&#x0A;- &quot;angry&quot;&#x0A;- &quot;sad&quot;&#x0A;&#x0A;Tip:&#x0A;Connect this output to a &quot;Switch Case&quot; box containing the possible output values as strings. In this way you can trigger different paths in your behavior depending on the output.' id="4" /><Output name="onError" type="3" type_size="1" nature="1" inner="0" tooltip='Triggered when gender detection failed. &#x0A;Possible error messages:&#x0A;- &quot;No face detected&quot;&#x0A;- &quot;Multiple faces detected&quot;&#x0A;- &quot;Timeout&quot;' id="5" /><Parameter name="Confidence Threshold" inherits_from_parent="0" content_type="2" value="0.35" default_value="0.6" min="0" max="1" tooltip="Set the confidence threshold for the age detection." id="6" /><Parameter name="Timeout (s)" inherits_from_parent="0" content_type="2" value="10" default_value="5" min="1" max="60" tooltip="" id="7" /><Parameter name="neutral" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="8" /><Parameter name="happy" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="9" /><Parameter name="surprised" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="10" /><Parameter name="angry" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="11" /><Parameter name="sad" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="12" /></Box><Box name="Switch Case (1)" id="8" localization="8" tooltip="Test input value and stimulate the output matching to this value. If there is no&#x0A;matching output, the default output (onDefault) is stimulated.&#x0A;&#x0A;You can edit a case by left double-clicking on the line. You can add a&#x0A;case by right clicking on a line and selecting &apos;Insert a row&apos;. You can delete&#x0A;a case by right clicking on a line and selecting &apos;Remove a row&apos;." plugin="dispatcher_plugin" x="1010" y="273"><bitmap>media/images/box/interaction/choice.png</bitmap><script language="4"><content><![CDATA[# /!\ Generated content. Do not edit!
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="3" type_size="1" nature="1" inner="0" tooltip='Returns the facial expression of the person in front of the robot. &#x0A;- &quot;neutral&quot;&#x0A;- &quot;happy&quot;&#x0A;- &quot;surprised&quot;&#x0A;- &quot;angry&quot;&#x0A;- &quot;sad&quot;&#x0A;&#x0A;Tip:&#x0A;Connect this output to a &quot;Switch Case&quot; box containing the possible output values as strings. In this way you can trigger different paths in your behavior depending on the output.' id="4" /><Output name="onError" type="3" type_size="1" nature="1" inner="0" tooltip='Triggered when gender detection failed. &#x0A;Possible error messages:&#x0A;- &quot;No face detected&quot;&#x0A;- &quot;Multiple faces detected&quot;&#x0A;- &quot;Timeout&quot;' id="5" /><Parameter name="Confidence Threshold" inherits_from_parent="0" content_type="2" value="0.35" default_value="0.6" min="0" max="1" tooltip="Set the confidence threshold for the age detection." id="6" /><Parameter name="Timeout (s)" inherits_from_parent="0" content_type="2" value="10" default_value="5" min="1" max="60" tooltip="" id="7" /><Parameter name="neutral" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="8" /><Parameter name="happy" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="9" /><Parameter name="surprised" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="10" /><Parameter name="angry" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="11" /><Parameter name="sad" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="12" /></Box><Box name="Switch Case (1)" id="8" localization="8" tooltip="Test input value and stimulate the output matching to this value. If there is no&#x0A;matching output, the default output (onDefault) is stimulated.&#x0A;&#x0A;You can edit a case by left double-clicking on the line. You can add a&#x0A;case by right clicking on a line and selecting &apos;Insert a row&apos;. You can delete&#x0A;a case by right clicking on a line and selecting &apos;Remove a row&apos;." plugin="dispatcher_plugin" x="988" y="273"><bitmap>media/images/box/interaction/choice.png</bitmap><script language="4"><content><![CDATA[# /!\ Generated content. Do not edit!
class MyClass(GeneratedClass):
def __init__(self):
try: # disable autoBind
......@@ -437,8 +342,10 @@ class MyClass(GeneratedClass):
def onInput_onStart(self, p):
p = self.typeConversion(p)
if(p == self.typeConversion(happy)):
if(p == self.typeConversion("happy")):
self.output_1(p)
elif(p == self.typeConversion("neutral")):
self.output_2(p)
else:
self.onDefault()
......@@ -450,7 +357,7 @@ class MyClass(GeneratedClass):
p = pint
except:
p = str(p)
return p]]></content></script><pluginContent><keywords><keyword>happy</keyword><keyword></keyword></keywords></pluginContent><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="0" type_size="1" nature="1" inner="0" tooltip="Value to test." id="2" /><Output name="onDefault" type="1" type_size="1" nature="2" inner="0" tooltip="If the input value does not match any value set on the box." id="3" /><Output name="output_1" type="0" type_size="1" nature="2" inner="0" tooltip="This IO has been automatically added by box. Read box tooltip for more information." id="4" /></Box><Box name="Say (1)" id="9" localization="8" tooltip="Say some text. The text can be localized." x="1269" y="395"><bitmap>media/images/box/interaction/say.png</bitmap><script language="4"><content><![CDATA[import time
return p]]></content></script><pluginContent><keywords><keyword>&quot;happy&quot;</keyword><keyword>&quot;neutral&quot;</keyword><keyword></keyword></keywords></pluginContent><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="0" type_size="1" nature="1" inner="0" tooltip="Value to test." id="2" /><Output name="onDefault" type="1" type_size="1" nature="2" inner="0" tooltip="If the input value does not match any value set on the box." id="3" /><Output name="output_1" type="0" type_size="1" nature="2" inner="0" tooltip="This IO has been automatically added by box. Read box tooltip for more information." id="4" /><Output name="output_2" type="0" type_size="1" nature="2" inner="0" tooltip="This IO has been automatically added by box. Read box tooltip for more information." id="5" /></Box><Box name="Say (1)" id="9" localization="8" tooltip="Say some text. The text can be localized." x="1311" y="289"><bitmap>media/images/box/interaction/say.png</bitmap><script language="4"><content><![CDATA[import time
class MyClass(GeneratedClass):
def __init__(self):
......@@ -491,123 +398,7 @@ class MyClass(GeneratedClass):
self.bIsRunning = False
def onInput_onStop(self):
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this Input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this Input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when Box behavior is finished." id="4" /><Parameter name="Voice shaping (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="150" tooltip='Used to modify at runtime the voice feature (tone, speed). In a slighty&#x0A;different way than pitch and speed, it gives a kind of &quot;gender or age&#x0A;modification&quot; effect.&#x0A;&#x0A;For instance, a quite good male derivation of female voice can be&#x0A;obtained setting this parameter to 78%.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the&#x0A;speed parameter. For example, if you want to decrease by 20% the voice&#x0A;shaping, you will have to increase by 20% the speed to keep a constant&#x0A;average speed.' id="5" /><Parameter name="Speed (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="200" tooltip="Changes the speed of the voice.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the voice&#x0A;shaping parameter. For example, if you want to increase by 20% the speed, you&#x0A;will have to decrease by 20% the voice shaping to keep a constant average&#x0A;speed." id="6" /><Parameter name="Text" inherits_from_parent="0" content_type="5" value="Come on in" default_value="" tooltip="The text you want to say. Don&apos;t forget to translate it!" id="7" /></Box><Box name="WideOpenBothHands_01" id="10" localization="8" tooltip="ID : #01C 0036&#x0A;&#x0A;===================&#x0A;&#x0A;Tags : &#x0A;-&#x0A;-&#x0A;&#x0A;===================&#x0A;&#x0A;Common dialog : Yes&#x0A;&#x0A;===================&#x0A;&#x0A;Start stance : Center&#x0A;End stance : Center" x="1274" y="512"><bitmap>media/images/box/movement/move.png</bitmap><script language="4"><content><![CDATA[]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Timeline enable="1" fps="25" start_frame="1" end_frame="-1" size="43"><ActuatorList model=""><ActuatorCurve name="value" actuator="HeadPitch" mute="0" unit="0"><Key frame="16" value="-4.60067" /><Key frame="26" value="-11.1925" /><Key frame="36" value="-16.1145" /><Key frame="42" value="-17.345" /></ActuatorCurve><ActuatorCurve name="value" actuator="HeadYaw" mute="0" unit="0"><Key frame="16" value="1.31597" /><Key frame="26" value="2.89802" /><Key frame="36" value="1.75543" /><Key frame="42" value="2.89802" /></ActuatorCurve><ActuatorCurve name="value" actuator="LElbowRoll" mute="0" unit="0"><Key frame="15" value="-37.3516" /><Key frame="26" value="-20.74" /><Key frame="36" value="-22.3221" /><Key frame="43" value="-20.8279" /></ActuatorCurve><ActuatorCurve name="value" actuator="LElbowYaw" mute="0" unit="0"><Key frame="15" value="-73.8245" /><Key frame="26" value="-91.7545" /><Key frame="36" value="-94.3033" /><Key frame="43" value="-91.7545" /></ActuatorCurve><ActuatorCurve name="value" actuator="LHand" mute="0" unit="1"><Key frame="15" value="0.3068" /><Key frame="26" value="0.82" /><Key frame="36" value="0.68" /><Key frame="43" value="0.1" /></ActuatorCurve><ActuatorCurve name="value" actuator="LShoulderPitch" mute="0" unit="0"><Key frame="15" value="81.5611" /><Key frame="26" value="80.7701" /><Key frame="36" value="79.7154" /><Key frame="43" value="80.7701" /></ActuatorCurve><ActuatorCurve name="value" actuator="LShoulderRoll" mute="0" unit="0"><Key frame="15" value="18.4689" /><Key frame="26" value="25.6088" /><Key frame="36" value="12.4922" /><Key frame="43" value="8.27343" /></ActuatorCurve><ActuatorCurve name="value" actuator="LWristYaw" mute="0" unit="0"><Key frame="15" value="-23.8211" /><Key frame="26" value="-60.9993" /><Key frame="36" value="-33.4892" /><Key frame="43" value="-27.2488" /></ActuatorCurve><ActuatorCurve name="value" actuator="RElbowRoll" mute="0" unit="0"><Key frame="17" value="34.6318" /><Key frame="25" value="33.1376" /><Key frame="35" value="30.8524" /><Key frame="43" value="29.1825" /></ActuatorCurve><ActuatorCurve name="value" actuator="RElbowYaw" mute="0" unit="0"><Key frame="17" value="65.2827" /><Key frame="25" value="99.8242" /><Key frame="35" value="94.3749" /><Key frame="43" value="92.0018" /></ActuatorCurve><ActuatorCurve name="value" actuator="RHand" mute="0" unit="1"><Key frame="17" value="0.3068" /><Key frame="25" value="0.82" /><Key frame="35" value="0.68" /><Key frame="43" value="0.1" /></ActuatorCurve><ActuatorCurve name="value" actuator="RShoulderPitch" mute="0" unit="0"><Key frame="17" value="80.8628" /><Key frame="25" value="79.3686" /><Key frame="35" value="82.2691" /><Key frame="43" value="84.2906" /></ActuatorCurve><ActuatorCurve name="value" actuator="RShoulderRoll" mute="0" unit="0"><Key frame="17" value="-23.769" /><Key frame="25" value="-32.4312" /><Key frame="35" value="-22.0111" /><Key frame="43" value="-16.9134" /></ActuatorCurve><ActuatorCurve name="value" actuator="RWristYaw" mute="0" unit="0"><Key frame="17" value="22.3221" /><Key frame="25" value="46.0529" /><Key frame="35" value="17.9275" /><Key frame="43" value="11.4235" /></ActuatorCurve><ActuatorCurve name="value" actuator="HipPitch" mute="0" unit="0"><Key frame="14" value="-13.2285" /><Key frame="23" value="-1.4726" /><Key frame="29" value="-1.4726" /><Key frame="41" value="-14.6544" /></ActuatorCurve><ActuatorCurve name="value" actuator="HipRoll" mute="0" unit="0"><Key frame="14" value="-0.0194984" /><Key frame="23" value="-0.0194984" /><Key frame="29" value="-0.0194984" /></ActuatorCurve><ActuatorCurve name="value" actuator="KneePitch" mute="0" unit="0"><Key frame="14" value="4.14344" /><Key frame="23" value="-0.553875" /><Key frame="29" value="-0.553875" /><Key frame="41" value="6.57449" /></ActuatorCurve></ActuatorList></Timeline></Box><Box name="Move To" id="11" localization="8" tooltip="Make the robot move to a configured point relative to its current location." x="1491" y="288"><bitmap>media/images/box/movement/walk_forward.png</bitmap><script language="4"><content><![CDATA[
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self, False)
self.motion = ALProxy("ALMotion")
self.positionErrorThresholdPos = 0.01
self.positionErrorThresholdAng = 0.03
def onLoad(self):
pass
def onUnload(self):
self.motion.moveToward(0.0, 0.0, 0.0)
def onInput_onStart(self):
import almath
# The command position estimation will be set to the sensor position
# when the robot starts moving, so we use sensors first and commands later.
initPosition = almath.Pose2D(self.motion.getRobotPosition(True))
targetDistance = almath.Pose2D(self.getParameter("Distance X (m)"),
self.getParameter("Distance Y (m)"),
self.getParameter("Theta (deg)") * almath.PI / 180)
expectedEndPosition = initPosition * targetDistance
enableArms = self.getParameter("Arms movement enabled")
self.motion.setMoveArmsEnabled(enableArms, enableArms)
self.motion.moveTo(self.getParameter("Distance X (m)"),
self.getParameter("Distance Y (m)"),
self.getParameter("Theta (deg)") * almath.PI / 180)
# The move is finished so output
realEndPosition = almath.Pose2D(self.motion.getRobotPosition(False))
positionError = realEndPosition.diff(expectedEndPosition)
positionError.theta = almath.modulo2PI(positionError.theta)
if (abs(positionError.x) < self.positionErrorThresholdPos
and abs(positionError.y) < self.positionErrorThresholdPos
and abs(positionError.theta) < self.positionErrorThresholdAng):
self.onArrivedAtDestination()
else:
self.onStoppedBeforeArriving(positionError.toVector())
def onInput_onStop(self):
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onArrivedAtDestination" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when the robot arrives at its destination." id="4" /><Output name="onStoppedBeforeArriving" type="0" type_size="1" nature="1" inner="0" tooltip="Signal sent when the robot stops before arriving to its destination. Returns a vector [x (m), y (m), theta(rad)] with the remaining distance up to the destination. This distance is expressed in the ROBOT frame." id="5" /><Parameter name="Distance X (m)" inherits_from_parent="0" content_type="2" value="0" default_value="0.2" min="-5" max="10" tooltip="The distance in meters for forward/backward motion. Positive value&#x0A;means forward, negative value means backward." id="6" /><Parameter name="Distance Y (m)" inherits_from_parent="0" content_type="2" value="0.4" default_value="0" min="-5" max="5" tooltip="The distance in meters for lateral motion. Positive value means left, negative&#x0A;value means right." id="7" /><Parameter name="Theta (deg)" inherits_from_parent="0" content_type="2" value="0" default_value="0" min="-180" max="180" tooltip="The orientation in degrees for final rotation. Positive value means anticlockwise,&#x0A;negative value means clockwise." id="8" /><Parameter name="Arms movement enabled" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="Enables natural motion of the arms." id="9" /><Resource name="Legs" type="Lock" timeout="0" /></Box><Box name="Delay" id="14" localization="8" tooltip="Wait a moment before triggering the output. &#x0A;Can be stopped anytime. &#x0A;Multiple inputs will trigger multiple outputs." x="1618" y="289"><bitmap>media/images/box/wait.png</bitmap><script language="4"><content><![CDATA[class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self, False)
def onLoad(self):
self.delayed = []
def onUnload(self):
self.cancelDelays()
def cancelDelays(self):
cancel_list = list(self.delayed)
for d in cancel_list:
d.cancel()
def cleanDelay(self, fut, fut_ref):
self.delayed.remove(fut)
def triggerOutput(self):
self.timerOutput()
def onInput_onStart(self):
import qi
import functools
delay_future = qi.async(self.triggerOutput, delay=int(self.getParameter("Timeout (s)") * 1000 * 1000))
# keep the async operation in an array for cancel
# and remove it when it is finished in the callback
self.delayed.append(delay_future)
bound_clean = functools.partial(self.cleanDelay, delay_future)
delay_future.addCallback(bound_clean)
def onInput_onStop(self):
if self.getParameter("Trigger timerOutput if cancelled") and self.delayed:
self.timerOutput()
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Start the Delay box with the configured timeout value." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Stop the wait and stimulate the output." id="3" /><Output name="timerOutput" type="1" type_size="1" nature="1" inner="0" tooltip="Send a bang once delay set in parameters is elapsed, or if the box is stopped and the appropriate parameter is set." id="4" /><Parameter name="Timeout (s)" inherits_from_parent="0" content_type="2" value="5" default_value="1" min="0" max="5000" tooltip="Duration the box waits before stimulating the output." id="5" /><Parameter name="Trigger timerOutput if cancelled" inherits_from_parent="0" content_type="0" value="0" default_value="1" tooltip="If the box is currently delaying at least one signal and cancelled, output will be stimulated." id="6" /></Box><Box name="Move To (1)" id="12" localization="8" tooltip="Make the robot move to a configured point relative to its current location." x="1776" y="278"><bitmap>media/images/box/movement/walk_forward.png</bitmap><script language="4"><content><![CDATA[
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self, False)
self.motion = ALProxy("ALMotion")
self.positionErrorThresholdPos = 0.01
self.positionErrorThresholdAng = 0.03
def onLoad(self):
pass
def onUnload(self):
self.motion.moveToward(0.0, 0.0, 0.0)
def onInput_onStart(self):
import almath
# The command position estimation will be set to the sensor position
# when the robot starts moving, so we use sensors first and commands later.
initPosition = almath.Pose2D(self.motion.getRobotPosition(True))
targetDistance = almath.Pose2D(self.getParameter("Distance X (m)"),
self.getParameter("Distance Y (m)"),
self.getParameter("Theta (deg)") * almath.PI / 180)
expectedEndPosition = initPosition * targetDistance
enableArms = self.getParameter("Arms movement enabled")
self.motion.setMoveArmsEnabled(enableArms, enableArms)
self.motion.moveTo(self.getParameter("Distance X (m)"),
self.getParameter("Distance Y (m)"),
self.getParameter("Theta (deg)") * almath.PI / 180)
# The move is finished so output
realEndPosition = almath.Pose2D(self.motion.getRobotPosition(False))
positionError = realEndPosition.diff(expectedEndPosition)
positionError.theta = almath.modulo2PI(positionError.theta)
if (abs(positionError.x) < self.positionErrorThresholdPos
and abs(positionError.y) < self.positionErrorThresholdPos
and abs(positionError.theta) < self.positionErrorThresholdAng):
self.onArrivedAtDestination()
else:
self.onStoppedBeforeArriving(positionError.toVector())
def onInput_onStop(self):
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onArrivedAtDestination" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when the robot arrives at its destination." id="4" /><Output name="onStoppedBeforeArriving" type="0" type_size="1" nature="1" inner="0" tooltip="Signal sent when the robot stops before arriving to its destination. Returns a vector [x (m), y (m), theta(rad)] with the remaining distance up to the destination. This distance is expressed in the ROBOT frame." id="5" /><Parameter name="Distance X (m)" inherits_from_parent="0" content_type="2" value="0" default_value="0.2" min="-5" max="10" tooltip="The distance in meters for forward/backward motion. Positive value&#x0A;means forward, negative value means backward." id="6" /><Parameter name="Distance Y (m)" inherits_from_parent="0" content_type="2" value="-0.4" default_value="0" min="-5" max="5" tooltip="The distance in meters for lateral motion. Positive value means left, negative&#x0A;value means right." id="7" /><Parameter name="Theta (deg)" inherits_from_parent="0" content_type="2" value="0" default_value="0" min="-180" max="180" tooltip="The orientation in degrees for final rotation. Positive value means anticlockwise,&#x0A;negative value means clockwise." id="8" /><Parameter name="Arms movement enabled" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="Enables natural motion of the arms." id="9" /><Resource name="Legs" type="Lock" timeout="0" /></Box><Box name="Delay (1)" id="13" localization="8" tooltip="Wait a moment before triggering the output. &#x0A;Can be stopped anytime. &#x0A;Multiple inputs will trigger multiple outputs." x="1361" y="286"><bitmap>media/images/box/wait.png</bitmap><script language="4"><content><![CDATA[class MyClass(GeneratedClass):
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this Input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this Input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when Box behavior is finished." id="4" /><Parameter name="Voice shaping (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="150" tooltip='Used to modify at runtime the voice feature (tone, speed). In a slighty&#x0A;different way than pitch and speed, it gives a kind of &quot;gender or age&#x0A;modification&quot; effect.&#x0A;&#x0A;For instance, a quite good male derivation of female voice can be&#x0A;obtained setting this parameter to 78%.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the&#x0A;speed parameter. For example, if you want to decrease by 20% the voice&#x0A;shaping, you will have to increase by 20% the speed to keep a constant&#x0A;average speed.' id="5" /><Parameter name="Speed (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="200" tooltip="Changes the speed of the voice.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the voice&#x0A;shaping parameter. For example, if you want to increase by 20% the speed, you&#x0A;will have to decrease by 20% the voice shaping to keep a constant average&#x0A;speed." id="6" /><Parameter name="Text" inherits_from_parent="0" content_type="5" value="Come on in" default_value="" tooltip="The text you want to say. Don&apos;t forget to translate it!" id="7" /></Box><Box name="WideOpenBothHands_01" id="10" localization="8" tooltip="ID : #01C 0036&#x0A;&#x0A;===================&#x0A;&#x0A;Tags : &#x0A;-&#x0A;-&#x0A;&#x0A;===================&#x0A;&#x0A;Common dialog : Yes&#x0A;&#x0A;===================&#x0A;&#x0A;Start stance : Center&#x0A;End stance : Center" x="1660" y="244"><bitmap>media/images/box/movement/move.png</bitmap><script language="4"><content><![CDATA[]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Timeline enable="1" fps="25" start_frame="1" end_frame="-1" size="43"><ActuatorList model=""><ActuatorCurve name="value" actuator="HeadPitch" mute="0" unit="0"><Key frame="16" value="-4.60067" /><Key frame="26" value="-11.1925" /><Key frame="36" value="-16.1145" /><Key frame="42" value="-17.345" /></ActuatorCurve><ActuatorCurve name="value" actuator="HeadYaw" mute="0" unit="0"><Key frame="16" value="1.31597" /><Key frame="26" value="2.89802" /><Key frame="36" value="1.75543" /><Key frame="42" value="2.89802" /></ActuatorCurve><ActuatorCurve name="value" actuator="LElbowRoll" mute="0" unit="0"><Key frame="15" value="-37.3516" /><Key frame="26" value="-20.74" /><Key frame="36" value="-22.3221" /><Key frame="43" value="-20.8279" /></ActuatorCurve><ActuatorCurve name="value" actuator="LElbowYaw" mute="0" unit="0"><Key frame="15" value="-73.8245" /><Key frame="26" value="-91.7545" /><Key frame="36" value="-94.3033" /><Key frame="43" value="-91.7545" /></ActuatorCurve><ActuatorCurve name="value" actuator="LHand" mute="0" unit="1"><Key frame="15" value="0.3068" /><Key frame="26" value="0.82" /><Key frame="36" value="0.68" /><Key frame="43" value="0.1" /></ActuatorCurve><ActuatorCurve name="value" actuator="LShoulderPitch" mute="0" unit="0"><Key frame="15" value="81.5611" /><Key frame="26" value="80.7701" /><Key frame="36" value="79.7154" /><Key frame="43" value="80.7701" /></ActuatorCurve><ActuatorCurve name="value" actuator="LShoulderRoll" mute="0" unit="0"><Key frame="15" value="18.4689" /><Key frame="26" value="25.6088" /><Key frame="36" value="12.4922" /><Key frame="43" value="8.27343" /></ActuatorCurve><ActuatorCurve name="value" actuator="LWristYaw" mute="0" unit="0"><Key frame="15" value="-23.8211" /><Key frame="26" value="-60.9993" /><Key frame="36" value="-33.4892" /><Key frame="43" value="-27.2488" /></ActuatorCurve><ActuatorCurve name="value" actuator="RElbowRoll" mute="0" unit="0"><Key frame="17" value="34.6318" /><Key frame="25" value="33.1376" /><Key frame="35" value="30.8524" /><Key frame="43" value="29.1825" /></ActuatorCurve><ActuatorCurve name="value" actuator="RElbowYaw" mute="0" unit="0"><Key frame="17" value="65.2827" /><Key frame="25" value="99.8242" /><Key frame="35" value="94.3749" /><Key frame="43" value="92.0018" /></ActuatorCurve><ActuatorCurve name="value" actuator="RHand" mute="0" unit="1"><Key frame="17" value="0.3068" /><Key frame="25" value="0.82" /><Key frame="35" value="0.68" /><Key frame="43" value="0.1" /></ActuatorCurve><ActuatorCurve name="value" actuator="RShoulderPitch" mute="0" unit="0"><Key frame="17" value="80.8628" /><Key frame="25" value="79.3686" /><Key frame="35" value="82.2691" /><Key frame="43" value="84.2906" /></ActuatorCurve><ActuatorCurve name="value" actuator="RShoulderRoll" mute="0" unit="0"><Key frame="17" value="-23.769" /><Key frame="25" value="-32.4312" /><Key frame="35" value="-22.0111" /><Key frame="43" value="-16.9134" /></ActuatorCurve><ActuatorCurve name="value" actuator="RWristYaw" mute="0" unit="0"><Key frame="17" value="22.3221" /><Key frame="25" value="46.0529" /><Key frame="35" value="17.9275" /><Key frame="43" value="11.4235" /></ActuatorCurve><ActuatorCurve name="value" actuator="HipPitch" mute="0" unit="0"><Key frame="14" value="-13.2285" /><Key frame="23" value="-1.4726" /><Key frame="29" value="-1.4726" /><Key frame="41" value="-14.6544" /></ActuatorCurve><ActuatorCurve name="value" actuator="HipRoll" mute="0" unit="0"><Key frame="14" value="-0.0194984" /><Key frame="23" value="-0.0194984" /><Key frame="29" value="-0.0194984" /></ActuatorCurve><ActuatorCurve name="value" actuator="KneePitch" mute="0" unit="0"><Key frame="14" value="4.14344" /><Key frame="23" value="-0.553875" /><Key frame="29" value="-0.553875" /><Key frame="41" value="6.57449" /></ActuatorCurve></ActuatorList></Timeline></Box><Box name="Delay (1)" id="13" localization="8" tooltip="Wait a moment before triggering the output. &#x0A;Can be stopped anytime. &#x0A;Multiple inputs will trigger multiple outputs." x="1502" y="282"><bitmap>media/images/box/wait.png</bitmap><script language="4"><content><![CDATA[class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self, False)
......@@ -641,7 +432,7 @@ class MyClass(GeneratedClass):
def onInput_onStop(self):
if self.getParameter("Trigger timerOutput if cancelled") and self.delayed:
self.timerOutput()
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Start the Delay box with the configured timeout value." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Stop the wait and stimulate the output." id="3" /><Output name="timerOutput" type="1" type_size="1" nature="1" inner="0" tooltip="Send a bang once delay set in parameters is elapsed, or if the box is stopped and the appropriate parameter is set." id="4" /><Parameter name="Timeout (s)" inherits_from_parent="0" content_type="2" value="1" default_value="1" min="0" max="5000" tooltip="Duration the box waits before stimulating the output." id="5" /><Parameter name="Trigger timerOutput if cancelled" inherits_from_parent="0" content_type="0" value="0" default_value="1" tooltip="If the box is currently delaying at least one signal and cancelled, output will be stimulated." id="6" /></Box><Box name="Say (2)" id="15" localization="8" tooltip="Say some text. The text can be localized." x="1218" y="104"><bitmap>media/images/box/interaction/say.png</bitmap><script language="4"><content><![CDATA[import time
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Start the Delay box with the configured timeout value." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Stop the wait and stimulate the output." id="3" /><Output name="timerOutput" type="1" type_size="1" nature="1" inner="0" tooltip="Send a bang once delay set in parameters is elapsed, or if the box is stopped and the appropriate parameter is set." id="4" /><Parameter name="Timeout (s)" inherits_from_parent="0" content_type="2" value="1" default_value="1" min="0" max="5000" tooltip="Duration the box waits before stimulating the output." id="5" /><Parameter name="Trigger timerOutput if cancelled" inherits_from_parent="0" content_type="0" value="0" default_value="1" tooltip="If the box is currently delaying at least one signal and cancelled, output will be stimulated." id="6" /></Box><Box name="Say (2)" id="15" localization="8" tooltip="Say some text. The text can be localized." x="1206" y="160"><bitmap>media/images/box/interaction/say.png</bitmap><script language="4"><content><![CDATA[import time
class MyClass(GeneratedClass):
def __init__(self):
......@@ -682,7 +473,7 @@ class MyClass(GeneratedClass):
self.bIsRunning = False
def onInput_onStop(self):
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this Input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this Input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when Box behavior is finished." id="4" /><Parameter name="Voice shaping (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="150" tooltip='Used to modify at runtime the voice feature (tone, speed). In a slighty&#x0A;different way than pitch and speed, it gives a kind of &quot;gender or age&#x0A;modification&quot; effect.&#x0A;&#x0A;For instance, a quite good male derivation of female voice can be&#x0A;obtained setting this parameter to 78%.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the&#x0A;speed parameter. For example, if you want to decrease by 20% the voice&#x0A;shaping, you will have to increase by 20% the speed to keep a constant&#x0A;average speed.' id="5" /><Parameter name="Speed (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="200" tooltip="Changes the speed of the voice.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the voice&#x0A;shaping parameter. For example, if you want to increase by 20% the speed, you&#x0A;will have to decrease by 20% the voice shaping to keep a constant average&#x0A;speed." id="6" /><Parameter name="Text" inherits_from_parent="0" content_type="5" value="ID please" default_value="" tooltip="The text you want to say. Don&apos;t forget to translate it!" id="7" /></Box><Box name="Red Ball Tracker" id="16" localization="-1" tooltip="This box makes the robot track a red ball with different modes." x="1366" y="82"><bitmap>media/images/box/tracker/tracker.png</bitmap><script language="4"><content><![CDATA[import time
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this Input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this Input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when Box behavior is finished." id="4" /><Parameter name="Voice shaping (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="150" tooltip='Used to modify at runtime the voice feature (tone, speed). In a slighty&#x0A;different way than pitch and speed, it gives a kind of &quot;gender or age&#x0A;modification&quot; effect.&#x0A;&#x0A;For instance, a quite good male derivation of female voice can be&#x0A;obtained setting this parameter to 78%.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the&#x0A;speed parameter. For example, if you want to decrease by 20% the voice&#x0A;shaping, you will have to increase by 20% the speed to keep a constant&#x0A;average speed.' id="5" /><Parameter name="Speed (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="200" tooltip="Changes the speed of the voice.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the voice&#x0A;shaping parameter. For example, if you want to increase by 20% the speed, you&#x0A;will have to decrease by 20% the voice shaping to keep a constant average&#x0A;speed." id="6" /><Parameter name="Text" inherits_from_parent="0" content_type="5" value="ID please" default_value="" tooltip="The text you want to say. Don&apos;t forget to translate it!" id="7" /></Box><Box name="Red Ball Tracker" id="16" localization="-1" tooltip="This box makes the robot track a red ball with different modes." x="1356" y="137"><bitmap>media/images/box/tracker/tracker.png</bitmap><script language="4"><content><![CDATA[import time
class MyClass(GeneratedClass):
def __init__(self):
......@@ -813,7 +604,7 @@ class MyClass(GeneratedClass):
elif value != self.targetName and self.subscribeDone:
self.memory.unsubscribeToEvent("ALTracker/TargetLost", self.getName())
self.memory.unsubscribeToEvent("ALTracker/TargetReached", self.getName())
self.subscribeDone = False]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Output name="targetLost" type="1" type_size="1" nature="2" inner="0" tooltip="Signal sent when the target is lost." id="5" /><Output name="targetReached" type="1" type_size="1" nature="2" inner="0" tooltip="Signal sent when the target is reached." id="6" /><Parameter name="Mode" inherits_from_parent="0" content_type="3" value="Head" default_value="Head" custom_choice="0" tooltip="Set tracker mode" id="7"><Choice value="Head" /><Choice value="WholeBody" /><Choice value="Move" /></Parameter><Parameter name="Effector" inherits_from_parent="0" content_type="3" value="None" default_value="None" custom_choice="0" tooltip="Set effector to use for tracking. Head is always used." id="8"><Choice value="None" /><Choice value="Arms" /><Choice value="LArm" /><Choice value="RArm" /></Parameter><Parameter name="Diameter (m)" inherits_from_parent="0" content_type="2" value="0.06" default_value="0.06" min="0.01" max="1" tooltip="Diameter of the ball in meters." id="9" /><Parameter name="Distance X (m)" inherits_from_parent="0" content_type="2" value="0.3" default_value="0.3" min="0.01" max="5" tooltip="Distance on X axis the robot will try to maintain from its target in move modes." id="10" /><Parameter name="Threshold X (m)" inherits_from_parent="0" content_type="2" value="0.1" default_value="0.1" min="0.01" max="1" tooltip="Threshold above which the robot will move to track its target in move modes." id="11" /><Parameter name="Distance Y (m)" inherits_from_parent="0" content_type="2" value="0" default_value="0" min="-5" max="5" tooltip="Distance on X axis the robot will try to maintain from its target in move modes." id="12" /><Parameter name="Threshold Y (m)" inherits_from_parent="0" content_type="2" value="0.1" default_value="0.1" min="0" max="1" tooltip="Threshold above which the robot will move to track its target in move modes." id="13" /><Parameter name="Theta (rad)" inherits_from_parent="0" content_type="2" value="0" default_value="0" min="-3.14" max="3.14" tooltip="Wz angle of the vector robot-target the robot will try to maintain in move modes." id="14" /><Parameter name="Threshold Theta (rad)" inherits_from_parent="0" content_type="2" value="0.3" default_value="0.3" min="0" max="3.14" tooltip="Threshold of the angle of the vector robot-target above which the robot will move to track its target in move modes." id="15" /></Box><Box name="Say (3)" id="17" localization="8" tooltip="Say some text. The text can be localized." x="1528" y="24"><bitmap>media/images/box/interaction/say.png</bitmap><script language="4"><content><![CDATA[import time
self.subscribeDone = False]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Output name="targetLost" type="1" type_size="1" nature="2" inner="0" tooltip="Signal sent when the target is lost." id="5" /><Output name="targetReached" type="1" type_size="1" nature="2" inner="0" tooltip="Signal sent when the target is reached." id="6" /><Parameter name="Mode" inherits_from_parent="0" content_type="3" value="Head" default_value="Head" custom_choice="0" tooltip="Set tracker mode" id="7"><Choice value="Head" /><Choice value="WholeBody" /><Choice value="Move" /></Parameter><Parameter name="Effector" inherits_from_parent="0" content_type="3" value="None" default_value="None" custom_choice="0" tooltip="Set effector to use for tracking. Head is always used." id="8"><Choice value="None" /><Choice value="Arms" /><Choice value="LArm" /><Choice value="RArm" /></Parameter><Parameter name="Diameter (m)" inherits_from_parent="0" content_type="2" value="0.06" default_value="0.06" min="0.01" max="1" tooltip="Diameter of the ball in meters." id="9" /><Parameter name="Distance X (m)" inherits_from_parent="0" content_type="2" value="0.3" default_value="0.3" min="0.01" max="5" tooltip="Distance on X axis the robot will try to maintain from its target in move modes." id="10" /><Parameter name="Threshold X (m)" inherits_from_parent="0" content_type="2" value="0.1" default_value="0.1" min="0.01" max="1" tooltip="Threshold above which the robot will move to track its target in move modes." id="11" /><Parameter name="Distance Y (m)" inherits_from_parent="0" content_type="2" value="0" default_value="0" min="-5" max="5" tooltip="Distance on X axis the robot will try to maintain from its target in move modes." id="12" /><Parameter name="Threshold Y (m)" inherits_from_parent="0" content_type="2" value="0.1" default_value="0.1" min="0" max="1" tooltip="Threshold above which the robot will move to track its target in move modes." id="13" /><Parameter name="Theta (rad)" inherits_from_parent="0" content_type="2" value="0" default_value="0" min="-3.14" max="3.14" tooltip="Wz angle of the vector robot-target the robot will try to maintain in move modes." id="14" /><Parameter name="Threshold Theta (rad)" inherits_from_parent="0" content_type="2" value="0.3" default_value="0.3" min="0" max="3.14" tooltip="Threshold of the angle of the vector robot-target above which the robot will move to track its target in move modes." id="15" /></Box><Box name="Say (3)" id="17" localization="8" tooltip="Say some text. The text can be localized." x="1516" y="104"><bitmap>media/images/box/interaction/say.png</bitmap><script language="4"><content><![CDATA[import time
class MyClass(GeneratedClass):
def __init__(self):
......@@ -854,7 +645,7 @@ class MyClass(GeneratedClass):
self.bIsRunning = False
def onInput_onStop(self):
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this Input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this Input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when Box behavior is finished." id="4" /><Parameter name="Voice shaping (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="150" tooltip='Used to modify at runtime the voice feature (tone, speed). In a slighty&#x0A;different way than pitch and speed, it gives a kind of &quot;gender or age&#x0A;modification&quot; effect.&#x0A;&#x0A;For instance, a quite good male derivation of female voice can be&#x0A;obtained setting this parameter to 78%.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the&#x0A;speed parameter. For example, if you want to decrease by 20% the voice&#x0A;shaping, you will have to increase by 20% the speed to keep a constant&#x0A;average speed.' id="5" /><Parameter name="Speed (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="200" tooltip="Changes the speed of the voice.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the voice&#x0A;shaping parameter. For example, if you want to increase by 20% the speed, you&#x0A;will have to decrease by 20% the voice shaping to keep a constant average&#x0A;speed." id="6" /><Parameter name="Text" inherits_from_parent="0" content_type="5" value="No ID, you need to leave" default_value="" tooltip="The text you want to say. Don&apos;t forget to translate it!" id="7" /></Box><Box name="Point At" id="18" localization="-1" tooltip="This box makes the robot point to a desired position." x="1658" y="26"><bitmap>media/images/box/movement/move_arm.png</bitmap><script language="4"><content><![CDATA[import time
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this Input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this Input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when Box behavior is finished." id="4" /><Parameter name="Voice shaping (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="150" tooltip='Used to modify at runtime the voice feature (tone, speed). In a slighty&#x0A;different way than pitch and speed, it gives a kind of &quot;gender or age&#x0A;modification&quot; effect.&#x0A;&#x0A;For instance, a quite good male derivation of female voice can be&#x0A;obtained setting this parameter to 78%.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the&#x0A;speed parameter. For example, if you want to decrease by 20% the voice&#x0A;shaping, you will have to increase by 20% the speed to keep a constant&#x0A;average speed.' id="5" /><Parameter name="Speed (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="200" tooltip="Changes the speed of the voice.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the voice&#x0A;shaping parameter. For example, if you want to increase by 20% the speed, you&#x0A;will have to decrease by 20% the voice shaping to keep a constant average&#x0A;speed." id="6" /><Parameter name="Text" inherits_from_parent="0" content_type="5" value="No ID, you need to leave" default_value="" tooltip="The text you want to say. Don&apos;t forget to translate it!" id="7" /></Box><Box name="Point At" id="18" localization="-1" tooltip="This box makes the robot point to a desired position." x="1646" y="101"><bitmap>media/images/box/movement/move_arm.png</bitmap><script language="4"><content><![CDATA[import time
class MyClass(GeneratedClass):
def __init__(self):
......@@ -937,4 +728,181 @@ class MyClass(GeneratedClass):
elif newValue == "World":
self.frame = 1
elif newValue == "Robot":
self.frame = 2]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Parameter name="X (m)" inherits_from_parent="0" content_type="2" value="1" default_value="1" min="0.001" max="10" tooltip="X coordinate of the target to point at." id="5" /><Parameter name="Y (m)" inherits_from_parent="0" content_type="2" value="0.5" default_value="0" min="-10" max="10" tooltip="Y coordinate of the target to point at." id="6" /><Parameter name="Z (m)" inherits_from_parent="0" content_type="2" value="1" default_value="0" min="-10" max="10" tooltip="Z coordinate of the target to point at." id="7" /><Parameter name="Speed (%)" inherits_from_parent="0" content_type="1" value="50" default_value="50" min="1" max="100" tooltip="Speed to look at the desired position" id="8" /><Parameter name="Effector" inherits_from_parent="0" content_type="3" value="Arms" default_value="Arms" custom_choice="0" tooltip="Effector to use" id="9"><Choice value="Arms" /><Choice value="LArm" /><Choice value="RArm" /></Parameter><Parameter name="Frame" inherits_from_parent="0" content_type="3" value="Torso" default_value="Torso" custom_choice="0" tooltip="Select the frame of target." id="10"><Choice value="Torso" /><Choice value="World" /><Choice value="Robot" /></Parameter></Box><Link inputowner="2" indexofinput="2" outputowner="0" indexofoutput="2" /><Link inputowner="4" indexofinput="2" outputowner="2" indexofoutput="4" /><Link inputowner="3" indexofinput="2" outputowner="4" indexofoutput="5" /><Link inputowner="6" indexofinput="2" outputowner="3" indexofoutput="4" /><Link inputowner="7" indexofinput="2" outputowner="3" indexofoutput="4" /><Link inputowner="1" indexofinput="2" outputowner="4" indexofoutput="6" /><Link inputowner="5" indexofinput="2" outputowner="1" indexofoutput="6" /><Link inputowner="8" indexofinput="2" outputowner="5" indexofoutput="4" /><Link inputowner="9" indexofinput="2" outputowner="8" indexofoutput="4" /><Link inputowner="10" indexofinput="2" outputowner="8" indexofoutput="4" /><Link inputowner="14" indexofinput="2" outputowner="11" indexofoutput="4" /><Link inputowner="12" indexofinput="2" outputowner="14" indexofoutput="4" /><Link inputowner="0" indexofinput="4" outputowner="12" indexofoutput="4" /><Link inputowner="13" indexofinput="2" outputowner="8" indexofoutput="4" /><Link inputowner="11" indexofinput="2" outputowner="13" indexofoutput="4" /><Link inputowner="15" indexofinput="2" outputowner="8" indexofoutput="3" /><Link inputowner="16" indexofinput="2" outputowner="15" indexofoutput="4" /><Link inputowner="4" indexofinput="2" outputowner="6" indexofoutput="4" /><Link inputowner="17" indexofinput="2" outputowner="16" indexofoutput="5" /><Link inputowner="17" indexofinput="2" outputowner="16" indexofoutput="4" /><Link inputowner="18" indexofinput="2" outputowner="17" indexofoutput="4" /><Link inputowner="0" indexofinput="4" outputowner="18" indexofoutput="4" /><Link inputowner="13" indexofinput="2" outputowner="16" indexofoutput="6" /><Link inputowner="1" indexofinput="2" outputowner="5" indexofoutput="5" /></Diagram></BehaviorKeyframe></BehaviorLayer></Timeline></Box></ChoregrapheProject>
\ No newline at end of file
self.frame = 2]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Parameter name="X (m)" inherits_from_parent="0" content_type="2" value="1" default_value="1" min="0.001" max="10" tooltip="X coordinate of the target to point at." id="5" /><Parameter name="Y (m)" inherits_from_parent="0" content_type="2" value="0.5" default_value="0" min="-10" max="10" tooltip="Y coordinate of the target to point at." id="6" /><Parameter name="Z (m)" inherits_from_parent="0" content_type="2" value="1" default_value="0" min="-10" max="10" tooltip="Z coordinate of the target to point at." id="7" /><Parameter name="Speed (%)" inherits_from_parent="0" content_type="1" value="50" default_value="50" min="1" max="100" tooltip="Speed to look at the desired position" id="8" /><Parameter name="Effector" inherits_from_parent="0" content_type="3" value="Arms" default_value="Arms" custom_choice="0" tooltip="Effector to use" id="9"><Choice value="Arms" /><Choice value="LArm" /><Choice value="RArm" /></Parameter><Parameter name="Frame" inherits_from_parent="0" content_type="3" value="Torso" default_value="Torso" custom_choice="0" tooltip="Select the frame of target." id="10"><Choice value="Torso" /><Choice value="World" /><Choice value="Robot" /></Parameter></Box><Box name="Say (4)" id="11" localization="8" tooltip="Say some text. The text can be localized." x="292" y="220"><bitmap>media/images/box/interaction/say.png</bitmap><script language="4"><content><![CDATA[import time
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self, False)
self.tts = ALProxy('ALTextToSpeech')
self.ttsStop = ALProxy('ALTextToSpeech', True) #Create another proxy as wait is blocking if audioout is remote
def onLoad(self):
self.bIsRunning = False
self.ids = []
def onUnload(self):
for id in self.ids:
try:
self.ttsStop.stop(id)
except:
pass
while( self.bIsRunning ):
time.sleep( 0.2 )
def onInput_onStart(self):
self.bIsRunning = True
try:
sentence = "\RSPD="+ str( self.getParameter("Speed (%)") ) + "\ "
sentence += "\VCT="+ str( self.getParameter("Voice shaping (%)") ) + "\ "
sentence += self.getParameter("Text")
sentence += "\RST\ "
id = self.tts.post.say(str(sentence))
self.ids.append(id)
self.tts.wait(id, 0)
finally:
try:
self.ids.remove(id)
except:
pass
if( self.ids == [] ):
self.onStopped() # activate output of the box
self.bIsRunning = False
def onInput_onStop(self):
self.onUnload()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when Diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Box behavior starts when a signal is received on this Input." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Box behavior stops when a signal is received on this Input." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when Box behavior is finished." id="4" /><Parameter name="Voice shaping (%)" inherits_from_parent="1" content_type="1" value="117" default_value="100" min="50" max="150" tooltip='Used to modify at runtime the voice feature (tone, speed). In a slighty&#x0A;different way than pitch and speed, it gives a kind of &quot;gender or age&#x0A;modification&quot; effect.&#x0A;&#x0A;For instance, a quite good male derivation of female voice can be&#x0A;obtained setting this parameter to 78%.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the&#x0A;speed parameter. For example, if you want to decrease by 20% the voice&#x0A;shaping, you will have to increase by 20% the speed to keep a constant&#x0A;average speed.' id="5" /><Parameter name="Speed (%)" inherits_from_parent="1" content_type="1" value="100" default_value="100" min="50" max="200" tooltip="Changes the speed of the voice.&#x0A;&#x0A;Note: For a better effect, you can compensate this parameter with the voice&#x0A;shaping parameter. For example, if you want to increase by 20% the speed, you&#x0A;will have to decrease by 20% the voice shaping to keep a constant average&#x0A;speed." id="6" /><Parameter name="Text" inherits_from_parent="0" content_type="5" value="Hello" default_value="" tooltip="The text you want to say. Don&apos;t forget to translate it!" id="7" /></Box><Box name="Basic Awareness" id="4" localization="8" tooltip="This box is an interface to the module ALBasicAwareness.&#x0A;&#x0A;It is a simple way to make the robot establish and keep eye contact with people.&#x0A;&#x0A;V1.1.0" x="454" y="234"><bitmap>media/images/box/tracker/basicawareness.png</bitmap><script language="4"><content><![CDATA[class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
#put initialization code here
try:
self.awareness = ALProxy('ALBasicAwareness')
except Exception as e:
self.awareness = None
self.logger.error(e)
self.memory = ALProxy('ALMemory')
self.isRunning = False
self.trackedHuman = -1
import threading
self.subscribingLock = threading.Lock()
self.BIND_PYTHON(self.getName(), "setParameter")
def onUnload(self):
if self.isRunning:
if self.awareness:
self.awareness.stopAwareness()
self.setALMemorySubscription(False)
self.isRunning = False
def onInput_onStart(self):
if self.isRunning:
return # already running, nothing to do
self.isRunning = True
self.trackedHuman = -1
if self.awareness:
self.awareness.setEngagementMode(self.getParameter('Engagement Mode'))
self.awareness.setTrackingMode(self.getParameter('Tracking Mode'))
self.awareness.setStimulusDetectionEnabled('Sound', self.getParameter('Sound Stimulus'))
self.awareness.setStimulusDetectionEnabled('Movement', self.getParameter('Movement Stimulus'))
self.awareness.setStimulusDetectionEnabled('People', self.getParameter('People Stimulus'))
self.awareness.setStimulusDetectionEnabled('Touch', self.getParameter('Touch Stimulus'))
self.setALMemorySubscription(True)
self.awareness.startAwareness()
def onInput_onStop(self):
if not self.isRunning:
return # already stopped, nothing to do
self.onUnload()
self.onStopped()
def setParameter(self, parameterName, newValue):
GeneratedClass.setParameter(self, parameterName, newValue)
if self.awareness:
if parameterName == 'Sound Stimulus':
self.awareness.setStimulusDetectionEnabled('Sound', newValue)
elif parameterName == 'Movement Stimulus':
self.awareness.setStimulusDetectionEnabled('Movement', newValue)
elif parameterName == 'People Stimulus':
self.awareness.setStimulusDetectionEnabled('People', newValue)
elif parameterName == 'Touch Stimulus':
self.awareness.setStimulusDetectionEnabled('Touch', newValue)
# callbacks for ALBasicAwareness events
def onStimulusDetected(self, eventName, stimulusName, subscriberIdentifier):
self.StimulusDetected(stimulusName)
def onHumanTracked(self, eventName, humanID, subscriberIdentifier):
self.trackedHuman = humanID
self.HumanTracked(humanID)
def onHumanLost(self, eventName, subscriberIdentifier):
self.HumanLost(self.trackedHuman)
self.trackedHuman = -1
def setALMemorySubscription(self, subscribe):
self.subscribingLock.acquire()
if subscribe:
self.memory.subscribeToEvent('ALBasicAwareness/StimulusDetected', self.getName(), 'onStimulusDetected')
self.memory.subscribeToEvent('ALBasicAwareness/HumanTracked', self.getName(), 'onHumanTracked')
self.memory.subscribeToEvent('ALBasicAwareness/HumanLost', self.getName(), 'onHumanLost')
else:
self.memory.unsubscribeToEvent('ALBasicAwareness/StimulusDetected', self.getName())
self.memory.unsubscribeToEvent('ALBasicAwareness/HumanTracked', self.getName())
self.memory.unsubscribeToEvent('ALBasicAwareness/HumanLost', self.getName())
self.subscribingLock.release()]]></content></script><Input name="onLoad" type="1" type_size="1" nature="0" inner="1" tooltip="Signal sent when diagram is loaded." id="1" /><Input name="onStart" type="1" type_size="1" nature="2" inner="0" tooltip="Starts the Basic Awareness with the given Engagement and Tracking mode parameters, using the given stimuli." id="2" /><Input name="onStop" type="1" type_size="1" nature="3" inner="0" tooltip="Stops the Basic Awareness." id="3" /><Output name="onStopped" type="1" type_size="1" nature="1" inner="0" tooltip="Signal sent when box behavior is finished." id="4" /><Output name="StimulusDetected" type="3" type_size="1" nature="2" inner="0" tooltip="This output is stimulated when BasicAwareness detects a stimulus amongst the tracked stimulus.&#x0A;&#x0A;The output data is the stimulus&apos; name." id="5" /><Output name="HumanTracked" type="2" type_size="1" nature="2" inner="0" tooltip="This output is triggered when ALBasicAwareness detects a stimulus that is confirmed to be a human.&#x0A;&#x0A;The output data is the ID corresponding to the tracked human. It is shared with PeoplePerception and can be used there. This output is triggered with -1 if ALBasicAwareness tried to detect a human but failed." id="6" /><Output name="HumanLost" type="2" type_size="1" nature="2" inner="0" tooltip="This output is triggered when the human currently tracked is lost.&#x0A;&#x0A; The output data is the ID corresponding to the lost human. It can be reused in PeoplePerception." id="7" /><Parameter name="Engagement Mode" inherits_from_parent="0" content_type="3" value="SemiEngaged" default_value="Unengaged" custom_choice="0" tooltip='The engagement mode specifies how &quot;focused&quot; the robot is on the engaged person.' id="8"><Choice value="Unengaged" /><Choice value="FullyEngaged" /><Choice value="SemiEngaged" /></Parameter><Parameter name="Tracking Mode" inherits_from_parent="0" content_type="3" value="Head" default_value="Head" custom_choice="0" tooltip="The tracking mode describes how the robot keeps eye contact with an engaged person." id="9"><Choice value="Head" /><Choice value="BodyRotation" /><Choice value="WholeBody" /></Parameter><Parameter name="Sound Stimulus" inherits_from_parent="0" content_type="0" value="0" default_value="1" tooltip="" id="10" /><Parameter name="Movement Stimulus" inherits_from_parent="0" content_type="0" value="0" default_value="1" tooltip="" id="11" /><Parameter name="People Stimulus" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="12" /><Parameter name="Touch Stimulus" inherits_from_parent="0" content_type="0" value="1" default_value="1" tooltip="" id="13" /></Box><Box name="Say Text" id="12" localization="8" tooltip="Say the text received on its input." x="1022" y="423"><bitmap>media/images/box/interaction/say.png</bitmap><script language="4"><content><![CDATA[import time
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self, False)