-
Notifications
You must be signed in to change notification settings - Fork 15
pyPNP
Luca Iocchi edited this page Apr 25, 2018
·
3 revisions
pyPNP
is a Python module that allows for integration of execution of PNP in Python.
pyPNP
is platform and middleware independent and has interfaces for both ROS and Naoqi. Thus it can be used to write high-level programs combining Python and PNP for any robot.
- Full update PetriNetPlans libraries (including PNPgen, PNPros and/or PNPNaoqi)
- Set environment variable
PNP_HOME
to your PetriNetPlans folder - Add path
$PNP_HOME/pyPNP
to environment variablePYTHONPATH
e.g.
export PYTHONPATH=$PNP_HOME/pyPNP:$PYTHONPATH
- Run action servers (either ROS PNPActionServer or Naoqi action servers)
- Execute a pyPNP Python script as in the following example
import sys, os
# For ROS action servers
sys.path.insert(0, os.getenv('PNP_HOME')+'/PNPros/ROS_bridge/pnp_ros/py')
import pnp_cmd_ros
from pnp_cmd_ros import *
# For Naoqi action servers use the following lines instead
#sys.path.insert(0, os.getenv('PNP_HOME')+'/PNPnaoqi/py')
#import pnp_cmd_naoqi
#from pnp_cmd_naoqi import *
p = PNPCmd()
p.begin()
p.exec_action('say', 'hello')
for i in range(4):
p.exec_action('turn', '90', interrupt='obstacle', recovery='waitfor_not_obstacle; restart_action')
p.exec_action('say', 'hello')
while (not p.get_condition('personhere')):
time.sleep(0.5)
p.exec_action('followperson', '', interrupt='stopfollow', recovery='skip_action')
p.plan_cmd('cocktail_party', 'start')
while (not p.get_condition('stopplan')):
time.sleep(1)
p.plan_cmd('cocktail_party', 'stop')
p.exec_action('say', 'goodbye')
p.exec_action('goto', 'exit')
p.end()