artoo-sphero 1.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rvmrc.example +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +62 -0
- data/LICENSE +13 -0
- data/README.md +16 -0
- data/Rakefile +10 -0
- data/artoo-sphero.gemspec +27 -0
- data/bin/sphero.sh +8 -0
- data/bin/sphero_linux_bind.sh +25 -0
- data/bin/sphero_linux_socat.sh +8 -0
- data/examples/sphero.rb +11 -0
- data/examples/sphero2.rb +26 -0
- data/examples/sphero_color.rb +13 -0
- data/examples/sphero_cycle.rb +15 -0
- data/examples/sphero_messages.rb +19 -0
- data/examples/sphero_multiple.rb +34 -0
- data/lib/artoo/adaptors/sphero.rb +58 -0
- data/lib/artoo/drivers/sphero.rb +105 -0
- data/lib/artoo-sphero/version.rb +5 -0
- data/lib/artoo-sphero.rb +3 -0
- data/test/adaptors/sphero_test.rb +24 -0
- data/test/drivers/sphero_test.rb +54 -0
- data/test/test_helper.rb +6 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 494f759984c5ab3cbb7ae3f7554d9d93bc521645
|
4
|
+
data.tar.gz: 12e3f9a754de59708bd43a56d72eed6d959b5576
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ecf4f66c889eccc2b4d90b3350514d4d5c6de44cc0a20cffef0014d94d434c17e1826ef7e153dc3f12e07fb10a2de8931e3b7593ff548fabae55506d5b865024
|
7
|
+
data.tar.gz: 49f47a74d5a628b1a5fa3acf5f448f60b43a34f7fbedec6065e8d180c79755de941899a213a96ab04b0c1228ea55de12b41903f7518f037ca8f3badd4d37066b
|
data/.gitignore
ADDED
data/.rvmrc.example
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use rbx-2.0.0-rc1@artoo-sphero --create
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
artoo-sphero (1.0.0.pre)
|
5
|
+
artoo (~> 1.0.0.pre)
|
6
|
+
hybridgroup-sphero (~> 1.3.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
artoo (1.0.0.pre)
|
12
|
+
celluloid (~> 0.14.0)
|
13
|
+
celluloid-io (~> 0.14.0)
|
14
|
+
multi_json (~> 1.6)
|
15
|
+
pry (~> 0.9)
|
16
|
+
rake (~> 10.0)
|
17
|
+
reel (~> 0.4.pre)
|
18
|
+
celluloid (0.14.0)
|
19
|
+
timers (>= 1.0.0)
|
20
|
+
celluloid-io (0.14.0)
|
21
|
+
celluloid (>= 0.13.0)
|
22
|
+
nio4r (>= 0.4.5)
|
23
|
+
certified (0.1.1)
|
24
|
+
coderay (1.0.9)
|
25
|
+
http (0.4.0)
|
26
|
+
certified
|
27
|
+
http_parser.rb
|
28
|
+
http_parser.rb (0.5.3)
|
29
|
+
hybridgroup-sphero (1.3.0)
|
30
|
+
metaclass (0.0.1)
|
31
|
+
method_source (0.8.1)
|
32
|
+
minitest (5.0.1)
|
33
|
+
minitest-happy (1.0.0)
|
34
|
+
mocha (0.14.0)
|
35
|
+
metaclass (~> 0.0.1)
|
36
|
+
multi_json (1.7.3)
|
37
|
+
nio4r (0.4.5)
|
38
|
+
pry (0.9.12.2)
|
39
|
+
coderay (~> 1.0.5)
|
40
|
+
method_source (~> 0.8)
|
41
|
+
slop (~> 3.4)
|
42
|
+
rack (1.5.2)
|
43
|
+
rake (10.0.4)
|
44
|
+
reel (0.4.0.pre)
|
45
|
+
celluloid-io (>= 0.8.0)
|
46
|
+
http (>= 0.2.0)
|
47
|
+
http_parser.rb (>= 0.5.3)
|
48
|
+
rack (>= 1.4.0)
|
49
|
+
websocket_parser (>= 0.1.2)
|
50
|
+
slop (3.4.5)
|
51
|
+
timers (1.1.0)
|
52
|
+
websocket_parser (0.1.4)
|
53
|
+
http
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
artoo-sphero!
|
60
|
+
minitest (~> 5.0)
|
61
|
+
minitest-happy
|
62
|
+
mocha (~> 0.14.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012, 2013 The Hybrid Group
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Artoo Adaptor For Sphero
|
2
|
+
|
3
|
+
This repository contains the Artoo (http://artoo.io/) adaptor for the Sphero (http://gosphero.com) robot.
|
4
|
+
|
5
|
+
Artoo is a open source micro-framework for robotics using Ruby.
|
6
|
+
|
7
|
+
For more information abut Artoo, check out our repo at https://github.com/hybridgroup/artoo
|
8
|
+
|
9
|
+
[](https://codeclimate.com/github/hybridgroup/artoo-sphero) [](https://travis-ci.org/hybridgroup/artoo-sphero)
|
10
|
+
|
11
|
+
## Installing
|
12
|
+
|
13
|
+
```
|
14
|
+
gem install artoo-sphero
|
15
|
+
```
|
16
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "artoo-sphero/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "artoo-sphero"
|
7
|
+
s.version = Artoo::Sphero::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ron Evans", "Adrian Zankich"]
|
10
|
+
s.email = ["artoo@hybridgroup.com"]
|
11
|
+
s.homepage = "https://github.com/hybridgroup/artoo-sphero"
|
12
|
+
s.summary = %q{Artoo adaptor and driver for Sphero robot}
|
13
|
+
s.description = %q{Artoo adaptor and driver for Sphero robot}
|
14
|
+
|
15
|
+
s.rubyforge_project = "artoo-sphero"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_runtime_dependency 'artoo', '~> 1.0.0.pre'
|
23
|
+
s.add_runtime_dependency 'hybridgroup-sphero', '~> 1.3.0'
|
24
|
+
s.add_development_dependency 'minitest', '~> 5.0'
|
25
|
+
s.add_development_dependency 'minitest-happy'
|
26
|
+
s.add_development_dependency 'mocha', '~> 0.14.0'
|
27
|
+
end
|
data/bin/sphero.sh
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# This will create a sphero connection bound to /dev/Sphero-XXX
|
4
|
+
#
|
5
|
+
# Requires sudo or ran as root
|
6
|
+
#
|
7
|
+
# $1 = unbound /dev/rfcommXX
|
8
|
+
# $2 = sphero hardware address from hcitool scan
|
9
|
+
# $3 = sphero three letter color code
|
10
|
+
#
|
11
|
+
# Optional parameter
|
12
|
+
# $4 = bluetooth radio hcix
|
13
|
+
#
|
14
|
+
# Example
|
15
|
+
#
|
16
|
+
# sudo ./sphero_linux_bind.sh 1 00:06:66:4A:43:23 PYG hci1
|
17
|
+
#
|
18
|
+
#
|
19
|
+
if [ -z "$4" ]; then
|
20
|
+
addr="hci0"
|
21
|
+
else
|
22
|
+
addr=$4
|
23
|
+
fi
|
24
|
+
rfcomm -i $addr bind /dev/rfcomm$1 $2 1
|
25
|
+
ln -s /dev/rfcomm$1 /dev/Sphero-$3
|
data/examples/sphero.rb
ADDED
data/examples/sphero2.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'artoo/robot'
|
2
|
+
|
3
|
+
class DoubleSpheroRobot < Artoo::Robot
|
4
|
+
connection :sphero, :adaptor => :sphero
|
5
|
+
device :sphero, :driver => :sphero
|
6
|
+
|
7
|
+
work do
|
8
|
+
@count = 1
|
9
|
+
every(3.seconds) do
|
10
|
+
sphero.set_color(@count % 2 == 0 ? :green : :blue)
|
11
|
+
@count += 1
|
12
|
+
sphero.roll 90, rand(360)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
SPHEROS = {"127.0.0.1:4560" => "/dev/tty.Sphero-BRG-RN-SPP",
|
18
|
+
"127.0.0.1:4561" => "/dev/tty.Sphero-YBW-RN-SPP"}
|
19
|
+
robots = []
|
20
|
+
SPHEROS.each_key {|p|
|
21
|
+
robots << DoubleSpheroRobot.new(:connections =>
|
22
|
+
{:sphero =>
|
23
|
+
{:port => p}})
|
24
|
+
}
|
25
|
+
|
26
|
+
DoubleSpheroRobot.work!(robots)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'artoo'
|
2
|
+
|
3
|
+
connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4560'
|
4
|
+
device :sphero, :driver => :sphero
|
5
|
+
|
6
|
+
work do
|
7
|
+
@count = 1
|
8
|
+
every(3.seconds) do
|
9
|
+
sphero.set_color(@count % 2 == 0 ? :green : :blue)
|
10
|
+
@count += 1
|
11
|
+
sphero.roll 60, rand(360)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'artoo'
|
2
|
+
|
3
|
+
connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4560'
|
4
|
+
device :sphero, :driver => :sphero
|
5
|
+
|
6
|
+
work do
|
7
|
+
sphero.set_color(0, 0, 0)
|
8
|
+
sphero.set_color(:red)
|
9
|
+
sphero.set_color(:yellow)
|
10
|
+
sphero.set_color(:green)
|
11
|
+
sphero.set_color(0, 255, 255)
|
12
|
+
sphero.set_color(:blue)
|
13
|
+
sphero.set_color(255, 0, 255)
|
14
|
+
sphero.set_color(:white)
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'artoo'
|
2
|
+
|
3
|
+
connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4560'
|
4
|
+
device :sphero, :driver => :sphero
|
5
|
+
|
6
|
+
def contact(*args)
|
7
|
+
@contacts ||= 0
|
8
|
+
@contacts += 1
|
9
|
+
puts "Contact #{@contacts}"
|
10
|
+
end
|
11
|
+
|
12
|
+
work do
|
13
|
+
on sphero, :collision => :contact
|
14
|
+
|
15
|
+
every(3.seconds) do
|
16
|
+
puts "Rolling..."
|
17
|
+
sphero.roll 90, rand(360)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'artoo/robot'
|
2
|
+
|
3
|
+
class SpheroRobot < Artoo::Robot
|
4
|
+
connection :sphero, :adaptor => :sphero
|
5
|
+
device :sphero, :driver => :sphero
|
6
|
+
|
7
|
+
#api :host => '127.0.0.1', :port => '8080'
|
8
|
+
|
9
|
+
work do
|
10
|
+
@count = 1
|
11
|
+
|
12
|
+
every(3.seconds) do
|
13
|
+
sphero.set_color(@count % 2 == 0 ? :white : :blue)
|
14
|
+
@count += 1
|
15
|
+
sphero.roll 90, rand(360)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
SPHEROS = {"127.0.0.1:4560" => "/dev/tty.Sphero-BRG-RN-SPP",
|
21
|
+
"127.0.0.1:4561" => "/dev/tty.Sphero-YBW-RN-SPP",
|
22
|
+
"127.0.0.1:4562" => "/dev/tty.Sphero-BWY-RN-SPP",
|
23
|
+
"127.0.0.1:4563" => "/dev/tty.Sphero-YRR-RN-SPP",
|
24
|
+
"127.0.0.1:4564" => "/dev/tty.Sphero-OBG-RN-SPP",
|
25
|
+
"127.0.0.1:4565" => "/dev/tty.Sphero-GOB-RN-SPP",
|
26
|
+
"127.0.0.1:4566" => "/dev/tty.Sphero-PYG-RN-SPP"}
|
27
|
+
robots = []
|
28
|
+
SPHEROS.each_key {|p|
|
29
|
+
robots << SpheroRobot.new(:connections =>
|
30
|
+
{:sphero =>
|
31
|
+
{:port => p}})
|
32
|
+
}
|
33
|
+
|
34
|
+
SpheroRobot.work!(robots)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'artoo/adaptors/adaptor'
|
2
|
+
|
3
|
+
module Artoo
|
4
|
+
module Adaptors
|
5
|
+
# Connect to a Sphero device
|
6
|
+
# @see http://gosphero.com Sphero information
|
7
|
+
# @see http://rubydoc.info/gems/hybridgroup-sphero Sphero gem Documentation
|
8
|
+
class Sphero < Adaptor
|
9
|
+
finalizer :finalize
|
10
|
+
attr_reader :sphero
|
11
|
+
|
12
|
+
# Number of retries when connecting
|
13
|
+
RETRY_COUNT = 5
|
14
|
+
|
15
|
+
# Closes connection with device if connected
|
16
|
+
# @return [Boolean]
|
17
|
+
def finalize
|
18
|
+
if connected?
|
19
|
+
sphero.close
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Creates a connection with Sphero object with retries
|
24
|
+
# @return [Boolean]
|
25
|
+
def connect
|
26
|
+
@retries_left = RETRY_COUNT
|
27
|
+
require 'sphero' unless defined?(::Sphero)
|
28
|
+
begin
|
29
|
+
@sphero = ::Sphero.new(connect_to)
|
30
|
+
super
|
31
|
+
return true
|
32
|
+
rescue Errno::EBUSY => e
|
33
|
+
@retries_left -= 1
|
34
|
+
if @retries_left > 0
|
35
|
+
retry
|
36
|
+
else
|
37
|
+
Logger.error e.message
|
38
|
+
Logger.error e.backtrace.inspect
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Closes connection with device
|
45
|
+
# @return [Boolean]
|
46
|
+
def disconnect
|
47
|
+
sphero.close
|
48
|
+
super
|
49
|
+
end
|
50
|
+
|
51
|
+
# Uses method missing to call sphero actions
|
52
|
+
# @see http://rubydoc.info/gems/hybridgroup-sphero/Sphero Sphero documentation
|
53
|
+
def method_missing(method_name, *arguments, &block)
|
54
|
+
sphero.send(method_name, *arguments, &block)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'artoo/drivers/driver'
|
2
|
+
|
3
|
+
module Artoo
|
4
|
+
module Drivers
|
5
|
+
# The Sphero driver behaviors
|
6
|
+
class Sphero < Driver
|
7
|
+
|
8
|
+
RED = [255, 0, 0]
|
9
|
+
GREEN = [0, 255, 0]
|
10
|
+
YELLOW = [255, 255, 0]
|
11
|
+
BLUE = [0, 0, 255]
|
12
|
+
WHITE = [255, 255, 255]
|
13
|
+
|
14
|
+
COMMANDS = [:detect_collisions, :clear_collisions, :collisions,
|
15
|
+
:power_notifications, :sensor_data, :set_color, :color].freeze
|
16
|
+
|
17
|
+
# Starts drives and required connections
|
18
|
+
def start_driver
|
19
|
+
begin
|
20
|
+
detect_collisions
|
21
|
+
|
22
|
+
every(interval) do
|
23
|
+
handle_collision_events
|
24
|
+
end
|
25
|
+
|
26
|
+
super
|
27
|
+
rescue Exception => e
|
28
|
+
Logger.error "Error starting Sphero driver!"
|
29
|
+
Logger.error e.message
|
30
|
+
Logger.error e.backtrace.inspect
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def handle_collision_events
|
35
|
+
while i = find_event(::Sphero::Response::CollisionDetected) do
|
36
|
+
update_collision(messages.slice!(i))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Publish collision events
|
41
|
+
def update_collision(data)
|
42
|
+
publish(event_topic_name("collision"), data)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Detects collisions
|
46
|
+
# @param [Hash] params
|
47
|
+
def detect_collisions(params={})
|
48
|
+
connection.configure_collision_detection 0x01, 0x20, 0x20, 0x20, 0x20, 0x50
|
49
|
+
end
|
50
|
+
|
51
|
+
# Clears collisions
|
52
|
+
def clear_collisions
|
53
|
+
messages.clear if responses = messages
|
54
|
+
end
|
55
|
+
|
56
|
+
# @return [CollisionDetected] collision
|
57
|
+
def collisions
|
58
|
+
matching_response_types messages, ::Sphero::Response::CollisionDetected
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [PowerNotification] power notification
|
62
|
+
def power_notifications
|
63
|
+
matching_response_types messages, ::Sphero::Response::PowerNotification
|
64
|
+
end
|
65
|
+
|
66
|
+
# @return [SensorData] sensor data
|
67
|
+
def sensor_data
|
68
|
+
matching_response_types messages, ::Sphero::Response::SensorData
|
69
|
+
end
|
70
|
+
|
71
|
+
# Set color
|
72
|
+
# @param [Collection] colors
|
73
|
+
def set_color(*colors)
|
74
|
+
connection.rgb(*color(*colors))
|
75
|
+
end
|
76
|
+
|
77
|
+
# Retrieves color
|
78
|
+
# @param [Collection] colors
|
79
|
+
def color(*colors)
|
80
|
+
case colors.first
|
81
|
+
when :red then RED
|
82
|
+
when :green then GREEN
|
83
|
+
when :yellow then YELLOW
|
84
|
+
when :blue then BLUE
|
85
|
+
when :white then WHITE
|
86
|
+
else colors
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def find_event(response_klass)
|
93
|
+
messages.index {|m| m.is_a? response_klass}
|
94
|
+
end
|
95
|
+
|
96
|
+
def matching_response_types(responses, respone_klass)
|
97
|
+
responses.select { |m| m.is_a? respone_klass } if responses
|
98
|
+
end
|
99
|
+
|
100
|
+
def messages
|
101
|
+
connection.async_messages
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/artoo-sphero.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
2
|
+
require 'artoo/adaptors/sphero'
|
3
|
+
require 'sphero'
|
4
|
+
|
5
|
+
describe Artoo::Adaptors::Sphero do
|
6
|
+
before do
|
7
|
+
@port = Artoo::Port.new('/dev/awesome')
|
8
|
+
@adaptor = Artoo::Adaptors::Sphero.new(:port => @port)
|
9
|
+
@sphero = mock('sphero')
|
10
|
+
Sphero.stubs(:new).returns(@sphero)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'Artoo::Adaptors::Sphero#connect' do
|
14
|
+
@adaptor.connect.must_equal true
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'Artoo::Adaptors::Sphero#disconnect' do
|
18
|
+
@adaptor.connect
|
19
|
+
|
20
|
+
@sphero.expects(:close)
|
21
|
+
@adaptor.disconnect
|
22
|
+
@adaptor.connected?.must_equal false
|
23
|
+
end
|
24
|
+
end
|
@@ -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
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: artoo-sphero
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ron Evans
|
8
|
+
- Adrian Zankich
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: artoo
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.0.0.pre
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.0.0.pre
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: hybridgroup-sphero
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.3.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.3.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: minitest
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '5.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '5.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest-happy
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: mocha
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.14.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.14.0
|
84
|
+
description: Artoo adaptor and driver for Sphero robot
|
85
|
+
email:
|
86
|
+
- artoo@hybridgroup.com
|
87
|
+
executables:
|
88
|
+
- sphero.sh
|
89
|
+
- sphero_linux_bind.sh
|
90
|
+
- sphero_linux_socat.sh
|
91
|
+
extensions: []
|
92
|
+
extra_rdoc_files: []
|
93
|
+
files:
|
94
|
+
- .gitignore
|
95
|
+
- .rvmrc.example
|
96
|
+
- .travis.yml
|
97
|
+
- Gemfile
|
98
|
+
- Gemfile.lock
|
99
|
+
- LICENSE
|
100
|
+
- README.md
|
101
|
+
- Rakefile
|
102
|
+
- artoo-sphero.gemspec
|
103
|
+
- bin/sphero.sh
|
104
|
+
- bin/sphero_linux_bind.sh
|
105
|
+
- bin/sphero_linux_socat.sh
|
106
|
+
- examples/sphero.rb
|
107
|
+
- examples/sphero2.rb
|
108
|
+
- examples/sphero_color.rb
|
109
|
+
- examples/sphero_cycle.rb
|
110
|
+
- examples/sphero_messages.rb
|
111
|
+
- examples/sphero_multiple.rb
|
112
|
+
- lib/artoo-sphero.rb
|
113
|
+
- lib/artoo-sphero/version.rb
|
114
|
+
- lib/artoo/adaptors/sphero.rb
|
115
|
+
- lib/artoo/drivers/sphero.rb
|
116
|
+
- test/adaptors/sphero_test.rb
|
117
|
+
- test/drivers/sphero_test.rb
|
118
|
+
- test/test_helper.rb
|
119
|
+
homepage: https://github.com/hybridgroup/artoo-sphero
|
120
|
+
licenses: []
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - '>'
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 1.3.1
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project: artoo-sphero
|
138
|
+
rubygems_version: 2.0.3
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Artoo adaptor and driver for Sphero robot
|
142
|
+
test_files: []
|