diff --git a/GestureRecognition/HandRecognition.py b/GestureRecognition/HandRecognition.py new file mode 100644 index 0000000..74bf9d7 --- /dev/null +++ b/GestureRecognition/HandRecognition.py @@ -0,0 +1,15 @@ +from PIL import Image +from PIL import ImageDraw + +img = Image.open('/Users/piv/Desktop/IMG_0818.png') + +# Create a new image of the cutout. +blkimg = Image.new('1', (img.width, img.height) +blkdraw = ImageDraw.Draw(blkimg) + +for i in range(1, img.width): + for j in range(1, img.height): + # getpixel returns tuple (r,g,b,a) + pixel = img.getpixel((i, j)) + if (pixel[0]/pixel[1]) > 1.05 and (pixel[0]/pixel[1]) < 4: + diff --git a/GestureRecognition/IMG_0818.png b/GestureRecognition/IMG_0818.png new file mode 100644 index 0000000..b4f9d25 Binary files /dev/null and b/GestureRecognition/IMG_0818.png differ diff --git a/MotorControl/ESC.py b/MotorControl/ESC.py new file mode 100644 index 0000000..d5e964e --- /dev/null +++ b/MotorControl/ESC.py @@ -0,0 +1,124 @@ +# This program will let you test your ESC and brushless motor. +# Make sure your battery is not connected if you are going to calibrate it at first. +# Since you are testing your motor, I hope you don't have your propeller attached to it otherwise you are in trouble my friend...? +# This program is made by AGT @instructable.com. DO NOT REPUBLISH THIS PROGRAM... actually the program itself is harmful pssst Its not, its safe. + +import os #importing os library so as to communicate with the system +import time #importing time library to make Rpi wait because its too impatient +os.system ("sudo pigpiod") #Launching GPIO library +time.sleep(1) # As i said it is too impatient and so if this delay is removed you will get an error +import pigpio #importing GPIO library + +ESC=4 #Connect the ESC in this GPIO pin + +pi = pigpio.pi(); +pi.set_servo_pulsewidth(ESC, 0) + +max_value = 2000 #change this if your ESC's max value is different or leave it be +min_value = 1000 #change this if your ESC's min value is different or leave it be +print "For first time launch, select calibrate" +print "Type the exact word for the function you want" +print "calibrate OR manual OR control OR arm OR stop" + +def manual_drive(): #You will use this function to program your ESC if required + print "You have selected manual option so give a value between 0 and you max value" + while True: + inp = raw_input() + if inp == "stop": + stop() + break + elif inp == "control": + control() + break + elif inp == "arm": + arm() + break + else: + pi.set_servo_pulsewidth(ESC,inp) + +def calibrate(): #This is the auto calibration procedure of a normal ESC + pi.set_servo_pulsewidth(ESC, 0) + print("Disconnect the battery and press Enter") + inp = raw_input() + if inp == '': + pi.set_servo_pulsewidth(ESC, max_value) + print("Connect the battery NOW.. you will here two beeps, then wait for a gradual falling tone then press Enter") + inp = raw_input() + if inp == '': + pi.set_servo_pulsewidth(ESC, min_value) + print "Wierd eh! Special tone" + time.sleep(7) + print "Wait for it ...." + time.sleep (5) + print "Im working on it, DONT WORRY JUST WAIT....." + pi.set_servo_pulsewidth(ESC, 0) + time.sleep(2) + print "Arming ESC now..." + pi.set_servo_pulsewidth(ESC, min_value) + time.sleep(1) + print "See.... uhhhhh" + control() # You can change this to any other function you want + +def control(): + print "I'm Starting the motor, I hope its calibrated and armed, if not restart by giving 'x'" + time.sleep(1) + speed = 1500 # change your speed if you want to.... it should be between 700 - 2000 + print "Controls - a to decrease speed & d to increase speed OR q to decrease a lot of speed & e to increase a lot of speed" + while True: + pi.set_servo_pulsewidth(ESC, speed) + inp = raw_input() + + if inp == "q": + speed -= 100 # decrementing the speed like hell + print "speed = %d" % speed + elif inp == "e": + speed += 100 # incrementing the speed like hell + print "speed = %d" % speed + elif inp == "d": + speed += 10 # incrementing the speed + print "speed = %d" % speed + elif inp == "a": + speed -= 10 # decrementing the speed + print "speed = %d" % speed + elif inp == "stop": + stop() #going for the stop function + break + elif inp == "manual": + manual_drive() + break + elif inp == "arm": + arm() + break + else: + print "WHAT DID I SAID!! Press a,q,d or e" + +def arm(): #This is the arming procedure of an ESC + print "Connect the battery and press Enter" + inp = raw_input() + if inp == '': + pi.set_servo_pulsewidth(ESC, 0) + time.sleep(1) + pi.set_servo_pulsewidth(ESC, max_value) + time.sleep(1) + pi.set_servo_pulsewidth(ESC, min_value) + time.sleep(1) + control() + +def stop(): #This will stop every action your Pi is performing for ESC ofcourse. + pi.set_servo_pulsewidth(ESC, 0) + pi.stop() + +#This is the start of the program actually, to start the function it needs to be initialized before calling... stupid python. +inp = raw_input() +if inp == "manual": + manual_drive() +elif inp == "calibrate": + calibrate() +elif inp == "arm": + arm() +elif inp == "control": + control() +elif inp == "stop": + stop() +else : + print "Thank You for not following the things I'm saying... now you gotta restart the program STUPID!!" diff --git a/MotorControl/motor.py b/MotorControl/motor.py index a2258f5..e0cebb8 100644 --- a/MotorControl/motor.py +++ b/MotorControl/motor.py @@ -2,22 +2,29 @@ import time from RPi import GPIO -"""This module controls the Motor and Servo module. +"""This module controls the Motor and Servo control. This module provides an interface for interacting with the motor on the Traxxas Slash using a Raspberry Pi 3B+. """ +""" + +""" class MotorController: - def __init__(self, control_pin, frequency, duty_cycle=0): + def __init__(self, pin_number, frequency, duty_cycle=0): self._duty_cycle = duty_cycle self._operating_frequency = frequency self._running = False + self.pin_number = pin_number + + # Pulse width was mentioned to be 6-7.2% by uni group. GPIO.setmode(GPIO.OUT) - GPIO.setup(self._control_pin, self._operating_frequency) - self._control_pin = GPIO.PWM(control_pin, self._duty_cycle) + GPIO.setup(self.pin_number, self._operating_frequency) + self._control_pin = GPIO.PWM(self.pin_number, self._duty_cycle) + @property def duty_cycle(self): @@ -28,6 +35,7 @@ class MotorController: if value > 0 and value < 100: self._duty_cycle = value # Change the current duty cycle of the GPIO. + self.control.changeDutyCycle def start(self): if self._running: @@ -38,4 +46,33 @@ class MotorController: def stop(self): self._control_pin.stop() - \ No newline at end of file + def arm(self): + +class MotorDetails: + def __init__(self): + + @property + def minDutyCycle(self): + return self._minDutyCycle + + @minDutyCycle.setter + def minDutyCycle(self, value): + self._minDutyCycle = value + + @property + def maxDutyCycle(self): + return self._maxDutyCycle + + @maxDutyCycle.setter + def maxDutyCycle(self, value): + self._maxDutyCycle = value + + @property + def idle(self): + return self._idle + + + +max_reverse = 1000 +idle = 1500 +max_forward = 2000 diff --git a/malima_SIU06.pdf b/malima_SIU06.pdf new file mode 100644 index 0000000..f761a05 Binary files /dev/null and b/malima_SIU06.pdf differ