artoo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/.gitignore +25 -0
  2. data/Gemfile +26 -0
  3. data/Gemfile.lock +144 -0
  4. data/Guardfile +15 -0
  5. data/LICENSE +13 -0
  6. data/README.md +97 -0
  7. data/Rakefile +11 -0
  8. data/api/assets/compass.rb +25 -0
  9. data/api/assets/javascripts/artoo/controllers/robot.js.coffee +27 -0
  10. data/api/assets/javascripts/artoo/routes.js.coffee +23 -0
  11. data/api/assets/javascripts/core.js.coffee +6 -0
  12. data/api/assets/javascripts/vendor/angular.min.js +161 -0
  13. data/api/assets/javascripts/vendor/bootstrap.min.js +6 -0
  14. data/api/assets/javascripts/vendor/jquery.min.js +5 -0
  15. data/api/assets/stylesheets/artoo/_core.css.scss +3 -0
  16. data/api/assets/stylesheets/artoo/_font-awesome.scss +534 -0
  17. data/api/assets/stylesheets/artoo/_variables.scss +8 -0
  18. data/api/assets/stylesheets/core.scss +70 -0
  19. data/api/public/core.css +9848 -0
  20. data/api/public/core.js +259 -0
  21. data/api/public/favicon.ico +0 -0
  22. data/api/public/font/FontAwesome.otf +0 -0
  23. data/api/public/font/fontawesome-webfont.eot +0 -0
  24. data/api/public/font/fontawesome-webfont.svg +284 -0
  25. data/api/public/font/fontawesome-webfont.ttf +0 -0
  26. data/api/public/font/fontawesome-webfont.woff +0 -0
  27. data/api/public/html5shiv.js +8 -0
  28. data/api/public/images/devices/ardrone.jpg +0 -0
  29. data/api/public/images/devices/arduino.jpg +0 -0
  30. data/api/public/images/devices/sphero.png +0 -0
  31. data/api/public/images/glyphicons-halflings-white.png +0 -0
  32. data/api/public/images/glyphicons-halflings.png +0 -0
  33. data/api/public/index.html +36 -0
  34. data/api/public/partials/robot-detail.html +111 -0
  35. data/api/public/partials/robot-device-detail.html +0 -0
  36. data/api/public/partials/robot-index.html +26 -0
  37. data/artoo.gemspec +21 -0
  38. data/bin/retry.sh +8 -0
  39. data/bin/sphero.sh +8 -0
  40. data/examples/ardrone.rb +12 -0
  41. data/examples/ardrone_nav.rb +22 -0
  42. data/examples/ardrone_nav_video.rb +33 -0
  43. data/examples/ardrone_video.rb +22 -0
  44. data/examples/conway_sphero.rb +65 -0
  45. data/examples/firmata.rb +13 -0
  46. data/examples/firmata_button.rb +9 -0
  47. data/examples/hello.rb +12 -0
  48. data/examples/hello_api.rb +9 -0
  49. data/examples/hello_api_multiple.rb +25 -0
  50. data/examples/hello_modular.rb +16 -0
  51. data/examples/hello_multiple.rb +22 -0
  52. data/examples/notifications.rb +9 -0
  53. data/examples/sphero.rb +11 -0
  54. data/examples/sphero_color.rb +13 -0
  55. data/examples/sphero_firmata.rb +17 -0
  56. data/examples/sphero_messages.rb +22 -0
  57. data/examples/sphero_multiple.rb +33 -0
  58. data/examples/wiiclassic.rb +94 -0
  59. data/lib/artoo.rb +3 -0
  60. data/lib/artoo/adaptors/adaptor.rb +54 -0
  61. data/lib/artoo/adaptors/ardrone.rb +32 -0
  62. data/lib/artoo/adaptors/ardrone_navigation.rb +26 -0
  63. data/lib/artoo/adaptors/ardrone_video.rb +27 -0
  64. data/lib/artoo/adaptors/firmata.rb +25 -0
  65. data/lib/artoo/adaptors/loopback.rb +8 -0
  66. data/lib/artoo/adaptors/sphero.rb +46 -0
  67. data/lib/artoo/api.rb +48 -0
  68. data/lib/artoo/api_route_helpers.rb +197 -0
  69. data/lib/artoo/connection.rb +70 -0
  70. data/lib/artoo/delegator.rb +49 -0
  71. data/lib/artoo/device.rb +61 -0
  72. data/lib/artoo/device_event_client.rb +27 -0
  73. data/lib/artoo/drivers/ardrone.rb +9 -0
  74. data/lib/artoo/drivers/ardrone_navigation.rb +21 -0
  75. data/lib/artoo/drivers/ardrone_video.rb +22 -0
  76. data/lib/artoo/drivers/button.rb +40 -0
  77. data/lib/artoo/drivers/driver.rb +48 -0
  78. data/lib/artoo/drivers/led.rb +37 -0
  79. data/lib/artoo/drivers/passthru.rb +9 -0
  80. data/lib/artoo/drivers/pinger.rb +19 -0
  81. data/lib/artoo/drivers/pinger2.rb +18 -0
  82. data/lib/artoo/drivers/sphero.rb +57 -0
  83. data/lib/artoo/drivers/wiichuck.rb +29 -0
  84. data/lib/artoo/drivers/wiiclassic.rb +137 -0
  85. data/lib/artoo/main.rb +32 -0
  86. data/lib/artoo/master.rb +16 -0
  87. data/lib/artoo/port.rb +51 -0
  88. data/lib/artoo/robot.rb +299 -0
  89. data/lib/artoo/utility.rb +39 -0
  90. data/lib/artoo/version.rb +5 -0
  91. data/test/adaptors/adaptor_test.rb +18 -0
  92. data/test/adaptors/ardrone_test.rb +24 -0
  93. data/test/adaptors/firmata_test.rb +25 -0
  94. data/test/adaptors/loopback_test.rb +18 -0
  95. data/test/adaptors/sphero_test.rb +24 -0
  96. data/test/api_test.rb +61 -0
  97. data/test/artoo_test.rb +12 -0
  98. data/test/connection_test.rb +28 -0
  99. data/test/delegator_test.rb +71 -0
  100. data/test/device_test.rb +41 -0
  101. data/test/drivers/ardrone_navigation_test.rb +11 -0
  102. data/test/drivers/ardrone_test.rb +11 -0
  103. data/test/drivers/ardrone_video_test.rb +11 -0
  104. data/test/drivers/driver_test.rb +21 -0
  105. data/test/drivers/led_test.rb +52 -0
  106. data/test/drivers/sphero_test.rb +54 -0
  107. data/test/drivers/wiichuck_test.rb +11 -0
  108. data/test/port_test.rb +33 -0
  109. data/test/robot_test.rb +96 -0
  110. data/test/test_helper.rb +8 -0
  111. data/test/utility_test.rb +27 -0
  112. metadata +185 -0
@@ -0,0 +1,54 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
+ require 'artoo/drivers/sphero'
3
+
4
+ describe Artoo::Drivers::Sphero do
5
+ before do
6
+ @device = mock('device')
7
+ @driver = Artoo::Drivers::Sphero.new(:parent => @device)
8
+ @connection = mock('connection')
9
+ @col1 = ::Sphero::Response::CollisionDetected.new("yo", "ho")
10
+ @col2 = ::Sphero::Response::CollisionDetected.new("yo", "ho")
11
+ @sen1 = ::Sphero::Response::SensorData.new("yo", "ho")
12
+ @sen2 = ::Sphero::Response::SensorData.new("lo", "no")
13
+ @sen3 = ::Sphero::Response::SensorData.new("jo", "jo")
14
+ @pow1 = ::Sphero::Response::PowerNotification.new("yo", "ho")
15
+ @pow2 = ::Sphero::Response::PowerNotification.new("yo", "ho")
16
+ @connection.stubs(:async_messages).returns([@col1, @col2, @sen1, @sen2, @sen3, @pow1, @pow2])
17
+ @device.stubs(:connection).returns(@connection)
18
+ end
19
+
20
+ it 'Sphero#collisions' do
21
+ @driver.collisions.size.must_equal 2
22
+ end
23
+
24
+ it 'Sphero#power_notifications' do
25
+ @driver.power_notifications.size.must_equal 2
26
+ end
27
+
28
+ it 'Sphero#sensor_data' do
29
+ @driver.sensor_data.size.must_equal 3
30
+ end
31
+
32
+ describe 'color' do
33
+ it 'Sphero#color(:red)' do
34
+ r, g, b = @driver.color(:red)
35
+ r.must_equal 255
36
+ g.must_equal 0
37
+ b.must_equal 0
38
+ end
39
+
40
+ it 'Sphero#color(:green)' do
41
+ r, g, b = @driver.color(:green)
42
+ r.must_equal 0
43
+ g.must_equal 255
44
+ b.must_equal 0
45
+ end
46
+
47
+ it 'Sphero#color(r, g, b)' do
48
+ r, g, b = @driver.color(2, 4, 6)
49
+ r.must_equal 2
50
+ g.must_equal 4
51
+ b.must_equal 6
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
+ require 'artoo/drivers/wiichuck'
3
+
4
+ describe Artoo::Drivers::Wiichuck do
5
+ before do
6
+ @device = mock('device')
7
+ @driver = Artoo::Drivers::Wiichuck.new(:parent => @device)
8
+ end
9
+
10
+ it 'must do things'
11
+ end
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
+
3
+ describe Artoo::Port do
4
+ before do
5
+ @remote_tcp_port = Artoo::Port.new("192.168.0.1:8080")
6
+ @local_tcp_port = Artoo::Port.new("5678")
7
+ @serial_port = Artoo::Port.new("/dev/tty.usb12345")
8
+ end
9
+
10
+ it 'Artoo::Port#port' do
11
+ @remote_tcp_port.port.must_equal "8080"
12
+ @local_tcp_port.port.must_equal "5678"
13
+ @serial_port.port.must_equal "/dev/tty.usb12345"
14
+ end
15
+
16
+ it 'Artoo::Port#is_tcp?' do
17
+ @remote_tcp_port.is_tcp?.must_equal true
18
+ @local_tcp_port.is_tcp?.must_equal true
19
+ @serial_port.is_tcp?.must_equal false
20
+ end
21
+
22
+ it 'Artoo::Port#is_serial?' do
23
+ @remote_tcp_port.is_serial?.must_equal false
24
+ @local_tcp_port.is_serial?.must_equal false
25
+ @serial_port.is_serial?.must_equal true
26
+ end
27
+
28
+ it 'Artoo::Port#to_s' do
29
+ @remote_tcp_port.to_s.must_equal "192.168.0.1:8080"
30
+ @local_tcp_port.to_s.must_equal "localhost:5678"
31
+ @serial_port.to_s.must_equal "/dev/tty.usb12345"
32
+ end
33
+ end
@@ -0,0 +1,96 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
+
3
+ class TestRobot < Artoo::Robot
4
+ connection :test_connection
5
+ device :test_device
6
+ device :another_test_device
7
+ end
8
+
9
+ describe Artoo::Robot do
10
+ before do
11
+ @robot = TestRobot.new(:name => "testme", :connections => {:test_connection => {:port => '1234'}})
12
+ end
13
+
14
+ it 'Artoo::Robot.connection_types' do
15
+ @robot.connection_types.first[:name].must_equal :test_connection
16
+ end
17
+
18
+ it 'Artoo::Robot.device_types' do
19
+ @robot.device_types.first[:name].must_equal :test_device
20
+ end
21
+
22
+ it 'Artoo::Robot#name' do
23
+ @robot.name.must_equal 'testme'
24
+ end
25
+
26
+ it 'Artoo::Robot#safe_name' do
27
+ robotina = TestRobot.new(:name => "I Am A Robot")
28
+ robotina.safe_name.must_equal 'i_am_a_robot'
29
+ end
30
+
31
+ it 'Artoo::Robot#name random when not provided' do
32
+ TestRobot.any_instance.stubs(:random_string).returns("RANDOM")
33
+ @robot3 = TestRobot.new(:connections => {:test_connection => {:port => '1234'}})
34
+ @robot3.name.must_equal 'Robot RANDOM'
35
+ end
36
+
37
+ it 'Artoo::Robot#connections' do
38
+ @robot.connections[:test_connection].name.must_equal 'test_connection'
39
+ end
40
+
41
+ it 'Artoo::Robot#default_connection' do
42
+ @robot.default_connection.name.must_equal 'test_connection'
43
+ end
44
+
45
+ it 'Artoo::Robot#connections initialized with params' do
46
+ @robot.connections[:test_connection].port.host.must_equal 'localhost'
47
+ @robot.connections[:test_connection].port.port.must_equal '1234'
48
+ end
49
+
50
+ it 'Artoo::Robot#devices' do
51
+ @robot.devices[:test_device].name.must_equal 'test_device'
52
+ end
53
+
54
+ it 'Artoo::Robot#test_device' do
55
+ @robot.test_device.name.must_equal 'test_device'
56
+ @robot.another_test_device.name.must_equal 'another_test_device'
57
+ end
58
+
59
+ it 'connects to Artoo::Adaptors::Loopback' do
60
+ @robot.default_connection.adaptor.must_be_kind_of Artoo::Adaptors::Loopback
61
+ end
62
+
63
+ it 'Artoo::Robot.work! with single object' do
64
+ TestRobot.stubs(:sleep)
65
+
66
+ @asm = mock("async_method")
67
+ @asm.expects(:work)
68
+ @robot.expects(:async).returns(@asm)
69
+ TestRobot.work!(@robot)
70
+ end
71
+
72
+ it 'Artoo::Robot.work! with array of objects' do
73
+ @robot2 = TestRobot.new(:name => "too", :connections => {:test_connection => {:port => '1234'}})
74
+ TestRobot.stubs(:sleep)
75
+
76
+ @asm = mock("async_method")
77
+ @asm.expects(:work).times(2)
78
+ @robot.expects(:async).returns(@asm)
79
+ @robot2.expects(:async).returns(@asm)
80
+ TestRobot.work!([@robot, @robot2])
81
+ end
82
+
83
+ it 'Artoo::Robot.work! without object' do
84
+ TestRobot.stubs(:sleep)
85
+
86
+ @asm = mock("async_method")
87
+ @asm.expects(:work).at_least_once
88
+ TestRobot.expects(:new).returns(@robot)
89
+ @robot.expects(:async).returns(@asm)
90
+ TestRobot.work!
91
+ end
92
+
93
+ it 'Artoo::Robot#as_json' do
94
+ MultiJson.load(@robot.as_json, :symbolize_keys => true)[:name].must_equal "testme"
95
+ end
96
+ end
@@ -0,0 +1,8 @@
1
+ gem 'minitest'
2
+ require 'minitest/autorun'
3
+ require 'minitest/pride'
4
+ require 'mocha/setup'
5
+
6
+ require 'artoo/robot'
7
+
8
+ Celluloid.logger = nil
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
+
3
+ class UtilityTestRobot < Artoo::Robot
4
+ connection :test_connection
5
+ device :test_device_1
6
+ device :test_device_2
7
+ end
8
+
9
+ describe Artoo::Utility do
10
+ before do
11
+ @robot = UtilityTestRobot.new
12
+ end
13
+
14
+ it 'Artoo::Utility#random_string' do
15
+ string = @robot.random_string
16
+ string.must_be_kind_of String
17
+ string.size.must_equal 8
18
+ end
19
+
20
+ it 'Artoo::Utility#classify' do
21
+ string = @robot.classify('firmata')
22
+ string.must_equal 'Firmata'
23
+
24
+ string = @robot.classify('ardrone_awesome')
25
+ string.must_equal 'ArdroneAwesome'
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: artoo
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Ron Evans
9
+ - Adrian Zankich
10
+ - Ari Lerner
11
+ - Mario Ricalde
12
+ - Daniel Fischer
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+ date: 2013-02-23 00:00:00.000000000 Z
17
+ dependencies: []
18
+ description: Ruby-based microframework for robotics
19
+ email:
20
+ - artoo@hybridgroup.com
21
+ executables:
22
+ - retry.sh
23
+ - sphero.sh
24
+ extensions: []
25
+ extra_rdoc_files: []
26
+ files:
27
+ - ".gitignore"
28
+ - Gemfile
29
+ - Gemfile.lock
30
+ - Guardfile
31
+ - LICENSE
32
+ - README.md
33
+ - Rakefile
34
+ - api/assets/compass.rb
35
+ - api/assets/javascripts/artoo/controllers/robot.js.coffee
36
+ - api/assets/javascripts/artoo/routes.js.coffee
37
+ - api/assets/javascripts/core.js.coffee
38
+ - api/assets/javascripts/vendor/angular.min.js
39
+ - api/assets/javascripts/vendor/bootstrap.min.js
40
+ - api/assets/javascripts/vendor/jquery.min.js
41
+ - api/assets/stylesheets/artoo/_core.css.scss
42
+ - api/assets/stylesheets/artoo/_font-awesome.scss
43
+ - api/assets/stylesheets/artoo/_variables.scss
44
+ - api/assets/stylesheets/core.scss
45
+ - api/public/core.css
46
+ - api/public/core.js
47
+ - api/public/favicon.ico
48
+ - api/public/font/FontAwesome.otf
49
+ - api/public/font/fontawesome-webfont.eot
50
+ - api/public/font/fontawesome-webfont.svg
51
+ - api/public/font/fontawesome-webfont.ttf
52
+ - api/public/font/fontawesome-webfont.woff
53
+ - api/public/html5shiv.js
54
+ - api/public/images/devices/ardrone.jpg
55
+ - api/public/images/devices/arduino.jpg
56
+ - api/public/images/devices/sphero.png
57
+ - api/public/images/glyphicons-halflings-white.png
58
+ - api/public/images/glyphicons-halflings.png
59
+ - api/public/index.html
60
+ - api/public/partials/robot-detail.html
61
+ - api/public/partials/robot-device-detail.html
62
+ - api/public/partials/robot-index.html
63
+ - artoo.gemspec
64
+ - bin/retry.sh
65
+ - bin/sphero.sh
66
+ - examples/ardrone.rb
67
+ - examples/ardrone_nav.rb
68
+ - examples/ardrone_nav_video.rb
69
+ - examples/ardrone_video.rb
70
+ - examples/conway_sphero.rb
71
+ - examples/firmata.rb
72
+ - examples/firmata_button.rb
73
+ - examples/hello.rb
74
+ - examples/hello_api.rb
75
+ - examples/hello_api_multiple.rb
76
+ - examples/hello_modular.rb
77
+ - examples/hello_multiple.rb
78
+ - examples/notifications.rb
79
+ - examples/sphero.rb
80
+ - examples/sphero_color.rb
81
+ - examples/sphero_firmata.rb
82
+ - examples/sphero_messages.rb
83
+ - examples/sphero_multiple.rb
84
+ - examples/wiiclassic.rb
85
+ - lib/artoo.rb
86
+ - lib/artoo/adaptors/adaptor.rb
87
+ - lib/artoo/adaptors/ardrone.rb
88
+ - lib/artoo/adaptors/ardrone_navigation.rb
89
+ - lib/artoo/adaptors/ardrone_video.rb
90
+ - lib/artoo/adaptors/firmata.rb
91
+ - lib/artoo/adaptors/loopback.rb
92
+ - lib/artoo/adaptors/sphero.rb
93
+ - lib/artoo/api.rb
94
+ - lib/artoo/api_route_helpers.rb
95
+ - lib/artoo/connection.rb
96
+ - lib/artoo/delegator.rb
97
+ - lib/artoo/device.rb
98
+ - lib/artoo/device_event_client.rb
99
+ - lib/artoo/drivers/ardrone.rb
100
+ - lib/artoo/drivers/ardrone_navigation.rb
101
+ - lib/artoo/drivers/ardrone_video.rb
102
+ - lib/artoo/drivers/button.rb
103
+ - lib/artoo/drivers/driver.rb
104
+ - lib/artoo/drivers/led.rb
105
+ - lib/artoo/drivers/passthru.rb
106
+ - lib/artoo/drivers/pinger.rb
107
+ - lib/artoo/drivers/pinger2.rb
108
+ - lib/artoo/drivers/sphero.rb
109
+ - lib/artoo/drivers/wiichuck.rb
110
+ - lib/artoo/drivers/wiiclassic.rb
111
+ - lib/artoo/main.rb
112
+ - lib/artoo/master.rb
113
+ - lib/artoo/port.rb
114
+ - lib/artoo/robot.rb
115
+ - lib/artoo/utility.rb
116
+ - lib/artoo/version.rb
117
+ - test/adaptors/adaptor_test.rb
118
+ - test/adaptors/ardrone_test.rb
119
+ - test/adaptors/firmata_test.rb
120
+ - test/adaptors/loopback_test.rb
121
+ - test/adaptors/sphero_test.rb
122
+ - test/api_test.rb
123
+ - test/artoo_test.rb
124
+ - test/connection_test.rb
125
+ - test/delegator_test.rb
126
+ - test/device_test.rb
127
+ - test/drivers/ardrone_navigation_test.rb
128
+ - test/drivers/ardrone_test.rb
129
+ - test/drivers/ardrone_video_test.rb
130
+ - test/drivers/driver_test.rb
131
+ - test/drivers/led_test.rb
132
+ - test/drivers/sphero_test.rb
133
+ - test/drivers/wiichuck_test.rb
134
+ - test/port_test.rb
135
+ - test/robot_test.rb
136
+ - test/test_helper.rb
137
+ - test/utility_test.rb
138
+ homepage: https://github.com/hybridgroup/artoo
139
+ licenses: []
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: !binary |-
149
+ MA==
150
+ none: false
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: !binary |-
156
+ MA==
157
+ none: false
158
+ requirements: []
159
+ rubyforge_project: artoo
160
+ rubygems_version: 1.8.24
161
+ signing_key:
162
+ specification_version: 3
163
+ summary: Ruby-based microframework for robotics
164
+ test_files:
165
+ - test/adaptors/adaptor_test.rb
166
+ - test/adaptors/ardrone_test.rb
167
+ - test/adaptors/firmata_test.rb
168
+ - test/adaptors/loopback_test.rb
169
+ - test/adaptors/sphero_test.rb
170
+ - test/api_test.rb
171
+ - test/artoo_test.rb
172
+ - test/connection_test.rb
173
+ - test/delegator_test.rb
174
+ - test/device_test.rb
175
+ - test/drivers/ardrone_navigation_test.rb
176
+ - test/drivers/ardrone_test.rb
177
+ - test/drivers/ardrone_video_test.rb
178
+ - test/drivers/driver_test.rb
179
+ - test/drivers/led_test.rb
180
+ - test/drivers/sphero_test.rb
181
+ - test/drivers/wiichuck_test.rb
182
+ - test/port_test.rb
183
+ - test/robot_test.rb
184
+ - test/test_helper.rb
185
+ - test/utility_test.rb