Esempio n. 1
0
 def __init__(self):
     global x, y, z, yaw, pitch, roll
     x = y = z = yaw = pitch = roll = 0
     self.robot = Quadruped(ax=self, origin=(0, 0, 100))
     self.traces = dict()
     self.app = QtGui.QApplication(sys.argv)
     self.w = gl.GLViewWidget()
     self.w.opts['distance'] = 40
     self.w.setWindowTitle('pyqtgraph Quadruped')
     self.w.setGeometry(0, 110, 1920, 1080)
     self.w.show()
     self.setup()
Esempio n. 2
0
class Visualizer(object):
    def __init__(self):
        global x, y, z, yaw, pitch, roll
        x = y = z = yaw = pitch = roll = 0
        self.robot = Quadruped(ax=self, origin=(0, 0, 100))
        self.traces = dict()
        self.app = QtGui.QApplication(sys.argv)
        self.w = gl.GLViewWidget()
        self.w.opts['distance'] = 40
        self.w.setWindowTitle('pyqtgraph Quadruped')
        self.w.setGeometry(0, 110, 1920, 1080)
        self.w.show()
        self.setup()

    def setup(self):
        gsz=400
        gx = gl.GLGridItem()
        gx.setSize(gsz,gsz,gsz)
        gx.setSpacing(10,10,10)
        gx.rotate(90, 0, 1, 0)
        gx.translate(-gsz/2, 0, gsz/2)
        self.w.addItem(gx)
        gy = gl.GLGridItem()
        gy.setSize(gsz,gsz,gsz)
        gy.setSpacing(10,10,10)
        gy.rotate(90, 1, 0, 0)
        gy.translate(0, -gsz/2, gsz/2)
        self.w.addItem(gy)
        gz = gl.GLGridItem()
        gz.setSize(gsz,gsz,gsz)
        gz.setSpacing(10,10,10)
        self.w.addItem(gz)


    def start(self):
        if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
            QtGui.QApplication.instance().exec_()

    def update(self):
        global x, y, z, yaw, pitch, roll
        self.w.clear()
        self.setup()
        self.robot.shift_body_rotation(-yaw, pitch,roll)
        self.robot.draw_body()

    def animation(self):
        timer = QtCore.QTimer()
        timer.timeout.connect(self.update)
        timer.start(1)
        self.start()
Esempio n. 3
0
 def __init__(self):
     global x, y, z, yaw, pitch, roll, cl, r, count
     count = r = x = y = z = yaw = pitch = roll = cl = 0
     self.robot = Quadruped(ax=self, origin=(0, 0, 100))
     self.r2 = Quadruped(ax=self, origin=(0, 0, 100))
     self.px = x
     self.py = y
     self.pz = z
     self.pyaw = yaw
     self.ppitch = pitch
     self.proll = roll
     self.traces = dict()
     self.app = QtGui.QApplication(sys.argv)
     self.w = gl.GLViewWidget()
     self.w.opts['distance'] = 700
     self.w.setWindowTitle('pyqtgraph Quadruped')
     self.w.setGeometry(0, 110, 1400, 1000)
     self.w.show()
     self.setup()
Esempio n. 4
0
x = y = z = yaw = pitch = roll = 0

WINDOW_SIZE = 500
ANIMATE_INTERVAL = 50
start_height = 170
ax.set_xlim3d(-WINDOW_SIZE / 2, WINDOW_SIZE / 2)
ax.set_ylim3d(-WINDOW_SIZE / 2, WINDOW_SIZE / 2)
ax.set_zlim3d(-start_height, WINDOW_SIZE - start_height)

ax.set_xlabel('x (mm)')
ax.set_ylabel('y (mm)')
ax.set_zlabel('z (mm)')

# Setting up Quadruped
robot = Quadruped(ax=ax, origin=(0, 0, 0))


class MyController(Controller):
    global switch, buffer, inc, x, y, z, yaw, pitch, roll

    def __init__(self, **kwargs):
        Controller.__init__(self, **kwargs)

    def on_x_press(self):
        print("Hello world")
        animate()

    def on_x_release(self):
        print("Goodbye world")
Esempio n. 5
0
class Visualizer(object):
    def __init__(self):
        global x, y, z, yaw, pitch, roll, cl, r, count
        count = r = x = y = z = yaw = pitch = roll = cl = 0
        self.robot = Quadruped(ax=self, origin=(0, 0, 100))
        self.r2 = Quadruped(ax=self, origin=(0, 0, 100))
        self.px = x
        self.py = y
        self.pz = z
        self.pyaw = yaw
        self.ppitch = pitch
        self.proll = roll
        self.traces = dict()
        self.app = QtGui.QApplication(sys.argv)
        self.w = gl.GLViewWidget()
        self.w.opts['distance'] = 700
        self.w.setWindowTitle('pyqtgraph Quadruped')
        self.w.setGeometry(0, 110, 1400, 1000)
        self.w.show()
        self.setup()

    def setup(self):
        gsz=400
        gsp=10
        gx = gl.GLGridItem(color=(255, 255, 255, 60))
        gx.setSize(gsz,gsz,gsz)
        gx.setSpacing(gsp,gsp,gsp)
        gx.rotate(90, 0, 1, 0)
        gx.translate(-gsz/2, 0, gsz/2)
        self.w.addItem(gx)
        gy = gl.GLGridItem(color=(255, 255, 255, 60))
        gy.setSize(gsz,gsz,gsz)
        gy.setSpacing(gsp,gsp,gsp)
        gy.rotate(90, 1, 0, 0)
        gy.translate(0, -gsz/2, gsz/2)
        self.w.addItem(gy)
        gz = gl.GLGridItem(color=(255, 255, 255, 100))
        gz.setSize(gsz,gsz,gsz)
        gz.setSpacing(gsp,gsp,gsp)
        self.w.addItem(gz)


    def start(self):
        if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
            QtGui.QApplication.instance().exec_()

    def update(self):
        global x, y, z, yaw, pitch, roll, r, cl, count
        count+=1
        del self.w.items [:]
        if cl:
            sys.exit(0)
        self.w.clear()
        self.setup()
        pts = np.array([[-127.5, -110,0], [127.5, -110,0],[127.5, 110,0],[-127.5, 110,0]])
        self.r2.shift_body_rotation(yaw, pitch, roll, 0)
        self.r2.shift_body_translation(x, y, z, 0)
        self.r2.draw_legs(pts, 0)
        if self.r2.flag == 1:
            x = self.px
            y = self.py
            z = self.pz
            yaw = self.pyaw
            pitch = self.ppitch
            roll = self.proll
            self.r2.flag = 0
        else:
            self.robot.shift_body_rotation(yaw, pitch, roll, 1)
            self.robot.shift_body_translation(x, y, z, 1)
            self.px = x
            self.py = y
            self.pz = z
            self.pyaw = yaw
            self.ppitch = pitch
            self.proll = roll
        #self.robot.reset(r)
        self.robot.draw_body()
        #self.w.addItem(gl.GLScatterPlotItem(pos=pts, color=pg.glColor((4, 5)), size=7))
        self.robot.draw_legs(pts, 1)

    def animation(self):
        timer = QtCore.QTimer()
        timer.timeout.connect(self.update)
        timer.start(1)
        self.start()