Esempio n. 1
0
    def __init__(self, currentNumOfSensors, sType, pins, partNumber,
                 currentCount):
        wires = numpy.empty(
            len(pins), dtype=object
        )  # TODO wires = ndarray((len(pins),),int) OR wires = [None] * len(pins) 				# Create an array on same length as pins[?, ?, ?]
        for i in pins:
            self.wires[i] = pins[i]

        self.DebugObject = Debug(True, "Sensor.py")
Esempio n. 2
0
	def __init__(self, aType, actuatorID, pins, partNumber, direction):
		"""
		Constructor to initialize an Actutator object, which can be an AngularServo(), Motor(), or Relay()

		Key arguments:
		self - Newly created object
		aType - Single String character to select type of actuator to create (S=Servo, M=Motor, R=Relay)
		actuatorID - Interger CONSTANT defined in Driver.py to enable quick array searches
		pins - Array to document wires / pins being used by Raspberry Pi to control an actuator
		partNumber - Vendor part number string variable (e.g. Seamuing MG996R)
		direction - Set counter-clockwise (CCW) / Linear IN or clockwise (CW) / Linear OUT as the forward direction

		Return value:
		Newly created Actuator() object
	    """

		currentProgramFilename = os.path.basename(__file__)
		self.DebugObject = Debug(True, currentProgramFilename)

		self.actuatorID = actuatorID
		self.actuatorType = aType

		numOfWires = len(pins)
		wires = np.empty(numOfWires, dtype=object)   # TODO wires = ndarray((len(pins),),int) OR wires = [None] * len(pins) 				# Create an array on same length as pins[?, ?, ?]
		for i in range(numOfWires):
			#TODO REMOVE print("PIN: "  + repr(i))
			self.wires[i] = pins[i]

		self.partNumber = partNumber
		self.forwardDirection = direction

		# The last wire in array is the PWM control pin
		tempServoObject = Servo(pins[0]) #TODO REMOVE BECAUSE TO SIMPLE AN OBJECT
		#tempServoObject = gpiozero.Servo(pins[0]) #TODO REMOVE BECAUSE TO SIMPLE AN OBJECT
		tempAngularServoObject = AngularSevo(wires[len(wires)-1])

    	# The last two wires in array are the INPUT control pins
		tempMotorObject = Motor(wires[len(wires)-2], wires[len(wires)-1])

	    # The last wire in array is the relay control pin
		tempRelayObject = OutputDevice(wires[len(wires)-1])

	    # https://gist.github.com/johnwargo/ea5edc8516b24e0658784ae116628277
	    # https://gpiozero.readthedocs.io/en/stable/api_output.html
	    # https://stackoverflow.com/questions/14301967/bare-asterisk-in-function-arguments/14302007#14302007
		if(aType == "S"):
			self.actuatorObject = tempAngularServoObject
			#TODO If above DOES NOT WORK: self.actuatorType = Servo(wires[0], initial_value=0, min_pulse_width=1/1000, max_pulse_width=2/1000, frame_width=20/1000, pin_factory=None)
		elif(aType == "M"):
			self.actuatorObject = tempMotorObject
			#TODO If above DOES NOT WORK: self.actuatorType = Motor(wires[0], wires[1], pwm=true, pin_factory=None)
		elif(aType == "R"):
			self.actuatorObject = tempRelayObject
			#TODO If above DOES NOT WORK: self.actuatorObject = gpiozero.OutputDevice(wired[0], active_high=False, initial_value=False)
		else:
			self.DebugObject.Dprint("INVALID Actutator Type in __init__ method, please use S, M, or R string as first parameter to Actuator() Object")
Esempio n. 3
0
def SwapTool(newTool):
    """
    Change end effector tool connected to the 3-axis + rotational motor crane system

    newTool - Name of new tool to cennect to the crane system

    return NOTHING
    """

    if(currentTool == newTool):
        Debug.Dprint(Debug(True), "DO NOTHING")
    elif(newTool == DRILL_BIT_TOOL):
        GoToToolHome()
        LockOldTool()
        UnlockNewTool()
    elif(newTool == TAPPING_SOCKET_TOOL):
        GoToToolHome()
        LockOldTool()
        UnlockNewTool()
    else:
        Debug.Dprint(Debug(True), "ERROR: You attempted to use a tool not supported by Tapomatic v" + VERSION)
Esempio n. 4
0
 def __init__(self):
     super(Level, self).__init__()
     self.debug = Debug.Debug()
     self.timer = Timer.Timer()
     self.draglist = []
     self.shadow_blocks = []
     self.tooltips = []
     self.shadow_drawable = True
     size = int(settings.WINDOWWIDTH / 8)
     self.img_size = size
     self.recycle = Recycle.Recycle(size)
     self.cook = CookButton.CookButton(size)
Esempio n. 5
0
    def __init__(self, drinkNameID, addOnFlavor, addOnFlavorLevel,
                 addOnHealthAdditive, addOnHealthAdditiveLevel, tapOrCutFlow,
                 brandingArt):
        """
		Constructor to initialize an CocoDrink() object, which stores add-ons and artwork

		Key arguments:
		self -- Newly created CocoDrink object
		drinkNameID -- CONSTANT product name of drink
		addOnFlavor -- CONSTANT product name of flavoring being added to base drink (e.g. IMMUNITY_BOOST, PINA_COLADA, etc)
		addOnFlavorLevel -- The unit step amount of flavor to be added to a drink from 0 to MAX_ADD_ON_LEVEL
							Each unit is a different but constant volume (in milliLiters) for each flavor
		addOnHealthAdditive -- CONSTANT product name of  health additive being added to base liquid
		addOnHealthAdditiveLevel -- The unit step amount of additive to be added to a drink from 0 to MAX_ADD_ON_LEVEL
									Each discrete unit is a differnt but constant volume (in milliLiters) for each additive
		tapOrCutFlow -- Variable used as conditional in program flow to determin if coconut is topped off or tapped 
		brandingArt -- PNG image to LASER brand onto the side of the coconut (max size is 200 MB or ? x ? pixels / ? x ? inches)

		Return value:
		New CocoDrink() object
		"""

        currentProgramFilename = os.path.basename(__file__)
        self.DebugObject = Debug(True, currentProgramFilename)

        self.drinkNameID = drinkNameID
        self.addOnFlavor = addOnFlavor
        self.addOnFlavorLevel = addOnFlavorLevel
        self.addOnHealthAdditive = addOnHealthAdditive
        self.addOnHealthAdditiveLevel = addOnHealthAdditiveLevel
        self.tapOrCutFlow = tapOrCutFlow  #TODO REMOVE - LIKELY NOT GOING TO BE SUPPORTED IN v2020.1
        self.brandingArt = brandingArt

        if (addOnFlavorLevel > CocoDrink.MAX_ADD_ON_LEVEL
                or addOnHealthAdditiveLevel > CocoDrink.MAX_ADD_ON_LEVEL):
            self.DebugObject.Dprint(
                "OBJECT CREATION ERROR: You created a CocoDrink() object with add-on level greater then "
                + MAX_ADD_ON_LEVEL)
            __exit__()  # Destructor / memory clean up

        if (addOnFlavorLevel < 0 or addOnHealthAdditiveLevel < 0):
            self.DebugObject.Dprint(
                "OBJECT CREATION ERROR: You created a CocoDrink() object with add-on level less then "
                + MIN_ADD_ON_LEVEL)
            __exit__()  # Destructor / memory clean up

        if (CocoDrink.NO_DRINK > drinkNameID
                or drinkNameID > CocoDrink.MAX_DRINK_NAME):
            self.DebugObject.Dprint(
                "OBJECT CREATION ERROR: You created a CocoDrink() object with a drink name that doesn't exist. Why did you do that genius?"
            )
            __exit__()  # Destructor / memory clean up
Esempio n. 6
0
    def __init__(self, gpioFirePin, supplierPartNumber, cocoPartNumber,
                 powerLevel, maxPowerLevel, brandingArt):
        """
	    Create a LASER object with power settings, part numbers, and image data to used when fired via GPIO pin

	    Key arguments:
        gpioFirePin -- 5V GPIO pin used to control a LASER or a 12V relay connected to a LASER
	    supplierPartNumber -- External supplier part number (i.e. PA-07-12-5V)
	    cocoPartNumber -- Internal part number (i.e XXX-YYYYY-Z)) linked to one supplier part number
	    powerLevel -- Power in Wats to intialize a LASER module first fire to
	    maxPowerLevel -- Max power in Watts that LASER can support in continous operation (> 30 seconds)
	    brandingArt -- Black & White PNG image to brand / burn into an object

	    Return value:
	    New LASER() object
	    """

        currentProgramFilename = os.path.basename(__file__)
        self.DebugObject = Debug(True, currentProgramFilename)

        #self.gpioFirePin = gpiozero.OutputDevice(gpioFirePin)

        self.supplierPartNumber = supplierPartNumber

        if (len(cocoPartNumber) != 10):
            self.DebugObject.Dprint(
                "Invalid part number format, please verify part number looks like XXX-YYYYY-Z"
            )

        # List of current valid internal LASER part numbers
        if (cocoPartNumber == "205-0003-A" or cocoPartNumber == "???-????-?"):
            self.cocoPartNumber = cocoPartNumber
        else:
            self.DebugObject.Dprint("Invalid part number format")

        if (0 > powerLevel or powerLevel > LASER.MAX_POWER_LEVEL):
            # Check for valid power level and default to 10 Watts if invalid
            Debug.Dprint(
                DebugOject, "Invalid power. I'm  setting the LASER power to " +
                repr(self.maxPowerLevel / 2) + " Watts")
            self.powerLevel = self.MAX_POWER_LEVEL / 2
        else:
            self.powerLevel = powerLevel

        self.brandingArt = LASER.__WarpImage(
            CocoDrink.COCOTAPS_LOGO,
            CocoDrink.SIZE_102MM)  # Initialize to standard CocoTaps logo

        LASER.__ConfigureLaserForNewImage(self.brandingArt)
Esempio n. 7
0
    from signal import pause

    # Allow control of input and out pins
    from gpiozero import OutputDevice, InputDevice

    # Check status of network / new device IP addresses and Pi hardware
    from gpiozero import PingServer, pi_info

    # Useful pin status tools and math tools
    from gpiozero.tools import all_values, negated, sin_values

    # Useful for controlling devices based on date and time
    from gpiozero import TimeOfDay

except ImportError:
    DebugObject = Debug(True)
    Debug.Dprint(
        DebugObject,
        "WARNING: You are running code on Mac or PC (NOT a Raspberry Pi 4), thus hardware control is not possible."
    )


def GetMillimeters(pin):
    """
    Get distance to closest object in direct line of sight for PING LASER rangefinder
    
    Key arguments:
    pin -- GPIO pin PING sensor is connected to
    
    Return value:
    range -- Distance in mm to closest object 
Esempio n. 8
0
    return render_template(HTMLtoDisplay)


@app.route('/Complete')
def CompleteScreen():
    """
	GUI to display COMPLETE.
	HTTP GET Method
	:return: HTML template to display complete.html
	"""
    HTMLtoDisplay = "complete.html"
    return render_template(HTMLtoDisplay)


if __name__ == '__main__':
    DebugOject = Debug(True, "GUI.py")
    app.run(debug=True)
    if (DebugOject.GetMode == True):
        # Allow URLs to be refreshed (F5) without restarting web server after code changes
        app.run(debug=True)
        check_call("export FLASK_DEBUG=1", shell=True)
    else:
        app.run(debug=False)  # check_call("export FLASK_DEBUG=0", shell=True)
        app.run(host='0.0.0.0')

    # #WelcomeScreen()
    # #TODO Add button code
    # #sleep(3)
    # TapOrCutScreen()
    #
    # print("Sleeping Worked")
Esempio n. 9
0
        # Receiving data from the UDP Server.
        data, addr = udpClientSocket.recvfrom(DATA_BUFFER_SIZE)
        # TODO Debug.Dprint(driverDebugObject, "received message: " + data)
        logging.info('received message:', data) #TODO LOGGING NOT WORKING, HAVE TO FIX
        #TODO Write code to handle this data

        now = datetime.now(timezone.utc)
        endTimeStampMicroSec = (now - epoch)//timedelta(microsecond=1)

        timeout = timeout - (endTimeStampMicroSec/1000 - startTimeStampMicroSec/1000)


if __name__ == "__main__":

    driverDebugObject = Debug(True, "Driver.py")

    #actuatorObjects = np.array(MAX_NUM_OF_ACTUATORS)

    currentTool = NO_TOOL           # Default is having no tool attached to 3-axis system
    currentKnifeSectionInUse = 0    # Always attempt to used section 0 when code restarts

    numberOfOrdersCompleted = 0
    numberOfOrdersInProgress = 0
    #TODO tempDrink = CocoDrink2(CocoDrink2.NONE, CocoDrink2.NONE, CocoDrink2.NONE, CocoDrink2.NONE, CocoDrink2.NONE, CocoDrink2.NONE, CocoDrink2.NONE, CocoDrink2.NONE)
    #TODO tempDrink = CocoDrink(CocoDrink.NONE, CocoDrink.NONE, CocoDrink.NONE, CocoDrink.NONE, CocoDrink.NONE, CocoDrink.NONE, CocoDrink.NONE, CocoDrink.NONE)
    vendQueue = np.array(MAX_VEND_QUEUE_SIZE)

    GuiPi = RaspPi()
    BackendPi = RaspPi()
Esempio n. 10
0
"""

# Useful standard Python system jazz
import sys, time, traceback, argparse, string

# Robotic Beverage Technologies code for custom data logging and terminal debugging output
from Debug import *

try:
    # OpenCV magic
    # https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_table_of_contents_imgproc/py_table_of_contents_imgproc.html
    import cv2
    import numpy as np

except ImportError:
    ImportDebugObject = Debug(True, "ComputerVision.py")
    Debug.Dprint(ImportDebugObject, "Run ComputerVision.py with python not PYTHON3")


# Create a command line parser
# parser = argparse.ArgumentParser(prog = "Tapomatic Computer Vision", description = __doc__, add_help=True)
# parser.add_argument("-f", "--filename", type=str, default="Update.py", help="Local or cloud software to be loaded on ki$
# parser.add_argument("-l", "--loop", type=int, default=0, help="Set to 1 to loop this driver program.")
# args = parser.parse_args()

##GUIDE TO BEGINNERS
##Treat the Image as a matrix and that is how computers see and store the images.
## [x,y]

class ComputerVision():
    def printImageForTestingPurpose(self, name, img):
Esempio n. 11
0
	# Check status of network / new device IP addresses and Pi hardware
	from gpiozero import PingServer, pi_info

	# Useful pin status tools and math tools
	from gpiozero.tools import all_values, negated, sin_values

	# Useful for controlling devices based on date and time
	from gpiozero import TimeOfDay

	# Allow control of output devices such as Motors, Servos, LEDs, and Relays
	from gpiozero import Motor, Servo, LED, Energenie, OutputDevice

except ImportError:
	#TODO DO LOW LEVEL PIN CONTROL THAT WORKS EVER WHERE? http://wiringpi.com/the-gpio-utility/
	currentProgramFilename = os.path.basename(__file__)
	ImportDebugObject = Debug(True, currentProgramFilename)
	ImportDebugObject.Dprint("WARNING: You are running code on Mac or PC (NOT a Raspberry Pi 4), thus hardware control is not possible.")


class Actuator:

	# Class attributes that can be accessed using ActuatorControl.X (not actuatorcontrol.X)
	MAX_NUM_OF_SERVOS = 0		# Circular servos
	MAX_NUM_OF_MOTORS = 12		# Circular stepper or brushless DC motors
	MAX_NUM_OF_LINEAR_ACT = 5 	# Linear actuators
	N_A = 0						# Not Applicable

	# Circular & linear actuator direction CONSTANTS
	CCW = -1  			# Counter-Clockwise
	CW = 1    			# Clockwise
	LINEAR_IN = CCW		# Towardsbase of linear actuator
Esempio n. 12
0
from Debug import *

# Allow program to extract filename of the current file
import os

try:
    # Robotic Beverage Technologies code for controlling many different types of motors, servos, and relays
    from Actuator import *

    # Robotic Beverage Technologies code for controlling the physical movement and power output of a LASER
    from LASER import *

except ImportError:
    #TODO DO LOW LEVEL PIN CONTROL THAT WORKS EVER WHERE? http://wiringpi.com/the-gpio-utility/
    currentProgramFilename = os.path.basename(__file__)
    TempDebugObject = Debug(
        True, "Try/Catch ImportError in " + currentProgramFilename)
    TempDebugObject.Dprint(
        "WARNING - You are running code on Mac or PC (NOT a Raspberry Pi 4), thus hardware control is not possible."
    )


class CocoDrink:

    # Drink Name CONSTANTS
    NONE = "NONE"
    NO_DRINK = 0
    COCONUT = 1
    MAX_DRINK_NAME = COCONUT

    # Coconut sizing CONSTANTS
    SIZE_102MM = 102
Esempio n. 13
0
def create_instance(c_instance):
    """ Creates and returns the Base script """
    return Debug.Debug(c_instance)
Esempio n. 14
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import Debug as debug

reload(sys)
sys.setdefaultencoding('utf-8')

debug_log = debug.Debug("test.log", True)


def test():
    log_msg = "%s test example." % debug.comm_get_func_head_info()
    debug_log.debug_write_log(log_msg)

    string = "test"
    log_msg = "%s test example. %s" % (debug.comm_get_func_head_info(), string)
    debug_log.debug_write_log(log_msg)


if __name__ == '__main__':
    test()
Esempio n. 15
0
 def __init__(self):
     self.DebugObject = Debug(True)