artoo-sphero 1.4.0 → 1.5.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: 7507b0ede5639c02f83755caaf79bfcf0338ac86
4
- data.tar.gz: a315842f56618f9dc23259d3cf341c7fb651de5e
3
+ metadata.gz: 0ae96ff0cb00e1374fbaecb2b8369007646e9537
4
+ data.tar.gz: 7105cb2f87e72baeeae67b6c44b1626322794d4c
5
5
  SHA512:
6
- metadata.gz: 22d7e5ef84665e7aed238abc7bf13a0d878fdfebaef1f592c1975ace9f47587a7616ed91fbbe3364dd326bc733c99b6ec847143407f602359c106b989bea5ece
7
- data.tar.gz: 16c97c98413658ab034aa8b98d5ab2776d08cba7c5dd3780ed7f2ce33f6042c46641028cd505a726f10dc1446e2d5ad07fa91858514bafa6315305b098fe5cd3
6
+ metadata.gz: 7a888596ad66ee223332a0a68bedc6f71f2fea8a860a81dbc48e00795e5994d893850d9f593812a9466b8324570f89a6fda40d02a81ffb8308d70f5bff1d0770
7
+ data.tar.gz: ae7e3a60e3e89783bdf13a508cada51d31cba752ca4f3a986a173aec4420bf99a83ce15509aeecd8d3b773948213a13f1f79507fe03615bbdbbf21dcfcc0a595
data/README.md CHANGED
@@ -57,3 +57,30 @@ connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
57
57
  ### Windows
58
58
 
59
59
  We are currently working with the Celluloid team to add Windows support. Please check back soon!
60
+
61
+ ## Documentation
62
+
63
+ Check out our [documentation](http://artoo.io/documentation/) for lots of information about how to use Artoo.
64
+
65
+ If you want to help us with some documentation on the site, you can go to [artoo.io branch](https://github.com/hybridgroup/artoo/tree/artoo.io) and then, follow the instructions.
66
+
67
+ ## IRC
68
+
69
+ Need more help? Just want to say "Hello"? Come visit us on IRC freenode #artoo
70
+
71
+ ## Contributing
72
+ * All active development is in the dev branch. New or updated features must be added to the dev branch. Hotfixes will be considered on the master branch in situations where it does not alter behaviour or features, only fixes a bug.
73
+ * All patches must be provided under the Apache 2.0 License
74
+ * 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
75
+ * Submit a Github Pull Request to the appropriate branch and ideally discuss the changes with us in IRC.
76
+ * We will look at the patch, test it out, and give you feedback.
77
+ * 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.
78
+ * Take care to maintain the existing coding style.
79
+ * Add unit tests for any new or changed functionality.
80
+ * All pull requests should be "fast forward"
81
+ * If there are commits after yours use “git rebase -i <new_head_branch>”
82
+ * If you have local changes you may need to use “git stash”
83
+ * For git help see [progit](http://git-scm.com/book) which is an awesome (and free) book on git
84
+
85
+
86
+ (c) 2012-2014 The Hybrid Group
@@ -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.6.7'
22
+ s.add_runtime_dependency 'artoo', '>= 1.7.0'
23
23
  s.add_runtime_dependency 'sphero', '>= 1.5.1'
24
24
  s.add_development_dependency 'minitest', '>= 5.0'
25
25
  s.add_development_dependency 'minitest-happy', "~>1.0.0"
@@ -1,8 +1,6 @@
1
1
  require 'artoo'
2
2
 
3
3
  connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
4
- #connection :sphero, :adaptor => :sphero, :port => '127.0.0.1:4567'
5
-
6
4
  device :sphero, :driver => :sphero
7
5
 
8
6
  work do
@@ -0,0 +1,21 @@
1
+ require 'artoo'
2
+
3
+ connection :sphero, :adaptor => :sphero, :port => '/dev/rfcomm0' #linux
4
+ device :sphero, :driver => :sphero
5
+
6
+ work do
7
+ @rolling = false
8
+
9
+ every(3.seconds) do
10
+ puts "Rolling..."
11
+ unless @rolling
12
+ # same as interfaces[:rover].forward(90)
13
+ forward(90)
14
+ @rolling = true
15
+ else
16
+ # same as interfaces[:rover].backward(90)
17
+ backward(90)
18
+ @rolling = false
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,4 @@
1
1
  require 'lib/artoo/adaptors/sphero'
2
2
  require 'lib/artoo/drivers/sphero'
3
+ require 'lib/artoo/interfaces/sphero'
3
4
  require 'lib/artoo-sphero/version'
@@ -1,5 +1,5 @@
1
1
  module Artoo
2
2
  module Sphero
3
- VERSION = '1.4.0'
3
+ VERSION = '1.5.0'
4
4
  end
5
5
  end
@@ -35,6 +35,7 @@ module Artoo
35
35
  # Closes connection with device
36
36
  # @return [Boolean]
37
37
  def disconnect
38
+ Logger.info "Stopping and disconnecting sphero"
38
39
  sphero.close if connected?
39
40
 
40
41
  super
@@ -16,7 +16,13 @@ module Artoo
16
16
  :stop, :heading, :stabilization, :color, :rgb, :set_color,
17
17
  :back_led_output, :rotation_rate, :set_power_notification,
18
18
  :set_data_streaming, :detect_collisions,
19
- :handle_message_events, :get_rgb].freeze
19
+ :handle_message_events, :get_rgb, :start_calibration,
20
+ :finish_calibration].freeze
21
+
22
+ def initialize(params={})
23
+ super
24
+ require_interface(:sphero)
25
+ end
20
26
 
21
27
  # Starts drives and required connections
22
28
 
@@ -26,6 +32,7 @@ module Artoo
26
32
  def start_driver
27
33
  begin
28
34
  detect_collisions
35
+ enable_stop_on_disconnect
29
36
 
30
37
  every(interval) do
31
38
  handle_message_events
@@ -117,6 +124,21 @@ module Artoo
117
124
  [rgb.r, rgb.g, rgb.b] if rgb
118
125
  end
119
126
 
127
+ # Starts calibration process by turning on back LED and turning off
128
+ # auto-stabilization
129
+ def start_calibration
130
+ connection.back_led_output = 127
131
+ connection.stabilization = false
132
+ end
133
+
134
+ # Finishes calibration process by setting the new heading, turning off back LED,
135
+ # and turning back on auto-stabilization
136
+ def finish_calibration
137
+ connection.heading = 0
138
+ connection.back_led_output = 0
139
+ connection.stabilization = true
140
+ end
141
+
120
142
  private
121
143
 
122
144
  # Publish collision events
@@ -0,0 +1,36 @@
1
+ require 'artoo/interfaces/interface'
2
+
3
+ module Artoo
4
+ module Interfaces
5
+ # The Sphero Rover interface
6
+ class Sphero < Rover
7
+ def forward(speed)
8
+ @device.roll 0, speed
9
+ end
10
+
11
+ def backward(speed)
12
+ @device.roll 180, speed
13
+ end
14
+
15
+ def left(speed)
16
+ @device.roll 270, speed
17
+ end
18
+
19
+ def right(speed)
20
+ @device.roll 90, speed
21
+ end
22
+
23
+ def turn_left(degrees)
24
+ # TODO: implement
25
+ end
26
+
27
+ def turn_right(degrees)
28
+ # TODO: implement
29
+ end
30
+
31
+ def stop
32
+ @device.stop
33
+ end
34
+ end
35
+ end
36
+ end
@@ -4,6 +4,7 @@ require 'artoo/drivers/sphero'
4
4
  describe Artoo::Drivers::Sphero do
5
5
  before do
6
6
  @device = mock('device')
7
+ @device.stubs(:require_interface)
7
8
  @driver = Artoo::Drivers::Sphero.new(:parent => @device)
8
9
  @connection = mock('connection')
9
10
  @messages = Queue.new
@@ -73,4 +74,7 @@ describe Artoo::Drivers::Sphero do
73
74
 
74
75
  end
75
76
 
77
+ it 'should be able to start calibration process'
78
+ it 'should be able to finish calibration process'
79
+
76
80
  end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
+ require 'artoo/interfaces/sphero'
3
+
4
+ describe Artoo::Interfaces::Sphero do
5
+ before do
6
+ @device = mock('device')
7
+ @interface = Artoo::Interfaces::Sphero.new(:device => @device)
8
+ end
9
+
10
+ describe "Rover interface" do
11
+ it 'Rover#forward' do
12
+ @device.expects(:roll).with(0, 30)
13
+ @interface.forward 30
14
+ end
15
+
16
+ it 'Rover#backward' do
17
+ @device.expects(:roll).with(180, 30)
18
+ @interface.backward 30
19
+ end
20
+
21
+ it 'Rover#right' do
22
+ @device.expects(:roll).with(90, 30)
23
+ @interface.right 30
24
+ end
25
+
26
+ it 'Rover#left' do
27
+ @device.expects(:roll).with(270, 30)
28
+ @interface.left 30
29
+ end
30
+
31
+ it 'Rover#turn_right'
32
+ it 'Rover#turn_left'
33
+ it 'Rover#stop' do
34
+ @device.expects(:stop)
35
+ @interface.stop
36
+ end
37
+
38
+ end
39
+ end
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.4.0
4
+ version: 1.5.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-07-04 00:00:00.000000000 Z
15
+ date: 2014-08-15 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: artoo
@@ -20,14 +20,14 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.6.7
23
+ version: 1.7.0
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.7
30
+ version: 1.7.0
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: sphero
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +107,7 @@ files:
107
107
  - examples/sphero2.rb
108
108
  - examples/sphero_color.rb
109
109
  - examples/sphero_cycle.rb
110
+ - examples/sphero_interface.rb
110
111
  - examples/sphero_messages.rb
111
112
  - examples/sphero_multiple.rb
112
113
  - examples/sphero_pebble.rb
@@ -115,8 +116,10 @@ files:
115
116
  - lib/artoo-sphero/version.rb
116
117
  - lib/artoo/adaptors/sphero.rb
117
118
  - lib/artoo/drivers/sphero.rb
119
+ - lib/artoo/interfaces/sphero.rb
118
120
  - test/adaptors/sphero_test.rb
119
121
  - test/drivers/sphero_test.rb
122
+ - test/interfaces/sphero_test.rb
120
123
  - test/test_helper.rb
121
124
  homepage: https://github.com/hybridgroup/artoo-sphero
122
125
  licenses: []
@@ -137,8 +140,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
140
  version: '0'
138
141
  requirements: []
139
142
  rubyforge_project: artoo-sphero
140
- rubygems_version: 2.2.0
143
+ rubygems_version: 2.2.2
141
144
  signing_key:
142
145
  specification_version: 4
143
146
  summary: Artoo adaptor and driver for Sphero robot
144
- test_files: []
147
+ test_files:
148
+ - test/adaptors/sphero_test.rb
149
+ - test/drivers/sphero_test.rb
150
+ - test/interfaces/sphero_test.rb
151
+ - test/test_helper.rb
152
+ has_rdoc: