I am having problems with the web simulator.
I am interested in writing programs in Python (only, not Snap) in order to study the computations of 3D rotations.
The documentation is inconsistent if I need to run poppy-services
if I am writing my own Python program.
But I did so and it runs OK.
If I am supposed to run it, can I just omit the --snap parameter
since I don’t want Snap? Or should the parameters be different.
In a separate command window I ran Python with the following program based on the example in the documentation.
The printing of present position worked and the value of m3 printed changes after running the program, but nothing happened in the visualization.
from pypot.creatures import PoppyErgoJr
import time
poppy = PoppyErgoJr(simulator='poppy-simu')
for m in poppy.motors:
print(m.present_position)
for _ in range(3):
poppy.m3.goal_position = 30
time.sleep(0.5)
poppy.m3.goal_position = -30
time.sleep(0.5)
for m in poppy.motors:
print(m.present_position)
Hello,
There was a bug/undocumented change in the API that required to start manually the HTTP API to be able to visualize the dummy robot from simu.poppy-project.org.
We fixed it. You can install the last version of pypot from the git, or simplier you can start the HTTP API manually like this:
from pypot.creatures import PoppyErgoJr
poppy = PoppyErgoJr(simulator='poppy-simu', use_http=True)
After that, you will be able to go on http://simu.poppy-project.org/poppy-ergo-jr/, an click on “sychroniser” checkbox.
If you restart the robot, you will have to uncheck/check this checkbox.
poppy-services is a cli tool that make easier to start the different APIs of the robot, so it is not intended to be able to program the robot in Python by this way.
Hi,
It is the way to do it. You can have the web page open before executing your code, but you need to check synchroniser after the code was started.
I tested with your code, and it works (I just increase the number of loop iteration to be able to see the movement before the synchronization).
By restarting, in your case it just mean calling you file again.
Just for fun, I tried it on my laptop at home (using Miniconda instead of Anaconda) and it works!
The Windows firewall asked for permission and I allowed it.
I don’t know why I didn’t get the firewall warning on the computer at the office…
Aaah, I thought about that and then I forgot. In many offices, ports other than 80, 443, 22 are blocked without warning the firewall.
The HTTP API use the port 8080.