Initial Commit
This commit is contained in:
15
GestureRecognition/HandRecognition.py
Normal file
15
GestureRecognition/HandRecognition.py
Normal file
@@ -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:
|
||||||
|
|
||||||
BIN
GestureRecognition/IMG_0818.png
Normal file
BIN
GestureRecognition/IMG_0818.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 MiB |
124
MotorControl/ESC.py
Normal file
124
MotorControl/ESC.py
Normal file
@@ -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!!"
|
||||||
@@ -2,22 +2,29 @@ import time
|
|||||||
|
|
||||||
from RPi import GPIO
|
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
|
This module provides an interface for interacting with
|
||||||
the motor on the Traxxas Slash using a Raspberry Pi
|
the motor on the Traxxas Slash using a Raspberry Pi
|
||||||
3B+.
|
3B+.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
class MotorController:
|
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._duty_cycle = duty_cycle
|
||||||
self._operating_frequency = frequency
|
self._operating_frequency = frequency
|
||||||
self._running = False
|
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.setmode(GPIO.OUT)
|
||||||
GPIO.setup(self._control_pin, self._operating_frequency)
|
GPIO.setup(self.pin_number, self._operating_frequency)
|
||||||
self._control_pin = GPIO.PWM(control_pin, self._duty_cycle)
|
self._control_pin = GPIO.PWM(self.pin_number, self._duty_cycle)
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def duty_cycle(self):
|
def duty_cycle(self):
|
||||||
@@ -28,6 +35,7 @@ class MotorController:
|
|||||||
if value > 0 and value < 100:
|
if value > 0 and value < 100:
|
||||||
self._duty_cycle = value
|
self._duty_cycle = value
|
||||||
# Change the current duty cycle of the GPIO.
|
# Change the current duty cycle of the GPIO.
|
||||||
|
self.control.changeDutyCycle
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if self._running:
|
if self._running:
|
||||||
@@ -38,4 +46,33 @@ class MotorController:
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
self._control_pin.stop()
|
self._control_pin.stop()
|
||||||
|
|
||||||
|
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
|
||||||
|
|||||||
BIN
malima_SIU06.pdf
Normal file
BIN
malima_SIU06.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user