def traverse_scene_object(scene_data, parent=None):
    """
    Recursivesly populate a scene object with tree of children 
    :param scene_data:
    :param parent:
    :return:
    """

    if parent is None:
        # At the tree root
        new_parent = Object3D(name=scene_data.name)
        parent = new_parent

    for sub_object in scene_data.contents:
        if type(sub_object) == list:
            for iobj in sub_object:
                traverse_scene_object(iobj, parent)
            continue
        elif hasattr(sub_object, "type"):
            parent.add(convert_object_to_pythreejs(sub_object))
        else:
            new_parent = Object3D(name=sub_object.name)
            parent.add(new_parent)
            traverse_scene_object(sub_object, parent)
    return parent
Exemple #2
0
 def __init__(self):
     Object3D.__init__(self)
     mesh = ColladaMesh(dae_path + 'base.dae')
     mesh.rotateZ(np.pi)
     self.add(mesh)
     axes = AxesHelper(size=0.5)
     self.add(axes)
Exemple #3
0
 def __init__(self):
     Object3D.__init__(self)
     mesh = ColladaMesh(_DAE_PATH + "wrist3.dae")
     self.mesh = mesh
     self.add(mesh)
     axes = AxesHelper(size=0.1)
     self.add(axes)
def _traverse_scene_object(scene_data, parent=None):
    """
    Recursivesly populate a nested Object3D object from pythreejs
    using the same tree structure from crystaltoolkit

    :param scene_data: The content of the current branch of the Scene object
    :param parent: Reference to the parent in the pythreejs tree
        (default: {None} means you are at the root)
    :return: Object3D of the current pythreejs object with all the children fully populated
    """

    if parent is None:
        # At the tree root
        new_parent = Object3D(name=scene_data.name)
        parent = new_parent

    for sub_object in scene_data.contents:
        if isinstance(sub_object, list):
            for iobj in sub_object:
                _traverse_scene_object(iobj, parent)
            continue
        elif hasattr(sub_object, "type"):
            parent.add(_convert_object_to_pythreejs(sub_object))
        else:
            new_parent = Object3D(name=sub_object.name)
            parent.add(new_parent)
            _traverse_scene_object(sub_object, parent)
    return parent
Exemple #5
0
 def __init__(self):
     Object3D.__init__(self)
     mesh = ColladaMesh(dae_path + 'wrist1.dae')
     mesh.position = (0.0, -0.10915 + (-0.1197 + 0.13585), 0)
     self.mesh = mesh
     self.add(mesh)
     axes = AxesHelper(size=0.5)
     self.add(axes)
Exemple #6
0
 def __init__(self):
     Object3D.__init__(self)
     mesh = ColladaMesh(dae_path + 'wrist3.dae')
     mesh.position = (0.0, 0.0, -0.0823)
     mesh.rotateX(np.pi / 2)
     self.mesh = mesh
     self.add(mesh)
     axes = AxesHelper(size=0.5)
     self.add(axes)
Exemple #7
0
 def __init__(self):
     Object3D.__init__(self)
     mesh = ColladaMesh(dae_path + 'shoulder.dae')
     mesh.rotateX(-np.pi / 2)
     mesh.rotateZ(np.pi)
     self.mesh = mesh
     self.add(mesh)
     axes = AxesHelper(size=0.5)
     self.add(axes)
Exemple #8
0
 def __init__(self):
     Object3D.__init__(self)
     mesh = ColladaMesh(dae_path + 'forearm.dae')
     self.mesh = mesh
     mesh.rotateX(np.pi / 2)
     mesh.position = (0.39225, 0., -0.1197 + 0.13585)
     mesh.rotateY(-np.pi / 2)
     self.add(mesh)
     axes = AxesHelper(size=0.5)
     self.add(axes)
Exemple #9
0
 def __init__(self):
     Object3D.__init__(self)
     mesh = ColladaMesh(dae_path + 'upperarm.dae')
     mesh.rotateX(np.pi / 2)
     mesh.rotateY(-np.pi / 2)
     mesh.position = (0.425, 0, 0.13585)
     self.mesh = mesh
     self.add(mesh)
     axes = AxesHelper(size=0.5)
     self.add(axes)
def traverse_scene_object(scene_data, parent=None):
    """
    Recursivesly populate a scene object with tree of children
    :param scene_data:
    :param parent:
    :return:
    """
    for sub_object in scene_data["contents"]:
        if "type" in sub_object.keys():
            parent.add(convert_object_to_pythreejs(sub_object))
        else:
            new_parent = Object3D(name=sub_object["name"])
            if parent is None:
                parent = new_parent
            else:
                parent.add(new_parent)
            traverse_scene_object(sub_object, parent)
    return parent
Exemple #11
0
 def __init__(self):
     Object3D.__init__(self)
    def __init__(self):
        self._viewer = Viewer()
        self._grid = Grid()
        self._viewer.add(self._grid)

        base_link = kr6.BaseLink()
        link1 = kr6.Link1()
        link2 = kr6.Link2()
        link3 = kr6.Link3()
        link4 = kr6.Link4()
        link5 = kr6.Link5()
        link6 = kr6.Link6()
        ee_link = Axes(0.1)

        joint1 = Object3D()
        joint1.position = (0.0, 0.0, 0.4)
        joint2 = Object3D()
        joint2.position = (0.025, 0.0, 0.0)
        joint3 = Object3D()
        joint3.position = (0.455, 0.0, 0.0)
        joint4 = Object3D()
        joint4.position = (0.0, 0.0, 0.035)
        joint5 = Object3D()
        joint5.position = (0.42, 0.0, 0.0)
        joint6 = Object3D()
        joint6.position = (0.08, 0.0, 0.0)

        ee_joint = Object3D()

        base_link.add(joint1)
        joint1.add(link1)
        link1.add(joint2)
        joint2.add(link2)
        link2.add(joint3)
        joint3.add(link3)
        link3.add(joint4)
        joint4.add(link4)
        link4.add(joint5)
        joint5.add(link5)
        link5.add(joint6)
        joint6.add(link6)
        link6.add(ee_joint)
        ee_joint.add(ee_link)

        self._joints = [joint1, joint2, joint3, joint4, joint5, joint6]
        self._offsets = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
        self._axes = np.array(
            [
                [0.0, 0.0, -1.0],
                [0.0, 1.0, 0.0],
                [0.0, 1.0, 0.0],
                [-1.0, 0.0, 0.0],
                [0.0, 1.0, 0.0],
                [-1.0, 0.0, 0.0],
            ]
        )

        self.theta = np.zeros(6)

        self._robot = base_link
        self._viewer.add(self._robot)
    def __init__(self):
        self._viewer = Viewer()
        self._grid = Grid()
        self._viewer.add(self._grid)

        base_link = ur5.BaseLink()
        link1 = ur5.Link1()
        link2 = ur5.Link2()
        link3 = ur5.Link3()
        link4 = ur5.Link4()
        link5 = ur5.Link5()
        link6 = ur5.Link6()
        ee_link = Axes(0.1)

        joint1 = Object3D()
        joint1.position = (0.0, 0.0, 0.089159)
        joint2 = Object3D()
        joint2.position = (0.0, 0.13585, 0.0)
        joint3 = Object3D()
        joint3.position = (0.0, -0.1197, 0.425)
        joint4 = Object3D()
        joint4.position = (0.0, 0.0, 0.39225)
        joint5 = Object3D()
        joint5.position = (0.0, 0.093, 0.0)
        joint6 = Object3D()
        joint6.position = (0.0, 0.0, 0.09465)

        ee_joint = Object3D()
        ee_joint.position = (0.0, 0.0823, 0.0)
        ee_joint.rotateX(-np.pi / 2)

        base_link.add(joint1)
        joint1.add(link1)
        link1.add(joint2)
        joint2.add(link2)
        link2.add(joint3)
        joint3.add(link3)
        link3.add(joint4)
        joint4.add(link4)
        link4.add(joint5)
        joint5.add(link5)
        link5.add(joint6)
        joint6.add(link6)
        link6.add(ee_joint)
        ee_joint.add(ee_link)

        self._joints = [joint1, joint2, joint3, joint4, joint5, joint6]
        self._offsets = np.array([0.0, np.pi / 2, 0.0, np.pi / 2, 0.0, 0.0])
        self._axes = np.array(
            [
                [0.0, 0.0, 1.0],
                [0.0, 1.0, 0.0],
                [0.0, 1.0, 0.0],
                [0.0, 1.0, 0.0],
                [0.0, 0.0, 1.0],
                [0.0, 1.0, 0.0],
            ]
        )

        self.theta = np.zeros(6)

        self._robot = base_link
        self._viewer.add(self._robot)
Exemple #14
0
 def __init__(self):
     Object3D.__init__(self)
     mesh = ColladaMesh(dae_path + 'base_link.dae', scale=0.001)
     self.add(mesh)
     axes = AxesHelper(size=0.5)
     self.add(axes)
 def __init__(self):
     Object3D.__init__(self)
     mesh = ColladaMesh(dae_path + "base_link.dae", scale=0.001)
     self.add(mesh)