dqjmq28248
2018-09-04 00:30
浏览 77

PHP shell_exec与python naoqi:“qimessaging.socketcache:过滤后没有更多端点可用”

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

图片转代码服务由CSDN问答提供 功能建议

当我在PHP中使用shell_exec执行它时,我似乎无法使我的python脚本工作

我在choregraphe中使用虚拟机器人

这是我的代码: PHP

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

Python: \ 来自naoqi的n 导入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 *在Arm1中为x的motion.TO_RAD] mp.post.angleInterpolationWithSpeed(JointNames,Arm1,pFractionMaxSpeed) \ n

如果我只是通过cmd运行python,那么它可以正常运行并让机器人移动。

我认为它与它运行时有关 数据用户和它 弄乱了naoqi模块(或类似的东西):链接

我只是不确定如何在Windows中使用XAMPP或WAMP

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doushi1974 2018-09-04 15:12
    已采纳

    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.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题