Exemplo n.º 1
0
import time
import re
import sys 
sys.dont_write_bytecode = True # keep the folders clean for beginners
sys.path.append('Moves') # include the moves folder
sys.path.append('PoMoCo')

import servotorComm
from robot import hexapod
import GUI

if __name__ == '__main__':

    controller = servotorComm.Controller() # Servo controller

    hexy = hexapod(controller)
    __builtins__.hexy = hexy # sets 'hexy' to be a gobal variable common to all modules
    __builtins__.floor = 60  # this is the minimum level the legs will reach

    # go through the Moves folder to find move files
    moves = []
    for fileName in os.listdir('Moves'):
        if os.path.splitext(fileName)[1] == '.py':
            fileName = os.path.splitext(fileName)[0]
            s1 = re.sub('(.)([A-Z][a-z]+)', r'\1 \2', fileName)
            moves.append(s1)
            __builtins__.moves = moves

    # global function for running move files
    def move(moveName):
        print "Preforming move:",moveName
Exemplo n.º 2
0
# Include the moves folder
sys.path.append('Moves')
sys.path.append('PoMoCo')

import servotorComm
from robot import hexapod
import GUI

if __name__ == '__main__':

    # Intialize the servo controller
    controller = servotorComm.Controller()

    # Set up the servo controller to run Hexy
    hexy = hexapod(controller)
    __builtins__.hexy = hexy  # sets 'hexy' to be a global variable common to all modules
    __builtins__.floor = 60  # this is the minimum level the legs will reach

    # Go through the Moves folder to find move files
    moves = []
    for fileName in os.listdir('Moves'):
        if os.path.splitext(fileName)[1] == '.py':
            fileName = os.path.splitext(fileName)[0]
            s1 = re.sub('(.)([A-Z][a-z]+)', r'\1 \2', fileName)
            moves.append(s1)
            __builtins__.moves = moves

    # Function for running move files
    def move(moveName):
        print "Performing move:", moveName
Exemplo n.º 3
0
    def __init__(self):
        self.con = servotorComm.Controller() # Servo controller
        self.hexy = hexapod(self.con)
        self.loadOffsets()

        self.estop()
Exemplo n.º 4
0
    def __init__(self, master):
        self.con = servotorComm.Controller()  # Servo controller
        self.hexy = hexapod(self.con)
        self.master = master

        self.frame = Frame(self.master)

        self.frame.pack()

        #setup menu system
        menu = Menu(root)
        root.config(menu=menu)
        filemenu = Menu(menu)

        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="New")
        filemenu.add_command(label="Save Offsets", command=self.saveOffsets)
        # TODO: bring these over from servitorGui
        #filemenu.add_command(label="Open Offsets", command=self.openOffsets)
        #filemenu.add_command(label="Save Positions", command=self.savePositions)
        #filemenu.add_command(label="Open Positions", command=self.openPositions)

        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.quitApp)

        #setup kill button
        self.killButton = Button(
            self.frame,
            text="Kill All Servos",
            fg="red",
            font=("Helvetica", 20),
            command=self.gui_estop)
        self.killButton.grid(row=0, column=14)

        self.loadOffsets()

        self.servos = []
        #setup left side, 4 groups of 4 servo controls
        for i in xrange(4):
            self.newServo(0 + i * 4, [1, 8 + i * 5])
            self.newServo(1 + i * 4, [1, 9 + i * 5])
            self.newServo(2 + i * 4, [1, 10 + i * 5])
            self.newServo(3 + i * 4, [1, 11 + i * 5])
            self.addSpace([0, 12 + i * 5])

        #setup right side, 4 groups of 4 servo controls
        for i in xrange(4):
            self.newServo(16 + i * 4, [11, 8 + i * 5])
            self.newServo(17 + i * 4, [11, 9 + i * 5])
            self.newServo(18 + i * 4, [11, 10 + i * 5])
            self.newServo(19 + i * 4, [11, 11 + i * 5])
            self.addSpace([11, 12 + i * 5])

        #add some spaces for asthetics
        self.addSpace([10, 1])

        # generate buttons for all move functions
        counter = 0
        for move_name in dir(self):
            if "move_" in move_name:
                b = Button(
                    self.frame,
                    text=move_name[5:],
                    command=
                    lambda func=getattr(self, "move_" + move_name[5:]): servotorComm.runMovement(func)
                )
                b.grid(row=counter + 8, column=0)
                #b.pack()
                counter += 1

        #servoBars = []

        self.poll()
        self.estop()
Exemplo n.º 5
0
    def __init__(self):
        self.con = servotorComm.Controller()  # Servo controller
        self.hexy = hexapod(self.con)
        self.loadOffsets()

        self.estop()
Exemplo n.º 6
0
    def __init__(self, master):
        self.con = servotorComm.Controller()  # Servo controller
        self.hexy = hexapod(self.con)
        self.master = master

        self.frame = Frame(self.master)

        self.frame.pack()

        #setup menu system
        menu = Menu(root)
        root.config(menu=menu)
        filemenu = Menu(menu)

        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="New")
        filemenu.add_command(label="Save Offsets", command=self.saveOffsets)
        # TODO: bring these over from servitorGui
        #filemenu.add_command(label="Open Offsets", command=self.openOffsets)
        #filemenu.add_command(label="Save Positions", command=self.savePositions)
        #filemenu.add_command(label="Open Positions", command=self.openPositions)

        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.quitApp)

        #setup kill button
        self.killButton = Button(self.frame,
                                 text="Kill All Servos",
                                 fg="red",
                                 font=("Helvetica", 20),
                                 command=self.gui_estop)
        self.killButton.grid(row=0, column=14)

        self.loadOffsets()

        self.servos = []
        #setup left side, 4 groups of 4 servo controls
        for i in xrange(4):
            self.newServo(0 + i * 4, [1, 8 + i * 5])
            self.newServo(1 + i * 4, [1, 9 + i * 5])
            self.newServo(2 + i * 4, [1, 10 + i * 5])
            self.newServo(3 + i * 4, [1, 11 + i * 5])
            self.addSpace([0, 12 + i * 5])

        #setup right side, 4 groups of 4 servo controls
        for i in xrange(4):
            self.newServo(16 + i * 4, [11, 8 + i * 5])
            self.newServo(17 + i * 4, [11, 9 + i * 5])
            self.newServo(18 + i * 4, [11, 10 + i * 5])
            self.newServo(19 + i * 4, [11, 11 + i * 5])
            self.addSpace([11, 12 + i * 5])

        #add some spaces for asthetics
        self.addSpace([10, 1])

        # generate buttons for all move functions
        counter = 0
        for move_name in dir(self):
            if "move_" in move_name:
                b = Button(
                    self.frame,
                    text=move_name[5:],
                    command=lambda func=getattr(self, "move_" + move_name[
                        5:]): servotorComm.runMovement(func))
                b.grid(row=counter + 8, column=0)
                #b.pack()
                counter += 1

        #servoBars = []

        self.poll()
        self.estop()