pythonphpnao-robotchoregraphe

PHP shell_exec with python naoqi: "qimessaging.socketcache: No more endpoints available after filtering"


I can't seem to get my python script to work when I execute it in PHP with shell_exec

I am using the virtual robot in choregraphe

Here is my code: PHP

$command = escapeshellcmd("python test.py");
$output = shell_exec ($command);
echo $output;

Python:

from naoqi import ALProxy
import os,sys
import motion

#import qi.logging
#qi.logging.setLevel(qi.logging.FATAL)

pFractionMaxSpeed=0.4
mp = ALProxy("ALMotion", "127.0.0.1",51712)
JointName = JointNames = ["LShoulderRoll","LShoulderPitch","LElbowYaw","LElbowRoll","LHand"]
Arm1 = [90,0,-90,-85,90]
Arm1 = [ x * motion.TO_RAD for x in Arm1]
mp.post.angleInterpolationWithSpeed(JointNames, Arm1, pFractionMaxSpeed)

If I just run the python through cmd, then it works fine and makes the robot move.

I think it has something to do with that it is run as the www-data user and it messes the naoqi modules up (or something along those lines): link

I am just not sure how to do it in windows with XAMPP or WAMP


Solution

  • It may be that your www-data user does not have access to port 51712 (or whichever port Choregraphe's virtual nao is using - it may change between sessions, have you checked that?). Maybe you can try running telnet 127.0.0.1 51712 from your PHP code - if that doesn't work, qimessaging won't be able to connect to that port either.