intrig-unicamp / mininet-wifi

Emulator for Software-Defined Wireless Networks
https://mn-wifi.readthedocs.io/
Other
431 stars 239 forks source link

Matplot lib not working in UAV.py #410

Closed kartikeyagg closed 2 years ago

kartikeyagg commented 2 years ago

I am trying to emulate FANET using /uav/uav.py but the script is throwing error stating that :- Warning: Starting a Matplotlib GUI outside of the main thread will likely fail. WARNING: QApplication was not created in the main() thread. I used the command : -sudo python examples/uav/uav.py I have not made any changes in the script The CoppeliaSim is opening and simulating the environment succesfully. I am attaching the complete output of terminal as follows:-

rm: cannot remove 'examples/uav/data/*': No such file or directory Creating nodes Configuring wifi nodes Connecting to wmediumd server /var/run/wmediumd.sock Starting network dr1 dr2 dr3 Starting Socket Server Starting CoppeliaSim /usr/local/lib/python3.6/dist-packages/mininet_wifi-2.6-py3.6.egg/mn_wifi/telemetry.py:61: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail. fig, (self.axes) = plt.subplots(1, 1, figsize=(10, 10)) WARNING: QApplication was not created in the main() thread. [CoppeliaSimClient] loading the CoppeliaSim library... QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' [CoppeliaSimClient] done. [CoppeliaSimClient:loadinfo] launching CoppeliaSim... [CoppeliaSim:loadinfo] CoppeliaSim V4.1.0., (rev. 1), flavor: 1 [CoppeliaSim:loadinfo] Legacy machine ID: 5000-9DEB-FFC4-9CEC-F7E3-841D [CoppeliaSim:loadinfo] Machine ID: 16E3-736C-D0E2-0000-07AB-0101 QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' [CoppeliaSim:loadinfo] using the default Lua library. [CoppeliaSim:loadinfo] loaded the video compression library. /usr/local/lib/python3.6/dist-packages/mininet_wifi-2.6-py3.6.egg/mn_wifi/telemetry.py:331: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail. plt.show() Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib/python3.6/threading.py", line 864, in run self._target(*self._args, self._kwargs) File "/usr/local/lib/python3.6/dist-packages/mininet_wifi-2.6-py3.6.egg/mn_wifi/telemetry.py", line 74, in start parseData(nodes, self.axes, single, data_type=data_type, fig=fig, kwargs) File "/usr/local/lib/python3.6/dist-packages/mininet_wifi-2.6-py3.6.egg/mn_wifi/telemetry.py", line 179, in init self.start(nodes, axes, single, data_type, fig, *kwargs) File "/usr/local/lib/python3.6/dist-packages/mininet_wifi-2.6-py3.6.egg/mn_wifi/telemetry.py", line 331, in start plt.show() File "/home/kartikey/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 353, in show return _backend_mod.show(args, **kwargs) File "/home/kartikey/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 3544, in show cls.mainloop() File "/home/kartikey/.local/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 1037, in mainloop signal.signal(signal.SIGINT, signal.SIG_DFL) File "/usr/lib/python3.6/signal.py", line 47, in signal handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler)) ValueError: signal only works in main thread

[CoppeliaSim:loadinfo] if CoppeliaSim crashes now, try to install libgl1-mesa-dev on your system:

sudo apt install libgl1-mesa-dev [CoppeliaSim:loadinfo] OpenGL NVIDIA Corporation, Renderer: GeForce GTX 1050 Ti/PCIe/SSE2, Version: 4.6.0 NVIDIA 460.91.03 [CoppeliaSim:loadinfo] simulator launched. [CoppeliaSim:loadinfo] plugin 'DynamicsBullet-2-78': loading... [CoppeliaSim:loadinfo] plugin 'DynamicsBullet-2-78': load succeeded. [CoppeliaSim:loadinfo] plugin 'DynamicsBullet-2-83': loading... [CoppeliaSim:loadinfo] plugin 'DynamicsBullet-2-83': load succeeded. [CoppeliaSim:loadinfo] plugin 'DynamicsNewton': loading... [CoppeliaSim:loadinfo] plugin 'DynamicsNewton': load succeeded. [CoppeliaSim:loadinfo] plugin 'DynamicsOde': loading... [CoppeliaSim:loadinfo] plugin 'DynamicsOde': load succeeded. [CoppeliaSim:loadinfo] plugin 'DynamicsVortex': loading... [CoppeliaSim:loadinfo] plugin 'DynamicsVortex': load succeeded. [CoppeliaSim:loadinfo] plugin 'Geometric': loading... [CoppeliaSim:loadinfo] plugin 'Geometric': load succeeded. [CoppeliaSim:loadinfo] plugin 'Assimp': loading... [CoppeliaSim:loadinfo] plugin 'Assimp': load succeeded. [CoppeliaSim:loadinfo] plugin 'BlueZero': loading... [CoppeliaSim:loadinfo] plugin 'BlueZero': load succeeded. [CoppeliaSim:loadinfo] plugin 'BubbleRob': loading... [CoppeliaSim:loadinfo] plugin 'BubbleRob': load succeeded. [CoppeliaSim:loadinfo] plugin 'Bwf': loading... [CoppeliaSim:loadinfo] plugin 'Bwf': load succeeded. [CoppeliaSim:loadinfo] plugin 'CodeEditor': loading... [simExtCodeEditor:loadinfo] CodeEditor plugin initialized [CoppeliaSim:loadinfo] plugin 'CodeEditor': load succeeded. [CoppeliaSim:loadinfo] plugin 'Collada': loading... [CoppeliaSim:loadinfo] plugin 'Collada': load succeeded. [CoppeliaSim:loadinfo] plugin 'ConvexDecompose': loading... [CoppeliaSim:loadinfo] plugin 'ConvexDecompose': load succeeded. [CoppeliaSim:loadinfo] plugin 'CustomUI': loading... [CoppeliaSim:loadinfo] plugin 'CustomUI': load succeeded. [CoppeliaSim:loadinfo] plugin 'ExternalRenderer': loading... [CoppeliaSim:loadinfo] plugin 'ExternalRenderer': load succeeded. [CoppeliaSim:loadinfo] plugin 'GLTF': loading... [CoppeliaSim:loadinfo] plugin 'GLTF': load succeeded. [CoppeliaSim:loadinfo] plugin 'ICP': loading... [CoppeliaSim:loadinfo] plugin 'ICP': load succeeded. [CoppeliaSim:loadinfo] plugin 'IK': loading... [CoppeliaSim:loadinfo] plugin 'IK': load succeeded. [CoppeliaSim:loadinfo] plugin 'Image': loading... [CoppeliaSim:loadinfo] plugin 'Image': load succeeded. [CoppeliaSim:loadinfo] plugin 'K3': loading... [CoppeliaSim:loadinfo] plugin 'K3': load succeeded. [CoppeliaSim:loadinfo] plugin 'LuaCommander': loading... [CoppeliaSim:loadinfo] plugin 'LuaCommander': load succeeded. [CoppeliaSim:loadinfo] plugin 'LuaRemoteApiClient': loading... [CoppeliaSim:loadinfo] plugin 'LuaRemoteApiClient': load succeeded. [CoppeliaSim:loadinfo] plugin 'Mtb': loading... [CoppeliaSim:loadinfo] plugin 'Mtb': load succeeded. [CoppeliaSim:loadinfo] plugin 'OMPL': loading... [CoppeliaSim:loadinfo] plugin 'OMPL': load succeeded. [CoppeliaSim:loadinfo] plugin 'OpenGL3Renderer': loading... [CoppeliaSim:loadinfo] plugin 'OpenGL3Renderer': load succeeded. [CoppeliaSim:loadinfo] plugin 'OpenMesh': loading... [CoppeliaSim:loadinfo] plugin 'OpenMesh': load succeeded. [CoppeliaSim:loadinfo] plugin 'Qhull': loading... [CoppeliaSim:loadinfo] plugin 'Qhull': load succeeded. [CoppeliaSim:loadinfo] plugin 'ROSInterface': loading... [CoppeliaSim:error] plugin 'ROSInterface': load failed (could not load). The plugin probably couldn't load dependency libraries. For additional infos, modify the script 'libLoadErrorCheck.sh', run it and inspect the output. [CoppeliaSim:loadinfo] plugin 'RRS1': loading... [CoppeliaSim:loadinfo] plugin 'RRS1': load succeeded. [CoppeliaSim:loadinfo] plugin 'ReflexxesTypeII': loading... [CoppeliaSim:loadinfo] plugin 'ReflexxesTypeII': load succeeded. [CoppeliaSim:loadinfo] plugin 'RemoteApi': loading... [simExtRemoteApi:loadinfo] starting a remote API server on port 19997 [CoppeliaSim:loadinfo] plugin 'RemoteApi': load succeeded. [CoppeliaSim:loadinfo] plugin 'SDF': loading... [CoppeliaSim:loadinfo] plugin 'SDF': load succeeded. [CoppeliaSim:loadinfo] plugin 'SurfaceReconstruction': loading... [CoppeliaSim:loadinfo] plugin 'SurfaceReconstruction': load succeeded. [CoppeliaSim:loadinfo] plugin 'URLDrop': loading... [CoppeliaSim:loadinfo] plugin 'URLDrop': load succeeded. [CoppeliaSim:loadinfo] plugin 'Urdf': loading... [CoppeliaSim:loadinfo] plugin 'Urdf': load succeeded. [CoppeliaSim:loadinfo] plugin 'Vision': loading... [CoppeliaSim:loadinfo] plugin 'Vision': load succeeded. [CoppeliaSim:warning] compatibility fix in script Quadricopter@childScript: replaced some occurrence of sim.getObjectOrientation with getObjectOrientation, to fix a possible bug in versions prior to CoppeliaSim V4.0.1. [CoppeliaSim:warning] compatibility fix in script Quadricopter@childScript: replaced some occurrence of sim.getObjectPosition with getObjectPosition, to fix a possible bug in versions prior to CoppeliaSim V4.0.1. [CoppeliaSim:warning] compatibility fix in script Quadricopter#0@childScript: replaced some occurrence of sim.getObjectOrientation with getObjectOrientation, to fix a possible bug in versions prior to CoppeliaSim V4.0.1. [CoppeliaSim:warning] compatibility fix in script Quadricopter#0@childScript: replaced some occurrence of sim.getObjectPosition with getObjectPosition, to fix a possible bug in versions prior to CoppeliaSim V4.0.1. [CoppeliaSim:warning] compatibility fix in script Quadricopter#1@childScript: replaced some occurrence of sim.getObjectOrientation with getObjectOrientation, to fix a possible bug in versions prior to CoppeliaSim V4.0.1. [CoppeliaSim:warning] compatibility fix in script Quadricopter#1@childScript: replaced some occurrence of sim.getObjectPosition with getObjectPosition, to fix a possible bug in versions prior to CoppeliaSim V4.0.1. [CoppeliaSim:loadinfo] using the 'Geometric' plugin. [CoppeliaSim:loadinfo] using the 'IK' plugin. Perform a simple test Configure the node position Running CLI Starting CLI: mininet-wifi> Screenshot from 2021-10-21 13-24-54

ramonfontes commented 2 years ago

Which version of matplotlib do you have?

kartikeyagg commented 2 years ago

matplotlib version :- 3.3.3

ramonfontes commented 2 years ago

Well, I cannot reproduce the issue because I don't have my computer now. However, this might be related to the matplotlib backend. Which one are you using? Qt? TkAgg? Can you try TkAgg?

ramonfontes commented 2 years ago

Please try https://github.com/intrig-unicamp/mininet-wifi/commit/650e89245adab5cee49dc08c2a1c7983ce246639 and let me know if it works for you.

kartikeyagg commented 2 years ago

It worked. Thank you very much. I am new to mininet-wifi and will be very grateful if you can help me with the following:- 1.) Is CoppeliaSim necessary for this type of emulations , can I use ROS Gazebo(Iris drone) instead? How UAVs are controlled in this emulations? Is it by sending locations (where?) ? 2.) Can I send velocity instead of position?

ramonfontes commented 2 years ago
  1. Yes. I only added integration with CoppeliaSim. However, you can make integration with other simulations if you prefer. Coppelia is responsible for the mobility.
  2. You can do that in Coppelia.
kartikeyagg commented 2 years ago

Is there any documentation for this script?

ramonfontes commented 2 years ago

Which one?

kartikeyagg commented 2 years ago

uav.py and other examples

ramonfontes commented 2 years ago

Do you really need a doc for uav.py?? It has few lines of code.

kartikeyagg commented 2 years ago

Its good . Thanks