artoo-sphero 1.3.0 → 1.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: dd4ee78dc0212685f59e294a8e0d251a3829fe24
4
- data.tar.gz: 4f7d8f33dcf7046f5eea874e3d059c36bab252ea
3
+ metadata.gz: 7507b0ede5639c02f83755caaf79bfcf0338ac86
4
+ data.tar.gz: a315842f56618f9dc23259d3cf341c7fb651de5e
5
5
  SHA512:
6
- metadata.gz: 43a82c9001d6e5ec14eb2d8ceb25328ef1e9304e0eae0b14edb81203b82b985e53da0d377b1d1e034f2befba1246a0488546941a361cfb73b6cbc3a6611bbdc8
7
- data.tar.gz: a903b5eae8a65898e88340533eaa312b1dcbae953d056060055630d4deb6f441452179f000ed780cf53cd6a968269a4515f33bc800462c386f10ce35310dde59
6
+ metadata.gz: 22d7e5ef84665e7aed238abc7bf13a0d878fdfebaef1f592c1975ace9f47587a7616ed91fbbe3364dd326bc733c99b6ec847143407f602359c106b989bea5ece
7
+ data.tar.gz: 16c97c98413658ab034aa8b98d5ab2776d08cba7c5dd3780ed7f2ce33f6042c46641028cd505a726f10dc1446e2d5ad07fa91858514bafa6315305b098fe5cd3
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .rvmrc
2
2
  .rbx
3
3
  pkg
4
+ Gemfile.lock
data/.travis.yml CHANGED
@@ -1,6 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
+ - 2.1.0
4
5
  - 1.9.3
5
- - jruby-19mode
6
- - rbx-2.1.1
6
+ - jruby
7
+ - rbx-2.2.10
8
+ script:
9
+ - bundle install
10
+ - bundle exec rake test
data/README.md CHANGED
@@ -14,18 +14,12 @@ For more information abut Artoo, check out our repo at https://github.com/hybrid
14
14
  gem install artoo-sphero
15
15
  ```
16
16
 
17
- Afterwards you need to install `socat` - for this please run the following command (works on both OSX and Linux):
18
-
19
- ```
20
- artoo install socat
21
- ```
22
-
23
17
  ## Using
24
18
 
25
19
  ```ruby
26
20
  require 'artoo'
27
21
 
28
- connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4567'
22
+ connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
29
23
  device :sphero, :driver => :sphero
30
24
 
31
25
  work do
@@ -39,55 +33,25 @@ end
39
33
  ```
40
34
  ## Connecting to Sphero
41
35
 
42
- ### OSX
43
-
44
- The main steps are:
45
- - Pair your computer and the Sphero
46
- - Use a socket to serial connection to map a TCP socket to the local unix port
47
- - Connect to the device via Artoo
48
-
49
- First pair your computer and Sphero. You might be prompted for a passcode, but you do not need to enter it, sinec the Sphero does not check.
50
-
51
- Once paired, use the `artoo connect scan` command to find out your connection info:
52
-
53
- ```
54
- $ artoo connect scan
55
- ```
56
-
57
- Now you are ready to connect to the Sphero using the socket, in this example port 4567:
58
-
59
- ```
60
- artoo connect serial Sphero-WRW 4567
61
- ```
62
-
63
- ### Ubuntu
36
+ ### OSX / Linux
64
37
 
65
38
  The main steps are:
66
39
  - Pair your computer and the Sphero
67
40
  - Map your device to a unix port
68
- - Use a socket to serial connection to map a TCP socket to the local unix port
69
41
  - Connect to the device via Artoo
70
42
 
71
43
  First pair your computer and Sphero. You might be prompted for a passcode, but you do not need to enter it, sinec the Sphero does not check.
72
44
 
73
- Once paired, use the `artoo connect scan` command to find out your connection info:
74
-
75
- ```
76
- $ artoo connect scan
77
- Scanning ...
78
- 00:06:66:4A:14:99 Sphero-WRW
79
- ```
80
-
81
- Next, you need to bind the Sphero to the system port. In the above example, /dev/Sphero-WRW. The easiest way to do this is to use the `artoo connect bind` command:
45
+ Once paired, use the `artoo scan serial` command to find out your connection info:
82
46
 
83
47
  ```
84
- artoo connect bind 00:06:66:4A:14:99 Sphero-WRW
48
+ $ artoo scan serial
85
49
  ```
86
50
 
87
- Now you are ready to connect to the Sphero using the socket, in this example port 4567:
51
+ Now you are ready to connect to the Sphero, update the code to use correct serial port:
88
52
 
89
53
  ```
90
- artoo connect serial Sphero-WRW 4567
54
+ connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
91
55
  ```
92
56
 
93
57
  ### Windows
data/artoo-sphero.gemspec CHANGED
@@ -19,9 +19,9 @@ 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.6.0'
23
- s.add_runtime_dependency 'sphero', '>= 1.5.0'
22
+ s.add_runtime_dependency 'artoo', '>= 1.6.7'
23
+ s.add_runtime_dependency 'sphero', '>= 1.5.1'
24
24
  s.add_development_dependency 'minitest', '>= 5.0'
25
- s.add_development_dependency 'minitest-happy'
25
+ s.add_development_dependency 'minitest-happy', "~>1.0.0"
26
26
  s.add_development_dependency 'mocha', '>= 0.14.0'
27
27
  end
data/docs/commands.md CHANGED
@@ -21,7 +21,7 @@ Stops the sphero.
21
21
 
22
22
  `true or nil`
23
23
 
24
- ## detect_collissions
24
+ ## detect_collisions
25
25
 
26
26
  Sets the sphero to detect collisions and report them.
27
27
 
data/examples/sphero.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  require 'artoo'
2
2
 
3
- connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4567'
3
+ connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
4
+ #connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4567'
5
+
4
6
  device :sphero, :driver => :sphero
5
-
7
+
6
8
  work do
7
9
  @rolling = false
8
10
 
@@ -1,8 +1,9 @@
1
1
  require 'artoo'
2
2
 
3
- connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4560'
3
+ connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
4
+ #connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4567'
4
5
  device :sphero, :driver => :sphero
5
-
6
+
6
7
  work do
7
8
  @count = 1
8
9
  every(3.seconds) do
@@ -1,6 +1,7 @@
1
1
  require 'artoo'
2
2
 
3
- connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4560'
3
+ connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
4
+ #connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4567'
4
5
  device :sphero, :driver => :sphero
5
6
 
6
7
  def contact(*args)
@@ -0,0 +1,43 @@
1
+ require 'artoo'
2
+
3
+ connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
4
+ #connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4567'
5
+ device :sphero, :driver => :sphero
6
+
7
+ connection :pebble, :adaptor => :pebble
8
+ device :watch, :driver => :pebble, :name => 'pebble'
9
+
10
+ api :host => '0.0.0.0', :port => '8080'
11
+
12
+ name 'pebble'
13
+
14
+ def move_forward
15
+ p 'moving forward'
16
+ sphero.roll 100, 0
17
+ sleep 4
18
+ sphero.stop
19
+ end
20
+
21
+ def move_backward
22
+ p 'moving backward'
23
+ sphero.roll 100, 180
24
+ sleep 4
25
+ sphero.stop
26
+ end
27
+
28
+ def button_push(*data)
29
+ unless data[1].nil?
30
+ case data[1]
31
+ when 'up' then
32
+ move_forward
33
+ when 'select' then
34
+ sphero.set_color(rand(255),rand(255),rand(255))
35
+ when 'down' then
36
+ move_backward
37
+ end
38
+ end
39
+ end
40
+
41
+ work do
42
+ on pebble, :button => :button_push
43
+ end
@@ -0,0 +1,34 @@
1
+ require 'artoo'
2
+
3
+ connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
4
+ #connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4567'
5
+ device :sphero, :driver => :sphero
6
+
7
+ connection :pebble, :adaptor => :pebble
8
+ device :watch, :driver => :pebble, :name => 'pebble'
9
+
10
+ api :host => '0.0.0.0', :port => '8080'
11
+
12
+ name 'pebble'
13
+
14
+ work do
15
+ on pebble, :accel => :set_direction
16
+
17
+ every(1.seconds) do
18
+ sphero.roll 100, heading
19
+ end
20
+ end
21
+
22
+ def set_direction(*data)
23
+ x, y = data[1].split(",")
24
+
25
+ @heading = direction(x.to_i, y.to_i)
26
+ end
27
+
28
+ def direction(x, y)
29
+ (180.0 - (Math.atan2(y,x) * (180.0 / Math::PI)))
30
+ end
31
+
32
+ def heading
33
+ @heading || 0
34
+ end
@@ -1,5 +1,5 @@
1
1
  module Artoo
2
2
  module Sphero
3
- VERSION = '1.3.0'
3
+ VERSION = '1.4.0'
4
4
  end
5
5
  end
@@ -11,7 +11,12 @@ module Artoo
11
11
  BLUE = [0, 0, 255]
12
12
  WHITE = [255, 255, 255]
13
13
 
14
- COMMANDS = [:roll, :stop, :detect_collisions, :messages, :set_color, :color].freeze
14
+ COMMANDS = [:ping, :version, :bluetooth_info, :auto_reconnect,
15
+ :disable_auto_reconnect, :power_state, :sphero_sleep, :roll,
16
+ :stop, :heading, :stabilization, :color, :rgb, :set_color,
17
+ :back_led_output, :rotation_rate, :set_power_notification,
18
+ :set_data_streaming, :detect_collisions,
19
+ :handle_message_events, :get_rgb].freeze
15
20
 
16
21
  # Starts drives and required connections
17
22
 
@@ -37,8 +42,8 @@ module Artoo
37
42
  # Public: Handles different message events.
38
43
  #
39
44
  # Returns sphero_event.
40
- def handle_message_events
41
- while not connection.messages.empty? do
45
+ def handle_message_events
46
+ while not connection.messages.empty? do
42
47
  evt = connection.messages.pop
43
48
  case
44
49
  when evt.is_a?(::Sphero::Response::CollisionDetected)
@@ -74,7 +79,7 @@ module Artoo
74
79
  #
75
80
  # Returns true | nil.
76
81
  def set_color(*colors)
77
- connection.rgb(*color(*colors))
82
+ connection.rgb(*color(*colors), true)
78
83
  end
79
84
 
80
85
  # Retrieves color
@@ -101,11 +106,22 @@ module Artoo
101
106
  end
102
107
  end
103
108
 
109
+ # Get the sphero color
110
+
111
+ # Public: You can retrieve current sphero color
112
+ #
113
+ # Returns array of rgb values
114
+ def get_rgb
115
+ rgb = connection.user_led
116
+
117
+ [rgb.r, rgb.g, rgb.b] if rgb
118
+ end
119
+
104
120
  private
105
121
 
106
122
  # Publish collision events
107
123
 
108
- # Public: Handles collision message events.
124
+ # Handles collision message events.
109
125
  #
110
126
  # data - params
111
127
  #
@@ -127,7 +143,7 @@ module Artoo
127
143
 
128
144
  # Publish collision events
129
145
 
130
- # Public: Handles sensor message events.
146
+ # Handles sensor message events.
131
147
  #
132
148
  # data - params
133
149
  #
@@ -54,4 +54,23 @@ describe Artoo::Drivers::Sphero do
54
54
  b.must_equal 6
55
55
  end
56
56
  end
57
+
58
+ describe 'get_rgb' do
59
+
60
+ let(:rgb_color) { OpenStruct.new(r: 255, g: 254, b: 253) }
61
+
62
+ it 'returns rgb color' do
63
+ @connection.stubs(:user_led).returns(rgb_color)
64
+
65
+ @driver.get_rgb.must_equal [255, 254, 253]
66
+ end
67
+
68
+ it 'returns nil if message lost' do
69
+ @connection.stubs(:user_led).returns(nil)
70
+
71
+ @driver.get_rgb.must_equal nil
72
+ end
73
+
74
+ end
75
+
57
76
  end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'artoo/robot'
2
2
 
3
+ require 'minitest'
3
4
  require 'minitest/autorun'
4
5
  require 'mocha/setup'
5
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artoo-sphero
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ron Evans
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-02-06 00:00:00.000000000 Z
15
+ date: 2014-07-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: artoo
@@ -20,28 +20,28 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.6.0
23
+ version: 1.6.7
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: 1.6.0
30
+ version: 1.6.7
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: sphero
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  requirements:
35
35
  - - ">="
36
36
  - !ruby/object:Gem::Version
37
- version: 1.5.0
37
+ version: 1.5.1
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: 1.5.0
44
+ version: 1.5.1
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: minitest
47
47
  requirement: !ruby/object:Gem::Requirement
@@ -60,16 +60,16 @@ dependencies:
60
60
  name: minitest-happy
61
61
  requirement: !ruby/object:Gem::Requirement
62
62
  requirements:
63
- - - ">="
63
+ - - "~>"
64
64
  - !ruby/object:Gem::Version
65
- version: '0'
65
+ version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - ">="
70
+ - - "~>"
71
71
  - !ruby/object:Gem::Version
72
- version: '0'
72
+ version: 1.0.0
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: mocha
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -97,7 +97,6 @@ files:
97
97
  - ".rvmrc.example"
98
98
  - ".travis.yml"
99
99
  - Gemfile
100
- - Gemfile.lock
101
100
  - LICENSE
102
101
  - README.md
103
102
  - Rakefile
@@ -110,6 +109,8 @@ files:
110
109
  - examples/sphero_cycle.rb
111
110
  - examples/sphero_messages.rb
112
111
  - examples/sphero_multiple.rb
112
+ - examples/sphero_pebble.rb
113
+ - examples/sphero_pebble_accelerometer.rb
113
114
  - lib/artoo-sphero.rb
114
115
  - lib/artoo-sphero/version.rb
115
116
  - lib/artoo/adaptors/sphero.rb
@@ -136,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
137
  version: '0'
137
138
  requirements: []
138
139
  rubyforge_project: artoo-sphero
139
- rubygems_version: 2.2.1
140
+ rubygems_version: 2.2.0
140
141
  signing_key:
141
142
  specification_version: 4
142
143
  summary: Artoo adaptor and driver for Sphero robot
data/Gemfile.lock DELETED
@@ -1,62 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- artoo-sphero (1.3.0)
5
- artoo (>= 1.6.0)
6
- sphero (>= 1.5.0)
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- artoo (1.6.0)
12
- celluloid (~> 0.15.0)
13
- celluloid-io (~> 0.15.0)
14
- multi_json (~> 1.6)
15
- pry (~> 0.9)
16
- rake
17
- reel (~> 0.4.0)
18
- robeaux (~> 0.0.3)
19
- thor (~> 0.18.1)
20
- celluloid (0.15.2)
21
- timers (~> 1.1.0)
22
- celluloid-io (0.15.0)
23
- celluloid (>= 0.15.0)
24
- nio4r (>= 0.5.0)
25
- coderay (1.1.0)
26
- http (0.5.0)
27
- http_parser.rb
28
- http_parser.rb (0.6.0)
29
- metaclass (0.0.1)
30
- method_source (0.8.2)
31
- minitest (5.0.6)
32
- minitest-happy (1.0.0)
33
- mocha (0.14.0)
34
- metaclass (~> 0.0.1)
35
- multi_json (1.8.4)
36
- nio4r (1.0.0)
37
- pry (0.9.12.6)
38
- coderay (~> 1.0)
39
- method_source (~> 0.8)
40
- slop (~> 3.4)
41
- rake (10.1.1)
42
- reel (0.4.0)
43
- celluloid (>= 0.15.1)
44
- celluloid-io (>= 0.15.0)
45
- http (>= 0.5.0)
46
- http_parser.rb (>= 0.6.0.beta.2)
47
- websocket_parser (>= 0.1.4)
48
- robeaux (0.0.3)
49
- slop (3.4.7)
50
- sphero (1.5.0)
51
- thor (0.18.1)
52
- timers (1.1.0)
53
- websocket_parser (0.1.6)
54
-
55
- PLATFORMS
56
- ruby
57
-
58
- DEPENDENCIES
59
- artoo-sphero!
60
- minitest (>= 5.0)
61
- minitest-happy
62
- mocha (>= 0.14.0)