Permalink
Browse files

Initial Commit

Added:
1) Arduino Source
2) web2py Source
3) Leap Motion Source
  • Loading branch information...
Yusuf Kaka
Yusuf Kaka committed May 30, 2014
1 parent b76ff59 commit e7fd278aa63fa8aa509bbd4cc72345123b7688f9
Showing with 8,687 additions and 1 deletion.
  1. +57 −0 Arduino/src/laser_serial/laser_serial.ino
  2. +1,068 −0 Leap/turret_ctrl/Leap.py
  3. BIN Leap/turret_ctrl/Leap.pyc
  4. BIN Leap/turret_ctrl/LeapPython.so
  5. BIN Leap/turret_ctrl/libLeap.dylib
  6. +171 −0 Leap/turret_ctrl/turret_ctl.py
  7. +6 −1 README.md
  8. +2 −0 web2py/applications/Lazer_Turret/ABOUT
  9. 0 web2py/applications/Lazer_Turret/__init__.py
  10. BIN web2py/applications/Lazer_Turret/__init__.pyc
  11. 0 web2py/applications/Lazer_Turret/cache/cache.lock
  12. +431 −0 web2py/applications/Lazer_Turret/controllers/appadmin.py
  13. +99 −0 web2py/applications/Lazer_Turret/controllers/default.py
  14. +99 −0 web2py/applications/Lazer_Turret/controllers/default.py.bak
  15. +1 −0 web2py/applications/Lazer_Turret/cron/crontab
  16. +109 −0 web2py/applications/Lazer_Turret/databases/c8b669d15150d7109e5f7ab36744a5b7_auth_cas.table
  17. +109 −0 web2py/applications/Lazer_Turret/databases/c8b669d15150d7109e5f7ab36744a5b7_auth_event.table
  18. +59 −0 web2py/applications/Lazer_Turret/databases/c8b669d15150d7109e5f7ab36744a5b7_auth_group.table
  19. +59 −0 web2py/applications/Lazer_Turret/databases/c8b669d15150d7109e5f7ab36744a5b7_auth_membership.table
  20. +92 −0 web2py/applications/Lazer_Turret/databases/c8b669d15150d7109e5f7ab36744a5b7_auth_permission.table
  21. +188 −0 web2py/applications/Lazer_Turret/databases/c8b669d15150d7109e5f7ab36744a5b7_auth_user.table
  22. +68 −0 web2py/applications/Lazer_Turret/databases/c8b669d15150d7109e5f7ab36744a5b7_settings.table
  23. +74 −0 web2py/applications/Lazer_Turret/databases/sql.log
  24. BIN web2py/applications/Lazer_Turret/databases/storage.sqlite
  25. +531 −0 ...plications/Lazer_Turret/errors/127.0.0.1.2014-05-30.18-59-26.19ef30c1-412a-4f45-a372-0d36916e72dd
  26. +473 −0 ...plications/Lazer_Turret/errors/127.0.0.1.2014-05-30.19-07-42.085c4c9b-8b8f-4b23-870b-4a04ab227b61
  27. +131 −0 web2py/applications/Lazer_Turret/languages/cs-cz.py
  28. +260 −0 web2py/applications/Lazer_Turret/languages/es-es.py
  29. +168 −0 web2py/applications/Lazer_Turret/languages/fr-ca.py
  30. +156 −0 web2py/applications/Lazer_Turret/languages/fr-fr.py
  31. +83 −0 web2py/applications/Lazer_Turret/languages/hi-hi.py
  32. +94 −0 web2py/applications/Lazer_Turret/languages/hu-hu.py
  33. +94 −0 web2py/applications/Lazer_Turret/languages/hu.py
  34. +108 −0 web2py/applications/Lazer_Turret/languages/it-it.py
  35. +108 −0 web2py/applications/Lazer_Turret/languages/it.py
  36. +82 −0 web2py/applications/Lazer_Turret/languages/pl-pl.py
  37. +105 −0 web2py/applications/Lazer_Turret/languages/pl.py
  38. +143 −0 web2py/applications/Lazer_Turret/languages/pt-br.py
  39. +117 −0 web2py/applications/Lazer_Turret/languages/pt-pt.py
  40. +117 −0 web2py/applications/Lazer_Turret/languages/pt.py
  41. +97 −0 web2py/applications/Lazer_Turret/languages/ru-ru.py
  42. +112 −0 web2py/applications/Lazer_Turret/languages/sk-sk.py
  43. +166 −0 web2py/applications/Lazer_Turret/languages/zh-tw.py
  44. +19 −0 web2py/applications/Lazer_Turret/models/0.py
  45. +120 −0 web2py/applications/Lazer_Turret/models/db.py
  46. +209 −0 web2py/applications/Lazer_Turret/models/db.py.bak
  47. +89 −0 web2py/applications/Lazer_Turret/models/db_configure.py.bak
  48. +2 −0 web2py/applications/Lazer_Turret/models/db_wizard.py
  49. +3 −0 web2py/applications/Lazer_Turret/models/db_wizard_populate.py
  50. +8 −0 web2py/applications/Lazer_Turret/models/menu.py
  51. +1 −0 web2py/applications/Lazer_Turret/modules/__init__.py
  52. BIN web2py/applications/Lazer_Turret/modules/__init__.pyc
  53. +20 −0 web2py/applications/Lazer_Turret/modules/arduino_serial.py
  54. +20 −0 web2py/applications/Lazer_Turret/modules/arduino_serial.py.bak
  55. BIN web2py/applications/Lazer_Turret/modules/arduino_serial.pyc
  56. +1 −0 web2py/applications/Lazer_Turret/private/auth.key
  57. +44 −0 web2py/applications/Lazer_Turret/progress.log
  58. +65 −0 web2py/applications/Lazer_Turret/sessions/127.0.0.1-db29a339-b902-4e36-948c-97a651bfc96f
  59. +7 −0 web2py/applications/Lazer_Turret/static/css/calendar.css
  60. +629 −0 web2py/applications/Lazer_Turret/static/css/skeleton.css
  61. +152 −0 web2py/applications/Lazer_Turret/static/css/superfish.css
  62. +351 −0 web2py/applications/Lazer_Turret/static/css/web2py.css
  63. BIN web2py/applications/Lazer_Turret/static/favicon.ico
  64. BIN web2py/applications/Lazer_Turret/static/favicon.png
  65. BIN web2py/applications/Lazer_Turret/static/images/arrows-ffffff.png
  66. BIN web2py/applications/Lazer_Turret/static/images/css3buttons_backgrounds.png
  67. BIN web2py/applications/Lazer_Turret/static/images/css3buttons_icons.png
  68. BIN web2py/applications/Lazer_Turret/static/images/poweredby.png
  69. BIN web2py/applications/Lazer_Turret/static/images/shadow.png
  70. BIN web2py/applications/Lazer_Turret/static/images/ui-icons_222222_256x240.png
  71. +42 −0 web2py/applications/Lazer_Turret/static/js/calendar.js
  72. +13 −0 web2py/applications/Lazer_Turret/static/js/dd_belatedpng.js
  73. +1 −0 web2py/applications/Lazer_Turret/static/js/jquery.js
  74. +4 −0 web2py/applications/Lazer_Turret/static/js/modernizr.custom.js
  75. +223 −0 web2py/applications/Lazer_Turret/static/js/superfish.js
  76. +160 −0 web2py/applications/Lazer_Turret/static/js/web2py.js
  77. +2 −0 web2py/applications/Lazer_Turret/static/robots.txt
  78. +1 −0 web2py/applications/Lazer_Turret/views/__init__.py
  79. +232 −0 web2py/applications/Lazer_Turret/views/appadmin.html
  80. +3 −0 web2py/applications/Lazer_Turret/views/default/error.html
  81. +19 −0 web2py/applications/Lazer_Turret/views/default/index.html
  82. +19 −0 web2py/applications/Lazer_Turret/views/default/index.html.bak
  83. +19 −0 web2py/applications/Lazer_Turret/views/default/user.html
  84. +16 −0 web2py/applications/Lazer_Turret/views/generic.html
  85. +1 −0 web2py/applications/Lazer_Turret/views/generic.json
  86. +16 −0 web2py/applications/Lazer_Turret/views/generic.jsonp
  87. +30 −0 web2py/applications/Lazer_Turret/views/generic.load
  88. BIN web2py/applications/Lazer_Turret/views/generic.pdf
  89. +10 −0 web2py/applications/Lazer_Turret/views/generic.rss
  90. +1 −0 web2py/applications/Lazer_Turret/views/generic.xml
  91. +170 −0 web2py/applications/Lazer_Turret/views/layout.html
  92. +14 −0 web2py/applications/Lazer_Turret/views/web2py_ajax.html
  93. +114 −0 web2py/applications/Lazer_Turret/wizard.metadata
@@ -0,0 +1,57 @@
#include <TinkerKit.h>
#include <Servo.h>
TKLed led(O2);
Servo servo1;
Servo servo2;
void setup()
{
servo1.attach(O0);
servo2.attach(O1);
Serial.begin(9600);
Serial.println("Power on, Ready.");
}
void loop()
{
static int v = 0;
if ( Serial.available()) {
char ch = Serial.read();
switch(ch) {
case '0'...'9':
v = v * 10 + ch - '0';
break;
case 'x':
servo1.write(v);
v = 0;
Serial.print(servo1.read());
Serial.print(',');
Serial.println(servo2.read());
break;
case 'a':
led.on();
break;
case 'z':
led.off();
break;
case 'y':
servo2.write(v);
v = 0;
Serial.print(servo1.read());
Serial.print(',');
Serial.println(servo2.read());
break;
//case 'd':
// servo2.detach();
// break;
//case 'a':
// servo2.attach(15);
// break;
}
}
}
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,171 @@
################################################################################
# Copyright (C) 2012-2013 Leap Motion, Inc. All rights reserved. #
# Leap Motion proprietary and confidential. Not for distribution. #
# Use subject to the terms of the Leap Motion SDK Agreement available at #
# https://developer.leapmotion.com/sdk_agreement, or another agreement #
# between Leap Motion and you, your company or other organization. #
################################################################################
import Leap, sys
import urllib2,base64
from Leap import CircleGesture, KeyTapGesture, ScreenTapGesture, SwipeGesture
class SampleListener(Leap.Listener):
def on_init(self, controller):
# self.base_url = "http://10.237.200.6/Laser_Turret/default/call/run/move?a="
self.base_url = "http://127.0.0.1:8000/Lazer_Turret/default/call/run/move?a="
self.positionX = 90
self.positionY = 90
# base64string = base64.encodestring('%s:%s' % ("leap", "leap123")).replace('\n', '')
# self.moveRequest.add_header("Authorization", "Basic %s" % base64string)
request = urllib2.Request(self.base_url+"a90x90y")
urllib2.urlopen(request).read()
print "Initialized"
def on_connect(self, controller):
print "Connected"
# Enable gestures
controller.enable_gesture(Leap.Gesture.TYPE_CIRCLE);
controller.enable_gesture(Leap.Gesture.TYPE_KEY_TAP);
controller.enable_gesture(Leap.Gesture.TYPE_SCREEN_TAP);
controller.enable_gesture(Leap.Gesture.TYPE_SWIPE);
def on_disconnect(self, controller):
# Note: not dispatched when running in a debugger.
print "Disconnected"
def on_exit(self, controller):
request = urllib2.Request(self.base_url+"z90x90y")
urllib2.urlopen(request).read()
print "Exited"
def on_frame(self, controller):
# Get the most recent frame and report some basic information
frame = controller.frame()
print "Frame id: %d, timestamp: %d, hands: %d, fingers: %d, tools: %d, gestures: %d" % (
frame.id, frame.timestamp, len(frame.hands), len(frame.fingers), len(frame.tools), len(frame.gestures()))
if not frame.hands.is_empty:
# Get the first hand
hand = frame.hands[0]
# Check if the hand has any fingers
fingers = hand.fingers
if not fingers.is_empty:
# Calculate the hand's average finger tip position
avg_pos = Leap.Vector()
for finger in fingers:
avg_pos += finger.tip_position
avg_pos /= len(fingers)
print "Hand has %d fingers, average finger tip position: %s" % (
len(fingers), avg_pos)
# Get the hand's sphere radius and palm position
print "Hand sphere radius: %f mm, palm position: %s" % (
hand.sphere_radius, hand.palm_position)
# Get the hand's normal vector and direction
normal = hand.palm_normal
direction = hand.direction
# Calculate the hand's pitch, roll, and yaw angles
print "Hand pitch: %f degrees, roll: %f degrees, yaw: %f degrees" % (
direction.pitch * Leap.RAD_TO_DEG,
normal.roll * Leap.RAD_TO_DEG,
direction.yaw * Leap.RAD_TO_DEG)
updateCoord = True
tempX = ((direction.yaw * Leap.RAD_TO_DEG - 60) * 3/2)
tempY = 180+((direction.pitch * Leap.RAD_TO_DEG - 60) * 3/2)
if self.positionX != tempX:
self.positionX = tempX
updateCoord = True
if self.positionY != tempY:
self.positionY = tempY
updateCoord = True
if updateCoord:
xstr = str(self.positionX).strip('-')
xstr2 = xstr[:xstr.find('.')]
ystr = str(self.positionY).strip('-')
ystr2 = ystr[:ystr.find('.')]
self.move_turret(xstr2,ystr2)
print("Turret Position X: " + xstr2)
print("Turret Position Y: " + ystr2)
# Gestures
for gesture in frame.gestures():
if gesture.type == Leap.Gesture.TYPE_CIRCLE:
circle = CircleGesture(gesture)
# Determine clock direction using the angle between the pointable and the circle normal
if circle.pointable.direction.angle_to(circle.normal) <= Leap.PI/4:
clockwiseness = "clockwise"
else:
clockwiseness = "counterclockwise"
# Calculate the angle swept since the last frame
swept_angle = 0
if circle.state != Leap.Gesture.STATE_START:
previous_update = CircleGesture(controller.frame(1).gesture(circle.id))
swept_angle = (circle.progress - previous_update.progress) * 2 * Leap.PI
print "Circle id: %d, %s, progress: %f, radius: %f, angle: %f degrees, %s" % (
gesture.id, self.state_string(gesture.state),
circle.progress, circle.radius, swept_angle * Leap.RAD_TO_DEG, clockwiseness)
if gesture.type == Leap.Gesture.TYPE_SWIPE:
swipe = SwipeGesture(gesture)
print "Swipe id: %d, state: %s, position: %s, direction: %s, speed: %f" % (
gesture.id, self.state_string(gesture.state),
swipe.position, swipe.direction, swipe.speed)
if gesture.type == Leap.Gesture.TYPE_KEY_TAP:
keytap = KeyTapGesture(gesture)
print "Key Tap id: %d, %s, position: %s, direction: %s" % (
gesture.id, self.state_string(gesture.state),
keytap.position, keytap.direction )
if gesture.type == Leap.Gesture.TYPE_SCREEN_TAP:
screentap = ScreenTapGesture(gesture)
print "Screen Tap id: %d, %s, position: %s, direction: %s" % (
gesture.id, self.state_string(gesture.state),
screentap.position, screentap.direction )
if not (frame.hands.is_empty and frame.gestures().is_empty):
print ""
def move_turret(self,xpos,ypos):
request = urllib2.Request(self.base_url+str(xpos)+"x"+str(ypos)+"y")
urllib2.urlopen(request).read()
def state_string(self, state):
if state == Leap.Gesture.STATE_START:
return "STATE_START"
if state == Leap.Gesture.STATE_UPDATE:
return "STATE_UPDATE"
if state == Leap.Gesture.STATE_STOP:
return "STATE_STOP"
if state == Leap.Gesture.STATE_INVALID:
return "STATE_INVALID"
def main():
# Create a sample listener and controller
listener = SampleListener()
controller = Leap.Controller()
# Have the sample listener receive events from the controller
controller.add_listener(listener)
# Keep this process running until Enter is pressed
print "Press Enter to quit..."
sys.stdin.readline()
# Remove the sample listener when done
controller.remove_listener(listener)
if __name__ == "__main__":
main()
View
@@ -1,4 +1,9 @@
Laser-Turret
============
Arduino and web2py code for remotely controlling a laser turret
Arduino and web2py code for remotely controlling a laser turret with a Leap Motion Controller
Tested on Arduino Mega ADK with Tinkerkit
Output 00 connected to Servo1 (Yaw)
Output 01 connected to Servo2 (Tilt)
Output 03 connected to Laser pointer
@@ -0,0 +1,2 @@
Write something about this app.
Developed with web2py.
Binary file not shown.
Oops, something went wrong.

0 comments on commit e7fd278

Please sign in to comment.