artoo-leapmotion 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02ceeb606551122ca82891fe48d65a2d10e6800a
4
- data.tar.gz: cbd4d8020e08208ade89632c5f798302fff93ea3
3
+ metadata.gz: 9cf5f47cdb65708e45c24014a96fa4b5d7875b3e
4
+ data.tar.gz: 0f105f0339580dd81dda3a87cf3b068e089d4c4b
5
5
  SHA512:
6
- metadata.gz: 0a39c3f28d384a2b8c695f367e1f7cfaf55c17a0df0adbb43393ae30cee86afdf096fb01372d8086da32918b355d818a3dd322baa2935d00d3518aa7e713f286
7
- data.tar.gz: 780d38f8dc8ae3640f39d134976648a913c44edd4ae2a03004d83f32bbea6707e5eb1342d66d929b3f4eff5a953f52c72e7510ace71676fe30a3bf6660423571
6
+ metadata.gz: 148e90d7dcd3907c23fb15ec5bf1b7ff3a56f85e7a1f044ae98918e240428d1c7f40b8518a10e1b745da570685914b5d87132c24d0ac5d53fdb5b6018d7c279d
7
+ data.tar.gz: a7a7deb8a46d3611c3982fbe76539c8ac0e2a2cf535fccf7430e6ed6039db1a83654e26e4317ca6c586be75091cf606c6e30ce4c787bd6debd0bc2b506bb2fb9
@@ -2,5 +2,8 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 1.9.3
5
- - jruby-1.7.4
6
- - rbx-19mode
5
+ - jruby-1.7.9
6
+ - rbx-2.1.1
7
+ matrix:
8
+ allow_failures:
9
+ - rvm: jruby-1.7.9
@@ -1,30 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- artoo-leapmotion (0.3.0)
5
- artoo (>= 1.4.0)
4
+ artoo-leapmotion (0.4.0)
5
+ artoo (>= 1.6.0)
6
6
  hybridgroup-celluloid-websocket-client
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- artoo (1.4.1)
11
+ artoo (1.6.0)
12
12
  celluloid (~> 0.15.0)
13
13
  celluloid-io (~> 0.15.0)
14
14
  multi_json (~> 1.6)
15
15
  pry (~> 0.9)
16
16
  rake
17
17
  reel (~> 0.4.0)
18
+ robeaux (~> 0.0.3)
18
19
  thor (~> 0.18.1)
19
20
  celluloid (0.15.2)
20
21
  timers (~> 1.1.0)
21
22
  celluloid-io (0.15.0)
22
23
  celluloid (>= 0.15.0)
23
24
  nio4r (>= 0.5.0)
24
- coderay (1.0.9)
25
+ coderay (1.1.0)
25
26
  http (0.5.0)
26
27
  http_parser.rb
27
- http_parser.rb (0.6.0.beta.2)
28
+ http_parser.rb (0.6.0)
28
29
  hybridgroup-celluloid-websocket-client (0.0.3)
29
30
  celluloid-io
30
31
  websocket-driver
@@ -34,25 +35,25 @@ GEM
34
35
  minitest-happy (1.0.0)
35
36
  mocha (0.14.0)
36
37
  metaclass (~> 0.0.1)
37
- multi_json (1.8.2)
38
- nio4r (0.5.0)
39
- pry (0.9.12.2)
40
- coderay (~> 1.0.5)
38
+ multi_json (1.8.4)
39
+ nio4r (1.0.0)
40
+ pry (0.9.12.6)
41
+ coderay (~> 1.0)
41
42
  method_source (~> 0.8)
42
43
  slop (~> 3.4)
43
- rake (10.1.0)
44
+ rake (10.1.1)
44
45
  reel (0.4.0)
45
46
  celluloid (>= 0.15.1)
46
47
  celluloid-io (>= 0.15.0)
47
48
  http (>= 0.5.0)
48
49
  http_parser.rb (>= 0.6.0.beta.2)
49
50
  websocket_parser (>= 0.1.4)
50
- slop (3.4.6)
51
+ robeaux (0.0.3)
52
+ slop (3.4.7)
51
53
  thor (0.18.1)
52
54
  timers (1.1.0)
53
- websocket-driver (0.3.0)
54
- websocket_parser (0.1.4)
55
- http
55
+ websocket-driver (0.3.2)
56
+ websocket_parser (0.1.6)
56
57
 
57
58
  PLATFORMS
58
59
  ruby
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 The Hybrid Group
1
+ Copyright (c) 2013-2014 The Hybrid Group
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -13,7 +13,7 @@ For more information abut Artoo, check out our repo at https://github.com/hybrid
13
13
  ## Installing
14
14
 
15
15
  ```
16
- gem install artoo-leapmotion --pre
16
+ gem install artoo-leapmotion
17
17
  ```
18
18
 
19
19
  ## Using
@@ -74,3 +74,28 @@ The main steps are:
74
74
  The normal Windows download of the Leap Motion software from https://www.leapmotion.com/setup should work with Artoo.
75
75
 
76
76
  We are currently working with the Celluloid team to add Windows support. Please check back soon!
77
+
78
+ ## Documentation
79
+
80
+ Check out our [documentation](http://artoo.io/documentation/) for lots of information about how to use Artoo.
81
+
82
+ ## IRC
83
+
84
+ Need more help? Just want to say "Hello"? Come visit us on IRC freenode #artoo
85
+
86
+ ## Contributing
87
+
88
+ * All patches must be provided under the Apache 2.0 License
89
+ * Please use the -s option in git to "sign off" that the commit is your work and you are providing it under the Apache 2.0 License
90
+ * Submit a Github Pull Request to the appropriate branch and ideally discuss the changes with us in IRC.
91
+ * We will look at the patch, test it out, and give you feedback.
92
+ * Avoid doing minor whitespace changes, renamings, etc. along with merged content. These will be done by the maintainers from time to time but they can complicate merges and should be done seperately.
93
+ * Take care to maintain the existing coding style.
94
+ * Add unit tests for any new or changed functionality.
95
+ * All pull requests should be "fast forward"
96
+ * If there are commits after yours use “git rebase -i <new_head_branch>”
97
+ * If you have local changes you may need to use “git stash”
98
+ * For git help see [progit](http://git-scm.com/book) which is an awesome (and free) book on git
99
+
100
+
101
+ (c) 2012-2014 The Hybrid Group
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.name = "artoo-leapmotion"
7
7
  s.version = Artoo::Leapmotion::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Ron Evans"]
9
+ s.authors = ["Ron Evans", "Andrew Stewart"]
10
10
  s.email = ["artoo@hybridgroup.com"]
11
11
  s.homepage = "https://github.com/hybridgroup/artoo-leapmotion"
12
12
  s.summary = %q{Artoo adaptor and driver for Leap Motion}
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_runtime_dependency 'artoo', '>= 1.4.0'
22
+ s.add_runtime_dependency 'artoo', '>= 1.6.0'
23
23
  s.add_runtime_dependency 'hybridgroup-celluloid-websocket-client'
24
24
  s.add_development_dependency 'minitest', '>= 5.0'
25
25
  s.add_development_dependency 'minitest-happy'
@@ -0,0 +1,38 @@
1
+ # Events
2
+
3
+ ## start_driver
4
+
5
+ Starts the driver.
6
+
7
+ ## on_open
8
+
9
+ Gets triggered when the leapmotion is opened.
10
+
11
+ ## on_message(data)
12
+
13
+ Gets triggered when the leapmotion have a message.
14
+
15
+ - **data** - params
16
+
17
+ ## on_close(code, reason)
18
+
19
+ Gets triggered when the leapmotion is closed.
20
+
21
+ - **code** - params
22
+ - **reason** - params
23
+
24
+ ## hand
25
+
26
+ Gets triggered when doing a hand motion, makes hand input available.
27
+
28
+ ## gesture
29
+
30
+ Gets triggered when doing a gesture motion, makes hand input available.
31
+
32
+ ## pointable
33
+
34
+ Gets triggered when doing a pointable motion, makes hand input available.
35
+
36
+ ## frame
37
+
38
+ Gets triggered with every motion detected, makes frame input available.
@@ -1,5 +1,5 @@
1
1
  module Artoo
2
2
  module Leapmotion
3
- VERSION = '0.3.0'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -8,6 +8,10 @@ module Artoo
8
8
  class Leapmotion < Driver
9
9
 
10
10
  # Start driver and any required connections
11
+
12
+ # Public: Starts the driver
13
+ #
14
+ # Returns nil
11
15
  def start_driver
12
16
  begin
13
17
  connection.handler = current_actor
@@ -21,12 +25,20 @@ module Artoo
21
25
  end
22
26
  end
23
27
 
28
+ # Public: On open
29
+ #
30
+ # Returns nil
24
31
  def on_open
25
32
  publish(event_topic_name("open"))
26
33
  data = JSON.dump("enableGestures" => true)
27
34
  connection.text(data)
28
35
  end
29
36
 
37
+ # Public: On message
38
+ #
39
+ # data - params
40
+ #
41
+ # Returns nil
30
42
  def on_message(data)
31
43
  message = JSON.parse(data)
32
44
  if message.key?("id") and message.key?("timestamp")
@@ -43,6 +55,12 @@ module Artoo
43
55
  publish(event_topic_name("error"), data)
44
56
  end
45
57
 
58
+ # Public: On close
59
+ #
60
+ # code - params
61
+ # reason - params
62
+ #
63
+ # Returns nil
46
64
  def on_close(code, reason)
47
65
  publish(event_topic_name("close"), code, reason)
48
66
  end
@@ -4,21 +4,35 @@ require 'artoo/drivers/leapmotion/hand'
4
4
 
5
5
  module Artoo
6
6
  module Drivers
7
- # The leapmotion driver behaviors
8
7
  class Leapmotion < Driver
9
8
  class Frame
10
- attr_reader :gestures, :pointables, :hands, :id, :timestamp, :r, :s, :t
11
- def initialize(data)
12
- @hands = Artoo::Drivers::Leapmotion::Hand.list(data)
13
- @gestures = Artoo::Drivers::Leapmotion::Gesture.list(data)
14
- @pointables = Artoo::Drivers::Leapmotion::Pointable.list(data)
15
- @id = data["id"]
16
- @timestamp = data["timestamp"]
17
- @r = data["r"]
18
- @s = data["s"]
19
- @t = data["t"]
9
+ attr_reader :id, :timestamp, :raw, :gestures, :hands, :pointables,
10
+ :rotation, :scale_factor, :translation
11
+
12
+ # Public: initialize
13
+ #
14
+ # frame - params
15
+ #
16
+ # Returns nil
17
+ def initialize(frame)
18
+ @id = frame["id"]
19
+ @timestamp = frame["timestamp"]
20
+ @raw = frame
21
+
22
+ @hands = Artoo::Drivers::Leapmotion::Hand.list(frame)
23
+ @gestures = Artoo::Drivers::Leapmotion::Gesture.list(frame)
24
+ @pointables = Artoo::Drivers::Leapmotion::Pointable.list(frame)
25
+
26
+ @rotation = {
27
+ axis: frame['r'][0],
28
+ angle: frame['r'][1],
29
+ matrix: frame['r'][2]
30
+ }
31
+
32
+ @scale_factor = frame["s"]
33
+ @translation = frame["t"]
20
34
  end
21
35
  end
22
36
  end
23
37
  end
24
- end
38
+ end
@@ -13,50 +13,80 @@ module Artoo
13
13
  class Gesture
14
14
  class Error < StandardError; end
15
15
 
16
+ # Public: Iterates through LeapMotion frame data, extracting all Hand
17
+ # JSON into new Leapmotion::Hand objects.
18
+ #
19
+ # data - a LeapMotion frame that may or may not contain hand data
20
+ #
21
+ # Returns an array containing all Hands found in the frame
16
22
  def self.list(data)
17
- gestures = []
18
- if data["gestures"]
19
- data["gestures"].each do |gesture|
20
- gestures << make_gesture(gesture)
21
- end
22
- end
23
- return gestures
23
+ return [] unless data["gestures"]
24
+ data["gestures"].map { |gesture| make_gesture gesture }
24
25
  end
25
26
 
27
+ # Public: Makes a gesture for te leapmotion
28
+ #
29
+ # data - params
30
+ #
31
+ # Returns an array
26
32
  def self.make_gesture(data)
27
33
  unless data.has_key? "type"
28
34
  raise Error, "gesture type unknown"
29
35
  end
36
+
30
37
  name = data["type"][0].upcase << data["type"][1..-1]
38
+
31
39
  unless class_exists?(name)
32
40
  raise Error, "gesture class `#{self}::#{name}' invalid"
33
41
  end
42
+
34
43
  const_get(name).new(data)
35
44
  end
36
45
 
46
+ # Public: Starts the driver
47
+ #
48
+ # Returns an nil
49
+ def start_position
50
+ @startPosition
51
+ end
52
+
53
+ # Public: initialize
54
+ #
55
+ # data - params
56
+ #
57
+ # Returns nil
58
+ def initialize(data)
59
+ data.each do |key, value|
60
+ instance_variable_set("@#{key}", value)
61
+ self.class.send(
62
+ :define_method,
63
+ key.to_sym,
64
+ lambda { instance_variable_get("@#{key}") }
65
+ )
66
+ end
67
+ end
68
+
37
69
  private
38
70
 
71
+ # Public: Class exists
72
+ #
73
+ # class_name - params
74
+ #
75
+ # Returns nil
39
76
  def self.class_exists?(class_name)
40
- klass = const_get(class_name)
41
- return klass.is_a?(Class)
77
+ const_get(class_name).is_a?(Class)
42
78
  rescue NameError
43
- return false
79
+ false
44
80
  end
45
81
 
46
- def self.define_gesture *names
47
- names.each do |n|
48
- name = n.to_s
49
- unless class_exists?(name)
50
- c = Class.new(self) do
51
- def initialize(data)
52
- data.each do |k, v|
53
- instance_variable_set("@#{k}", v)
54
- self.class.send(:define_method, k.to_sym, lambda { instance_variable_get("@#{k}") })
55
- end
56
- end
57
- end
58
- const_set name, c
59
- end
82
+ # Public: Define gesture
83
+ #
84
+ # *names - params
85
+ #
86
+ # Returns nil
87
+ def self.define_gesture(*names)
88
+ names.each do |name|
89
+ const_set name, Class.new(self) unless class_exists?(name)
60
90
  end
61
91
  end
62
92
 
@@ -3,34 +3,63 @@ module Artoo
3
3
  # The leapmotion driver behaviors
4
4
  class Leapmotion < Driver
5
5
  class Hand
6
+ # Public: Iterates through LeapMotion frame data, extracting all Hand
7
+ # JSON into new Leapmotion::Hand objects.
8
+ #
9
+ # data - a LeapMotion frame that may or may not contain hand data
10
+ #
11
+ # Returns an array containing all Hands found in the frame
6
12
  def self.list(data)
7
- hands = []
8
- if data["hands"]
9
- data["hands"].each do |hand|
10
- hands << Artoo::Drivers::Leapmotion::Hand.new(hand)
11
- end
12
- end
13
- return hands
13
+ return [] unless data["hands"]
14
+ data["hands"].map { |hand| Artoo::Drivers::Leapmotion::Hand.new hand }
14
15
  end
15
-
16
+ # Public: initialize
17
+ #
18
+ # frame - params
19
+ #
20
+ # Returns nil
16
21
  def initialize(data)
17
- data.each do |k, v|
18
- instance_variable_set("@#{k}", v)
19
- self.class.send(:define_method, k.to_sym, lambda { instance_variable_get("@#{k}") })
22
+ data.each do |key, value|
23
+ instance_variable_set "@#{key}", value
24
+ self.class.send(
25
+ :define_method,
26
+ key.to_sym,
27
+ lambda { instance_variable_get("@#{key}") }
28
+ )
20
29
  end
21
30
  end
22
31
 
32
+ # Public: Palm x position
33
+ #
34
+ # Returns nil
23
35
  def palm_x
24
36
  palmPosition[0] if palmPosition
25
37
  end
26
38
 
39
+ # Public: Palm y position
40
+ #
41
+ # Returns nil
27
42
  def palm_y
28
43
  palmPosition[2] if palmPosition
29
44
  end
30
45
 
46
+ # Public: Palm z position
47
+ #
48
+ # Returns nil
31
49
  def palm_z
32
50
  palmPosition[1] if palmPosition
33
51
  end
52
+
53
+ # Public: Rotation
54
+ #
55
+ # Returns nil
56
+ def rotation
57
+ {
58
+ axis: @r[0],
59
+ angle: @r[1],
60
+ matrix: @r[2]
61
+ }
62
+ end
34
63
  end
35
64
  end
36
65
  end
@@ -3,22 +3,48 @@ module Artoo
3
3
  # The leapmotion driver behaviors
4
4
  class Leapmotion < Driver
5
5
  class Pointable
6
+ # Public: Iterates through LeapMotion frame data, extracting all Hand
7
+ # JSON into new Leapmotion::Hand objects.
8
+ #
9
+ # data - a LeapMotion frame that may or may not contain hand data
10
+ #
11
+ # Returns an array containing all Hands found in the frame
6
12
  def self.list(data)
7
- pointables = []
8
- if data["pointables"]
9
- data["pointables"].each do |pointable|
10
- pointables << Artoo::Drivers::Leapmotion::Pointable.new(pointable)
11
- end
13
+ return [] unless data["pointables"]
14
+ data["pointables"].map do |pointable|
15
+ Artoo::Drivers::Leapmotion::Pointable.new(pointable)
12
16
  end
13
- return pointables
14
17
  end
15
18
 
19
+ # Public: initialize
20
+ #
21
+ # data - params
22
+ #
23
+ # Returns nil
16
24
  def initialize(data)
17
- data.each do |k, v|
18
- instance_variable_set("@#{k}", v)
19
- self.class.send(:define_method, k.to_sym, lambda { instance_variable_get("@#{k}") })
25
+ data.each do |key, value|
26
+ instance_variable_set "@#{key}", value
27
+ self.class.send(
28
+ :define_method,
29
+ key.to_sym,
30
+ lambda { instance_variable_get("@#{key}") }
31
+ )
20
32
  end
21
33
  end
34
+
35
+ # Public: Touch zone
36
+ #
37
+ # Returns nil
38
+ def touch_zone
39
+ @touchZone
40
+ end
41
+
42
+ # Public: tip position
43
+ #
44
+ # Returns nil
45
+ def tip_position
46
+ @tipPosition
47
+ end
22
48
  end
23
49
  end
24
50
  end
@@ -0,0 +1,47 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
+ require 'artoo/drivers/leapmotion'
3
+
4
+ describe Artoo::Drivers::Leapmotion::Frame do
5
+ frame = Artoo::Drivers::Leapmotion::Frame.new JSON.parse(frame_json)
6
+
7
+ it "extracts the frame's ID" do
8
+ assert frame.id.is_a?(Integer)
9
+ assert_equal frame.id, 99943
10
+ end
11
+
12
+ it "extracts the frame's timestamp" do
13
+ assert frame.timestamp.is_a?(Integer)
14
+ assert_equal frame.timestamp, 4729292670
15
+ end
16
+
17
+ it "stores the raw frame data" do
18
+ assert_equal frame.raw, JSON.parse(frame_json)
19
+ end
20
+
21
+ it "extracts rotation data from the frame" do
22
+ assert frame.rotation.is_a?(Hash)
23
+ assert frame.rotation[:axis].is_a?(Array)
24
+ assert frame.rotation[:angle].is_a?(Array)
25
+ assert frame.rotation[:matrix].is_a?(Array)
26
+ end
27
+
28
+ it "extracts scale factor data from the frame" do
29
+ assert frame.scale_factor.is_a?(Float)
30
+ end
31
+
32
+ it "extracts translation factor data from the frame" do
33
+ assert frame.translation.is_a?(Array)
34
+ end
35
+
36
+ it "stores the detected hands in an array" do
37
+ assert frame.hands.is_a?(Array)
38
+ end
39
+
40
+ it "stores the detected gestures in an array" do
41
+ assert frame.gestures.is_a?(Array)
42
+ end
43
+
44
+ it "stores the detected pointables in an array" do
45
+ assert frame.pointables.is_a?(Array)
46
+ end
47
+ end
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
+ require 'artoo/drivers/leapmotion'
3
+
4
+ describe Artoo::Drivers::Leapmotion::Gesture do
5
+ gesture = Artoo::Drivers::Leapmotion::Gesture.list(JSON.parse(frame_json))[0]
6
+
7
+ it "extracts the gesture position" do
8
+ assert gesture.position.is_a?(Array)
9
+ gesture.position.each do |number|
10
+ assert number.is_a?(Float)
11
+ end
12
+ end
13
+
14
+ it "extracts the gesture direction" do
15
+ assert gesture.direction.is_a?(Array)
16
+ gesture.direction.each do |number|
17
+ assert number.is_a?(Float)
18
+ end
19
+ end
20
+
21
+ it "extracts the gesture's starting position" do
22
+ assert gesture.start_position.is_a?(Array)
23
+ gesture.start_position.each do |number|
24
+ assert number.is_a?(Float)
25
+ end
26
+ end
27
+
28
+ it "extracts the gesture type" do
29
+ assert gesture.type.is_a?(String)
30
+ end
31
+
32
+ it "extracts the gesture state" do
33
+ assert gesture.state.is_a?(String)
34
+ end
35
+
36
+ it "creates an instance of a Gesture subclass to the gesture type" do
37
+ assert_equal gesture.type, 'swipe'
38
+ assert gesture.is_a?(Artoo::Drivers::Leapmotion::Gesture::Swipe)
39
+ end
40
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
+ require 'artoo/drivers/leapmotion'
3
+
4
+ describe Artoo::Drivers::Leapmotion::Hand do
5
+ hand = Artoo::Drivers::Leapmotion::Hand.list(JSON.parse(frame_json))[0]
6
+
7
+ it "extracts the palm position" do
8
+ assert hand.palm_x.is_a?(Float)
9
+ assert hand.palm_y.is_a?(Float)
10
+ assert hand.palm_z.is_a?(Float)
11
+ end
12
+
13
+ it "extracts the rotation information" do
14
+ assert hand.rotation.is_a?(Hash)
15
+ assert hand.rotation[:axis].is_a?(Array)
16
+ assert hand.rotation[:angle].is_a?(Array)
17
+ assert hand.rotation[:matrix].is_a?(Array)
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
+ require 'artoo/drivers/leapmotion'
3
+
4
+ describe Artoo::Drivers::Leapmotion::Pointable do
5
+ frame = JSON.parse frame_json
6
+ pointable = Artoo::Drivers::Leapmotion::Pointable.list(frame)[0]
7
+
8
+ it "extracts the length of the pointable" do
9
+ assert pointable.length.is_a?(Float)
10
+ end
11
+
12
+ it "extracts the position of the tip of the pointable" do
13
+ assert pointable.tip_position.is_a?(Array)
14
+ pointable.tip_position.each do |number|
15
+ assert number.is_a?(Float)
16
+ end
17
+ end
18
+
19
+ it "extracts the pointable's touch zone" do
20
+ assert pointable.touch_zone.is_a?(String)
21
+ end
22
+
23
+ it "extracts whether or not the pointable is a tool" do
24
+ assert [true, false].include?(pointable.tool)
25
+ end
26
+ end
@@ -30,14 +30,14 @@ describe Artoo::Drivers::Leapmotion do
30
30
  it 'Leapmotion#on_message with a frame but no gesture' do
31
31
  @device.expects(:event_topic_name).with("frame")
32
32
  @device.expects(:event_topic_name).with("gesture").never
33
- @driver.on_message(JSON.dump(valid_frame))
33
+ @driver.on_message(frame_json)
34
34
  end
35
35
 
36
36
  it 'Leapmotion#on_message with a gesture' do
37
37
  @device.expects(:event_topic_name).with("frame")
38
38
  @device.expects(:event_topic_name).with("gesture")
39
39
  @frame.stubs(:gestures).returns(['123'])
40
- @driver.on_message(JSON.dump(valid_frame))
40
+ @driver.on_message(frame_json)
41
41
  end
42
42
 
43
43
  it 'Leapmotion#error' do
@@ -0,0 +1,277 @@
1
+ {
2
+ "currentFrameRate": 115.473,
3
+ "gestures": [
4
+ {
5
+ "direction": [
6
+ -0.647384,
7
+ 0.750476,
8
+ -0.132964
9
+ ],
10
+ "duration": 0,
11
+ "handIds": [
12
+ 57
13
+ ],
14
+ "id": 72,
15
+ "pointableIds": [
16
+ 14
17
+ ],
18
+ "position": [
19
+ 117.665,
20
+ 313.471,
21
+ 27.2095
22
+ ],
23
+ "speed": 1050.66,
24
+ "startPosition": [
25
+ 195.438,
26
+ 223.313,
27
+ 43.183
28
+ ],
29
+ "state": "start",
30
+ "type": "swipe"
31
+ }
32
+ ],
33
+ "hands": [
34
+ {
35
+ "direction": [
36
+ 0.772435,
37
+ 0.520335,
38
+ -0.364136
39
+ ],
40
+ "id": 57,
41
+ "palmNormal": [
42
+ -0.0100593,
43
+ -0.563263,
44
+ -0.826217
45
+ ],
46
+ "palmPosition": [
47
+ 117.546,
48
+ 236.007,
49
+ 76.3394
50
+ ],
51
+ "palmVelocity": [
52
+ -866.196,
53
+ -100.749,
54
+ 275.692
55
+ ],
56
+ "r": [
57
+ [
58
+ 0.999844,
59
+ 0.0142022,
60
+ 0.0105289
61
+ ],
62
+ [
63
+ -0.0141201,
64
+ 0.99987,
65
+ -0.00783186
66
+ ],
67
+ [
68
+ -0.0106388,
69
+ 0.00768197,
70
+ 0.999914
71
+ ]
72
+ ],
73
+ "s": 0.992511,
74
+ "sphereCenter": [
75
+ 156.775,
76
+ 227.378,
77
+ 48.3453
78
+ ],
79
+ "sphereRadius": 75.3216,
80
+ "stabilizedPalmPosition": [
81
+ 119.009,
82
+ 236.071,
83
+ 75.951
84
+ ],
85
+ "t": [
86
+ -38.0468,
87
+ 28.2341,
88
+ -21.3291
89
+ ],
90
+ "timeVisible": 0.051952
91
+ }
92
+ ],
93
+ "id": 99943,
94
+ "interactionBox": {
95
+ "center": [
96
+ 0,
97
+ 200,
98
+ 0
99
+ ],
100
+ "size": [
101
+ 221.418,
102
+ 221.418,
103
+ 154.742
104
+ ]
105
+ },
106
+ "pointables": [
107
+ {
108
+ "direction": [
109
+ 0.54044,
110
+ 0.174084,
111
+ -0.823176
112
+ ],
113
+ "handId": 57,
114
+ "id": 1,
115
+ "length": 48.393,
116
+ "stabilizedTipPosition": [
117
+ 194.714,
118
+ 291.812,
119
+ 20.6219
120
+ ],
121
+ "timeVisible": 0.13873,
122
+ "tipPosition": [
123
+ 194.714,
124
+ 291.812,
125
+ 20.6219
126
+ ],
127
+ "tipVelocity": [
128
+ -716.414,
129
+ 686.468,
130
+ -427.914
131
+ ],
132
+ "tool": false,
133
+ "touchDistance": 0.333333,
134
+ "touchZone": "hovering"
135
+ },
136
+ {
137
+ "direction": [
138
+ 0.655715,
139
+ 0.423222,
140
+ -0.625237
141
+ ],
142
+ "handId": 57,
143
+ "id": 69,
144
+ "length": 43.4594,
145
+ "stabilizedTipPosition": [
146
+ 166.231,
147
+ 308.631,
148
+ 21.1697
149
+ ],
150
+ "timeVisible": 0.156012,
151
+ "tipPosition": [
152
+ 166.231,
153
+ 308.631,
154
+ 21.1697
155
+ ],
156
+ "tipVelocity": [
157
+ -817.678,
158
+ 511.988,
159
+ -496.456
160
+ ],
161
+ "tool": false,
162
+ "touchDistance": 0.333333,
163
+ "touchZone": "hovering"
164
+ },
165
+ {
166
+ "direction": [
167
+ 0.593251,
168
+ 0.566682,
169
+ -0.571773
170
+ ],
171
+ "handId": 57,
172
+ "id": 14,
173
+ "length": 47.3576,
174
+ "stabilizedTipPosition": [
175
+ 119.328,
176
+ 312.537,
177
+ 27.7416
178
+ ],
179
+ "timeVisible": 0.164757,
180
+ "tipPosition": [
181
+ 117.665,
182
+ 313.471,
183
+ 27.2095
184
+ ],
185
+ "tipVelocity": [
186
+ -779.297,
187
+ 651.055,
188
+ -269.665
189
+ ],
190
+ "tool": false,
191
+ "touchDistance": 0.333333,
192
+ "touchZone": "hovering"
193
+ },
194
+ {
195
+ "direction": [
196
+ 0.292649,
197
+ -0.45091,
198
+ -0.84323
199
+ ],
200
+ "handId": 57,
201
+ "id": 29,
202
+ "length": 57.4251,
203
+ "stabilizedTipPosition": [
204
+ 223.535,
205
+ 239.849,
206
+ 37.7847
207
+ ],
208
+ "timeVisible": 0.086657,
209
+ "tipPosition": [
210
+ 223.535,
211
+ 239.849,
212
+ 37.7847
213
+ ],
214
+ "tipVelocity": [
215
+ -929.251,
216
+ 390.064,
217
+ -506.855
218
+ ],
219
+ "tool": false,
220
+ "touchDistance": 0.333333,
221
+ "touchZone": "hovering"
222
+ },
223
+ {
224
+ "direction": [
225
+ 0.887561,
226
+ 0.160925,
227
+ 0.43167
228
+ ],
229
+ "handId": -1,
230
+ "id": 83,
231
+ "length": 64.4149,
232
+ "stabilizedTipPosition": [
233
+ 1.8725087977383e-321,
234
+ 2.1433800000305e-314,
235
+ 2.1681499999593e-314
236
+ ],
237
+ "timeVisible": 0.034634,
238
+ "tipPosition": [
239
+ 196.31,
240
+ 166.58,
241
+ 102.577
242
+ ],
243
+ "tipVelocity": [
244
+ -478.099,
245
+ 493.551,
246
+ -417.63
247
+ ],
248
+ "tool": false,
249
+ "touchDistance": 0.0166667,
250
+ "touchZone": "none"
251
+ }
252
+ ],
253
+ "r": [
254
+ [
255
+ -0.973344,
256
+ 0.0737047,
257
+ 0.217182
258
+ ],
259
+ [
260
+ -0.0241526,
261
+ 0.908749,
262
+ -0.416645
263
+ ],
264
+ [
265
+ -0.228073,
266
+ -0.410784,
267
+ -0.882745
268
+ ]
269
+ ],
270
+ "s": -34.3848,
271
+ "t": [
272
+ -10091.8,
273
+ -24629.7,
274
+ 1011.04
275
+ ],
276
+ "timestamp": 4729292670
277
+ }
@@ -9,3 +9,9 @@ MiniTest::Spec.before do
9
9
  Celluloid.shutdown
10
10
  Celluloid.boot
11
11
  end
12
+
13
+ def frame_json
14
+ @frame_json ||= begin
15
+ File.read File.join(File.dirname(__FILE__), "./support/frame.json")
16
+ end
17
+ end
metadata CHANGED
@@ -1,83 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artoo-leapmotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ron Evans
8
+ - Andrew Stewart
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-10-18 00:00:00.000000000 Z
12
+ date: 2014-02-07 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: artoo
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - '>='
18
+ - - ">="
18
19
  - !ruby/object:Gem::Version
19
- version: 1.4.0
20
+ version: 1.6.0
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - '>='
25
+ - - ">="
25
26
  - !ruby/object:Gem::Version
26
- version: 1.4.0
27
+ version: 1.6.0
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: hybridgroup-celluloid-websocket-client
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - '>='
32
+ - - ">="
32
33
  - !ruby/object:Gem::Version
33
34
  version: '0'
34
35
  type: :runtime
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - '>='
39
+ - - ">="
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: minitest
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - '>='
46
+ - - ">="
46
47
  - !ruby/object:Gem::Version
47
48
  version: '5.0'
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
- - - '>='
53
+ - - ">="
53
54
  - !ruby/object:Gem::Version
54
55
  version: '5.0'
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: minitest-happy
57
58
  requirement: !ruby/object:Gem::Requirement
58
59
  requirements:
59
- - - '>='
60
+ - - ">="
60
61
  - !ruby/object:Gem::Version
61
62
  version: '0'
62
63
  type: :development
63
64
  prerelease: false
64
65
  version_requirements: !ruby/object:Gem::Requirement
65
66
  requirements:
66
- - - '>='
67
+ - - ">="
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  - !ruby/object:Gem::Dependency
70
71
  name: mocha
71
72
  requirement: !ruby/object:Gem::Requirement
72
73
  requirements:
73
- - - '>='
74
+ - - ">="
74
75
  - !ruby/object:Gem::Version
75
76
  version: 0.14.0
76
77
  type: :development
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - '>='
81
+ - - ">="
81
82
  - !ruby/object:Gem::Version
82
83
  version: 0.14.0
83
84
  description: Artoo adaptor and driver for Leap Motion
@@ -87,13 +88,14 @@ executables: []
87
88
  extensions: []
88
89
  extra_rdoc_files: []
89
90
  files:
90
- - .travis.yml
91
+ - ".travis.yml"
91
92
  - Gemfile
92
93
  - Gemfile.lock
93
94
  - LICENSE
94
95
  - README.md
95
96
  - Rakefile
96
97
  - artoo-leapmotion.gemspec
98
+ - docs/events.md
97
99
  - examples/leap.rb
98
100
  - examples/leap_gesture.rb
99
101
  - examples/leap_hands.rb
@@ -106,7 +108,12 @@ files:
106
108
  - lib/artoo/drivers/leapmotion/hand.rb
107
109
  - lib/artoo/drivers/leapmotion/pointable.rb
108
110
  - test/adaptors/leapmotion_adaptor_test.rb
111
+ - test/drivers/leap/frame_test.rb
112
+ - test/drivers/leap/gesture_test.rb
113
+ - test/drivers/leap/hand_test.rb
114
+ - test/drivers/leap/pointable_test.rb
109
115
  - test/drivers/leapmotion_driver_test.rb
116
+ - test/support/frame.json
110
117
  - test/test_helper.rb
111
118
  homepage: https://github.com/hybridgroup/artoo-leapmotion
112
119
  licenses: []
@@ -117,17 +124,17 @@ require_paths:
117
124
  - lib
118
125
  required_ruby_version: !ruby/object:Gem::Requirement
119
126
  requirements:
120
- - - '>='
127
+ - - ">="
121
128
  - !ruby/object:Gem::Version
122
129
  version: '0'
123
130
  required_rubygems_version: !ruby/object:Gem::Requirement
124
131
  requirements:
125
- - - '>='
132
+ - - ">="
126
133
  - !ruby/object:Gem::Version
127
134
  version: '0'
128
135
  requirements: []
129
136
  rubyforge_project: artoo-leapmotion
130
- rubygems_version: 2.0.3
137
+ rubygems_version: 2.2.1
131
138
  signing_key:
132
139
  specification_version: 4
133
140
  summary: Artoo adaptor and driver for Leap Motion