Skip to content

Commit 963b43c

Browse files
committed
Update proto.py
1 parent b293607 commit 963b43c

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

proto/proto.py

+36-6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
from collections import defaultdict
4646
from types import FunctionType
4747
from typing import Optional
48+
import asyncio
49+
import subprocess
50+
from subprocess import Popen
51+
from subprocess import PIPE
4852

4953
import cv2
5054
import yaml
@@ -60,6 +64,16 @@
6064
SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
6165
EUROC_DATA_PATH = '/data/euroc/V1_01'
6266

67+
###############################################################################
68+
# PIP
69+
###############################################################################
70+
71+
72+
def pip_install(package):
73+
""" Install package via pip """
74+
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
75+
76+
6377
###############################################################################
6478
# YAML
6579
###############################################################################
@@ -2547,6 +2561,12 @@ def plot_xyz(title, data, key_time, key_x, key_y, key_z, ylabel, **kwargs):
25472561

25482562
def pyqtgraph_mesh(widget):
25492563
""" Plot mesh """
2564+
try:
2565+
import pyqtgraph
2566+
except:
2567+
pip_install("pyqtgraph")
2568+
pip_install("pyopengl")
2569+
25502570
import pyqtgraph.opengl as gl # Lazy importing
25512571
g = gl.GLGridItem()
25522572
g.scale(1, 1, 1)
@@ -2556,9 +2576,14 @@ def pyqtgraph_mesh(widget):
25562576

25572577
def pyqtgraph_axes(widget, T, **kwargs):
25582578
""" Plot axes """
2559-
import pyqtgraph.opengl as gl # Lazy importing
2579+
try:
2580+
import pyqtgraph
2581+
except:
2582+
pip_install("pyqtgraph")
2583+
pip_install("pyopengl")
25602584

25612585
# Settings
2586+
import pyqtgraph.opengl as gl # Lazy importing
25622587
w = kwargs.get("width", 2.0)
25632588
s = kwargs.get("scale", 1.0)
25642589
a = kwargs.get("antialias", False)
@@ -2592,9 +2617,14 @@ def pyqtgraph_axes(widget, T, **kwargs):
25922617

25932618
def pyqtgraph_example(sys):
25942619
""" Run Qt plot """
2620+
try:
2621+
import pyqtgraph
2622+
except:
2623+
pip_install("pyqtgraph")
2624+
pip_install("pyopengl")
2625+
25952626
from pyqtgraph.Qt import QtWidgets # Lazy importing
25962627
import pyqtgraph.opengl as gl # Lazy importing
2597-
25982628
app = QtWidgets.QApplication(sys.argv)
25992629
widget = gl.GLViewWidget()
26002630

@@ -12704,10 +12734,10 @@ def on_key(event, fig):
1270412734
# Visualizer
1270512735
###############################################################################
1270612736

12707-
import websockets
12708-
import asyncio
12709-
12710-
from subprocess import Popen, PIPE
12737+
try:
12738+
import websockets
12739+
except:
12740+
pip_install("websockets")
1271112741

1271212742

1271312743
class DevServer:

0 commit comments

Comments
 (0)