10 homeoPortName=
"/manager/toHomeostasis/rpc"+
":o" 11 toHomeo.open(homeoPortName)
14 alloPortName=
"/manager/toAllostasis/rpc"+
":o" 15 toAllo.open(alloPortName)
18 BMPortName=
"/manager/BehaviorManager/rpc"+
":o" 21 toPlanner = yarp.Port()
22 plannerPortName=
"/manager/toPlanner/rpc:o" 23 toPlanner.open(plannerPortName)
25 homeoRPC =
"/homeostasis/rpc" 26 alloRPC =
"/AllostaticController/rpc" 27 BMRPC =
"/BehaviorManager/rpc" 28 plannerRPC =
"/planner/rpc" 30 print yarp.Network.connect(homeoPortName,homeoRPC)
31 print yarp.Network.connect(alloPortName,alloRPC)
32 print yarp.Network.connect(BMPortName,BMRPC)
33 print yarp.Network.connect(plannerPortName,plannerRPC)
39 cmd.addString(
'names')
40 toHomeo.write(cmd,rply)
41 driveList = rply.toString().strip(
'()').split(
' ')
49 cmd.addString(
'names')
51 behList = rply.toString().strip(
'()').split(
' ')
56 print "Interrupting and closing ports" 73 cmd.addString(
'force')
74 cmd.addString(behavior)
75 cmd.addString(
'bottom')
77 if not yarp.Network.isConnected(homeoPortName,homeoRPC):
78 print yarp.Network.connect(homeoPortName,homeoRPC)
90 cmd.addString(behavior)
92 if not yarp.Network.isConnected(BMPortName,BMRPC):
93 print yarp.Network.connect(BMPortName,BMRPC)
103 cmd.addString(
'freeze')
106 if not yarp.Network.isConnected(homeoPortName,homeoRPC):
107 print yarp.Network.connect(homeoPortName,homeoRPC)
115 cmd.addString(
'unfreeze')
118 if not yarp.Network.isConnected(homeoPortName,homeoRPC):
119 print yarp.Network.connect(homeoPortName,homeoRPC)
129 cmd.addString(
'reset')
131 if not yarp.Network.isConnected(homeoPortName,homeoRPC):
132 print yarp.Network.connect(homeoPortName,homeoRPC)
150 cmd_allo = yarp.Bottle()
152 cmd_allo.addString(
'manual')
153 cmd_allo.addString(
'on')
155 if not yarp.Network.isConnected(alloPortName,alloRPC):
156 print yarp.Network.connect(alloPortName,alloRPC)
158 toAllo.write(cmd_allo)
161 cmd_planner = yarp.Bottle()
163 cmd_planner.addString(
'manual')
164 cmd_planner.addString(
'on')
165 if not yarp.Network.isConnected(plannerPortName,plannerRPC):
166 print yarp.Network.connect(plannerPortName,plannerRPC)
168 toPlanner.write(cmd_planner)
180 cmd.addString(
'manual')
183 if not yarp.Network.isConnected(alloPortName,alloRPC):
184 print yarp.Network.connect(alloPortName,alloRPC)
189 cmd_planner = yarp.Bottle()
191 cmd_planner.addString(
'manual')
192 cmd_planner.addString(
'off')
193 if not yarp.Network.isConnected(plannerPortName,plannerRPC):
194 print yarp.Network.connect(plannerPortName,plannerRPC)
196 toPlanner.write(cmd_planner)
def launch_behavior(behavior)
def trigger_behavior(behavior)