robotarium / robotarium_python_simulator

A Python simulator for the Robotarium! See your algorithm run on real robots!
MIT License
114 stars 61 forks source link

Graphics not showing up for Python simulator #14

Open zhzhang2018 opened 4 years ago

zhzhang2018 commented 4 years ago

Hi, I was trying to install the Python version of the Robotarium, but I was unable to see the simulation. For example, if I run formation_control.py, the program just runs for about a minute without showing me anything, and then tells me there has been 11 iterations where actuator limits are exceeded. I didn't change anything about the code, so the "show_figure" attribute should still be True.

Here's the printout when I try to run "pip install .": Requirement already satisfied: cvxopt in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from robotarium-python-simulator==0.0.0) (1.2.5) Requirement already satisfied: scipy in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from robotarium-python-simulator==0.0.0) (1.5.1) Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from robotarium-python-simulator==0.0.0) (1.19.0) Requirement already satisfied: matplotlib in /Users/zz/Library/Python/3.6/lib/python/site-packages (from robotarium-python-simulator==0.0.0) (3.0.1) Requirement already satisfied: cycler>=0.10 in /Users/zz/Library/Python/3.6/lib/python/site-packages (from matplotlib->robotarium-python-simulator==0.0.0) (0.10.0) Requirement already satisfied: python-dateutil>=2.1 in /Users/zz/Library/Python/3.6/lib/python/site-packages (from matplotlib->robotarium-python-simulator==0.0.0) (2.7.5) Requirement already satisfied: kiwisolver>=1.0.1 in /Users/zz/Library/Python/3.6/lib/python/site-packages (from matplotlib->robotarium-python-simulator==0.0.0) (1.0.1) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /Users/zz/Library/Python/3.6/lib/python/site-packages (from matplotlib->robotarium-python-simulator==0.0.0) (2.2.2) Requirement already satisfied: six in /Users/zz/Library/Python/3.6/lib/python/site-packages (from cycler>=0.10->matplotlib->robotarium-python-simulator==0.0.0) (1.11.0) Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib->robotarium-python-simulator==0.0.0) (47.1.0) Building wheels for collected packages: robotarium-python-simulator Building wheel for robotarium-python-simulator (setup.py) ... done Created wheel for robotarium-python-simulator: filename=robotarium_python_simulator-0.0.0-py3-none-any.whl size=22621 sha256=16811987f54d85a92aaeb77d5c2aaef41299f2fc893937cbed6d4e40ba845195 Stored in directory: /private/var/folders/8b/547r7lwx03j0_j31hwmhf1540000gn/T/pip-ephem-wheel-cache-c0w4b457/wheels/68/43/e5/011ecc5f3b2929f189fc3a4c3dff00758775127f65829f9fce Successfully built robotarium-python-simulator Installing collected packages: robotarium-python-simulator Attempting uninstall: robotarium-python-simulator Found existing installation: robotarium-python-simulator 0.0.0 Uninstalling robotarium-python-simulator-0.0.0: Successfully uninstalled robotarium-python-simulator-0.0.0 Successfully installed robotarium-python-simulator-0.0.0

So... I'm not sure why there's no visual.

I should note that there's another folder of code that tries to do modifications on the original Robotarium code to extend its functionalities in some other situations. I have ran "pip install ." using the code in that folder before. Could this have possibly messed up the build? Note also that after running the "pip install ." command at that folder, the formation_control.py file won't be able to find the package/folder RPS for some reason.

MehdiMoussaid commented 3 years ago

Hi ! I have the same issue. Did you manage to fix it ? Thanks !

Mohamam1 commented 3 years ago

Hi! i have the same issue. Did you manage to fix it ? im also on mac

medusamedusa commented 2 years ago

Hello! I have the same issue. Mac M1 here.

yliuaa commented 2 years ago

Same problem here. Mac M1

amoghcharan commented 1 year ago

I have a potential solution that worked for me (Mac OSX 12.4 Intel). The problem lies in the matplotlib package for MacOS where certain GUIs will not appear depending on the chosen backend in the ~/matplotlib/mpl-data/matplotlibrc file.

On default it claims to cycle through all available backends to find a compatible one, but I always had no Python GUI window show up and the experiments appeared to run in the background.

The simple fix I did to resolve this was to go into my robotarium_abc.py file in BOTH the rps and build/lib/rps directories and add to the imports:

import matplotlib
matplotlib.use('QtAgg')
import matplotlib.pyplot as plt
import matplotlib.patches as patches

This changes the default GUI backend to 'QtAgg' for only Robotarium files and other backends can be used (I found this one to work for me). I then went to the robotarium_python_simulator directory and reinstalled the dependencies with pip install . From here you should be able to run any of the python examples as instructed in the readme.

An alternative method that may work can be done in the matplotlibrc file directly:

To find the right matplotlibrc file, given that you may have it in multiple places if you have any virtual environments, go to the robotarium_python_simulator directory and reinstall the dependencies with pip install . For me, this showed: Requirement already satisfied: matplotlib in /Users/amogh/opt/anaconda3/lib/python3.9/site-packages (from robotarium-python-simulator==0.0.0) (3.5.2)

Now entering into this file I had to:

Hope this helps! And I'm open to helping resolve any further issues that might come up with this fix :)