Hi everybody !
I have a GoPiGo2 running with the Python library, and I use a website with PHP to launch an instruction on my robot (like forward, left etc…). Now, I’d like to execute a sequence of movements, like fwd/left/bwd/right.
So my php function uses “exec(“python …/forward.py 10”, $this->feedback);” to launch a python script, that make the robot moving forward of 10 cm, and create a “friendly” feedback.
But now, to launch every instructions of my sequence, I need to use a “foreach” in my php function, and so my probleme is : only the last instruction is correct, I mean make the robot moving with the right distance.
In other terms, every instruction is executed partially, because the “exec” receive a feedback at the begin of the moving function in Python (for exemple, fwd() send “None” feedback before finishing moving the robot)
So my question is : How do I wait the end of a moving instruction in python (fwd(), bwd() etc…) before to send the final feedback to php ?
Here is my script (forward.py) :
from gopigo import *
distance = sys.argv;
p = int(round(18*int(distance)/20.1, 0));
retour = “”;
a = 0;
a = enc_tgt(1,1,p);
if a == 1 :
r += "Distance : "+distance+“cm\n”;
a = fwd();
if a != -1 :
r += “Moving Forward”;
Thank you for any answer !