예제 #1
0
def _import_pyb():
    import importlib
    global _pyb
    global p

    try:
        from roboticstoolbox.tools.stdout_supress import pipes
    except Exception:  # pragma nocover
        from contextlib import contextmanager

        @contextmanager
        def pipes(stdout=None, stderr=None):
            pass

    try:
        out = StringIO()
        try:
            with pipes(stdout=out, stderr=None):
                p = importlib.import_module('pybullet')
        except Exception:  # pragma nocover
            p = importlib.import_module('pybullet')

        cid = p.connect(p.SHARED_MEMORY)
        if (cid < 0):
            p.connect(p.DIRECT)
        _pyb = True
    except ImportError:   # pragma nocover
        _pyb = False
예제 #2
0
from io import StringIO

try:
    from roboticstoolbox.tools.stdout_supress import pipes
except Exception:  # pragma nocover
    from contextlib import contextmanager

    @contextmanager
    def pipes(stdout=None, stderr=None):
        pass


_out = StringIO()
_err = StringIO()
try:
    with pipes(stdout=_out, stderr=_err):
        from stl import mesh
except Exception:  # pragma nocover
    from stl import mesh


def import_object_from_numpy_stl(filename, scene):  # pragma nocover
    """
    Import either an ASCII or BINARY file format of an STL file.
    The triangles will be combined into a single compound entity.

    :param filename: Path of the stl file to import.
    :type filename: `str`
    :param scene: The scene in which to draw the object
    :type scene: class:`vpython.canvas`
    :return: Compound object of a collection of triangles formed from an