artoo-neurosky 0.1.0
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 +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +55 -0
- data/LICENSE +13 -0
- data/README.md +96 -0
- data/Rakefile +10 -0
- data/artoo-neurosky.gemspec +30 -0
- data/example/eeg.rb +13 -0
- data/example/neuro.rb +8 -0
- data/lib/artoo-neurosky.rb +3 -0
- data/lib/artoo-neurosky/version.rb +5 -0
- data/lib/artoo/adaptors/neurosky.rb +59 -0
- data/lib/artoo/drivers/neurosky.rb +68 -0
- data/test/adaptors/neurosky_adaptor_test.rb +4 -0
- data/test/drivers/neurosky_driver_test.rb +4 -0
- data/test/test_helper.rb +5 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6931d8b72d53dfb498d0cfeb9b72599db2c7edf7
|
4
|
+
data.tar.gz: 7271aa5fe9d8d6a9a11e14d45cea120a05971b82
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 34cbbb9a0e0c80f5db27f3815bbd01e85613c62d0448161d6e12749a7a0aad9dab17e034654b2fa10df4b454a7358ff514929a9166aab6fef480e6be019f4c7c
|
7
|
+
data.tar.gz: b087bbbac9892640535de5ab35ffd10d52a562c77a24234a969b0b9d8d28ae5176e9eb319b9a8675de061f075825382770fad30ebb84d0c7daf5ebf6373be8c1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
artoo-neurosky (0.1.0)
|
5
|
+
artoo (>= 1.6.4)
|
6
|
+
mindset
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
artoo (1.6.4)
|
12
|
+
celluloid (~> 0.15)
|
13
|
+
celluloid-io (~> 0.15)
|
14
|
+
http (~> 0.5)
|
15
|
+
multi_json (~> 1.6)
|
16
|
+
pry (~> 0.9)
|
17
|
+
rake
|
18
|
+
reel (~> 0.4)
|
19
|
+
robeaux (~> 0.0.4)
|
20
|
+
thor (~> 0.18.1)
|
21
|
+
celluloid (0.15.2)
|
22
|
+
timers (~> 1.1.0)
|
23
|
+
celluloid-io (0.15.0)
|
24
|
+
celluloid (>= 0.15.0)
|
25
|
+
nio4r (>= 0.5.0)
|
26
|
+
coderay (1.1.0)
|
27
|
+
http (0.5.0)
|
28
|
+
http_parser.rb
|
29
|
+
http_parser.rb (0.6.0)
|
30
|
+
method_source (0.8.2)
|
31
|
+
mindset (0.2)
|
32
|
+
multi_json (1.9.2)
|
33
|
+
nio4r (1.0.0)
|
34
|
+
pry (0.9.12.6)
|
35
|
+
coderay (~> 1.0)
|
36
|
+
method_source (~> 0.8)
|
37
|
+
slop (~> 3.4)
|
38
|
+
rake (10.2.2)
|
39
|
+
reel (0.4.0)
|
40
|
+
celluloid (>= 0.15.1)
|
41
|
+
celluloid-io (>= 0.15.0)
|
42
|
+
http (>= 0.5.0)
|
43
|
+
http_parser.rb (>= 0.6.0.beta.2)
|
44
|
+
websocket_parser (>= 0.1.4)
|
45
|
+
robeaux (0.0.4)
|
46
|
+
slop (3.5.0)
|
47
|
+
thor (0.18.1)
|
48
|
+
timers (1.1.0)
|
49
|
+
websocket_parser (0.1.6)
|
50
|
+
|
51
|
+
PLATFORMS
|
52
|
+
ruby
|
53
|
+
|
54
|
+
DEPENDENCIES
|
55
|
+
artoo-neurosky!
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012-2014 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,96 @@
|
|
1
|
+
# Artoo Adaptor For Sphero
|
2
|
+
|
3
|
+
This repository contains the Artoo (http://artoo.io/) adaptor for the Neurosky Mindwave Mobile EEG (http://store.neurosky.com/products/mindwave-mobile).
|
4
|
+
|
5
|
+
Artoo is a open source 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-neurosky) [](https://travis-ci.org/hybridgroup/artoo-neurosky)
|
10
|
+
|
11
|
+
## Installing
|
12
|
+
|
13
|
+
```
|
14
|
+
gem install artoo-neurosky
|
15
|
+
```
|
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
|
+
## Using
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'artoo'
|
27
|
+
|
28
|
+
connection :neurosky, :adaptor => :neurosky, :port => '/dev/rfcomm0'
|
29
|
+
device :neurosky, :driver => :neurosky, :interval => 0.1
|
30
|
+
|
31
|
+
def handle_eeg(sender, data)
|
32
|
+
puts data
|
33
|
+
end
|
34
|
+
|
35
|
+
work do
|
36
|
+
puts "Scanning..."
|
37
|
+
on neurosky, :eeg => :handle_eeg
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
## Connecting to Mindwave
|
42
|
+
|
43
|
+
### OSX
|
44
|
+
|
45
|
+
The main steps are:
|
46
|
+
- Pair your computer and the Mindwave
|
47
|
+
- Use a socket to serial connection to map a TCP socket to the local unix port
|
48
|
+
- Connect to the device via Artoo
|
49
|
+
|
50
|
+
First pair your computer and Mindwave. You might be prompted for a passcode, if so enter '0000'.
|
51
|
+
|
52
|
+
Once paired, use the `artoo connect scan` command to find out your connection info:
|
53
|
+
|
54
|
+
```
|
55
|
+
$ artoo connect scan
|
56
|
+
```
|
57
|
+
|
58
|
+
Now you are ready to connect to the Mindwave using the socket, in this example port 4567:
|
59
|
+
|
60
|
+
```
|
61
|
+
artoo connect serial /dev/rfcomm0 4567
|
62
|
+
```
|
63
|
+
|
64
|
+
### Ubuntu
|
65
|
+
|
66
|
+
The main steps are:
|
67
|
+
- Pair your computer and the Mindwave
|
68
|
+
- Map your device to a unix port
|
69
|
+
- Use a socket to serial connection to map a TCP socket to the local unix port
|
70
|
+
- Connect to the device via Artoo
|
71
|
+
|
72
|
+
First pair your computer and Mindwave. You might be prompted for a passcode, if so enter '0000'.
|
73
|
+
|
74
|
+
Once paired, use the `artoo connect scan` command to find out your connection info:
|
75
|
+
|
76
|
+
```
|
77
|
+
$ artoo connect scan
|
78
|
+
Scanning ...
|
79
|
+
00:06:66:4A:14:99 Mindwave
|
80
|
+
```
|
81
|
+
|
82
|
+
Next, you need to bind the Mindawave to the system port. In the above example, /dev/rfcomm0. The easiest way to do this is to use the `artoo connect bind` command:
|
83
|
+
|
84
|
+
```
|
85
|
+
artoo connect bind 00:06:66:4A:14:99 /dev/rfcomm0
|
86
|
+
```
|
87
|
+
|
88
|
+
Now you are ready to connect to the Sphero using the socket, in this example port 4567:
|
89
|
+
|
90
|
+
```
|
91
|
+
artoo connect serial /dev/rfcomm0 4567
|
92
|
+
```
|
93
|
+
|
94
|
+
### Windows
|
95
|
+
|
96
|
+
We are currently working with the Celluloid team to add Windows support. Please check back soon!
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "artoo-neurosky/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "artoo-neurosky"
|
7
|
+
s.version = Artoo::Neurosky::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ron Evans"]
|
10
|
+
s.email = ["artoo@hybridgroup.com"]
|
11
|
+
s.homepage = "https://github.com/hybridgroup/artoo-neurosky"
|
12
|
+
s.license = "Apache 2.0"
|
13
|
+
s.summary = %q{Artoo adaptor and driver for Neurosky}
|
14
|
+
s.description = %q{Artoo adaptor and driver for Neurosky}
|
15
|
+
|
16
|
+
s.rubyforge_project = "artoo-neurosky"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.add_runtime_dependency 'artoo', '>= 1.6.4'
|
24
|
+
s.add_runtime_dependency 'mindset'
|
25
|
+
# TODO: add your development dependencies here
|
26
|
+
# EXAMPLE:
|
27
|
+
# s.add_development_dependency 'minitest', '>= 5.0'
|
28
|
+
# s.add_development_dependency 'minitest-happy'
|
29
|
+
# s.add_development_dependency 'mocha', '>= 0.14.0'
|
30
|
+
end
|
data/example/eeg.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'artoo'
|
2
|
+
|
3
|
+
connection :neurosky, :adaptor => :neurosky, :port => '/dev/rfcomm0'
|
4
|
+
device :neurosky, :driver => :neurosky, :interval => 0.1
|
5
|
+
|
6
|
+
def handle_eeg(sender, data)
|
7
|
+
puts data
|
8
|
+
end
|
9
|
+
|
10
|
+
work do
|
11
|
+
puts "Scanning..."
|
12
|
+
on neurosky, :eeg => :handle_eeg
|
13
|
+
end
|
data/example/neuro.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'artoo/adaptors/adaptor'
|
2
|
+
|
3
|
+
module Artoo
|
4
|
+
module Adaptors
|
5
|
+
# Connect to a neurosky device
|
6
|
+
# @see device documentation for more information
|
7
|
+
class Neurosky < Adaptor
|
8
|
+
attr_reader :neurosky
|
9
|
+
|
10
|
+
# Number of retries when connecting
|
11
|
+
RETRY_COUNT = 5
|
12
|
+
|
13
|
+
# Creates a connection with device
|
14
|
+
# @return [Boolean]
|
15
|
+
def connect
|
16
|
+
@retries_left = RETRY_COUNT
|
17
|
+
require 'mindset' unless defined?(::Mindset)
|
18
|
+
begin
|
19
|
+
@neurosky = ::Mindset.connect(connect_to)
|
20
|
+
super
|
21
|
+
return true
|
22
|
+
rescue Errno::EBUSY, Errno::ECONNREFUSED => e
|
23
|
+
@retries_left -= 1
|
24
|
+
if @retries_left > 0
|
25
|
+
retry
|
26
|
+
else
|
27
|
+
Logger.error e.message
|
28
|
+
Logger.error e.backtrace.inspect
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Closes connection with device
|
35
|
+
# @return [Boolean]
|
36
|
+
def disconnect
|
37
|
+
neurosky.disconnect if connected?
|
38
|
+
end
|
39
|
+
|
40
|
+
# Name of device
|
41
|
+
# @return [String]
|
42
|
+
def name
|
43
|
+
"neurosky"
|
44
|
+
end
|
45
|
+
|
46
|
+
# Version of device
|
47
|
+
# @return [String]
|
48
|
+
def version
|
49
|
+
Artoo::Neurosky::VERSION
|
50
|
+
end
|
51
|
+
|
52
|
+
# Uses method missing to call device actions
|
53
|
+
# @see device documentation
|
54
|
+
def method_missing(method_name, *arguments, &block)
|
55
|
+
neurosky.send(method_name, *arguments, &block)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'artoo/drivers/driver'
|
2
|
+
|
3
|
+
module Artoo
|
4
|
+
module Drivers
|
5
|
+
# The neurosky driver behaviors
|
6
|
+
class Neurosky < Driver
|
7
|
+
|
8
|
+
# Start driver and any required connections
|
9
|
+
def start_driver
|
10
|
+
begin
|
11
|
+
every(interval) do
|
12
|
+
handle_message_events
|
13
|
+
end
|
14
|
+
|
15
|
+
super
|
16
|
+
rescue Exception => e
|
17
|
+
Logger.error "Error starting Neurosky driver!"
|
18
|
+
Logger.error e.message
|
19
|
+
Logger.error e.backtrace.inspect
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def handle_message_events
|
24
|
+
begin
|
25
|
+
while true do
|
26
|
+
packets = connection.read_packet
|
27
|
+
return if packets.empty?
|
28
|
+
packets.each { |pkt|
|
29
|
+
handle_packet(pkt)
|
30
|
+
}
|
31
|
+
end
|
32
|
+
#rescue ::Mindset::Connection::TimeoutError, Interrupt => e
|
33
|
+
#cont = false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def handle_packet(packet)
|
38
|
+
case
|
39
|
+
when packet[:wave]
|
40
|
+
publish(event_topic_name("wave"), packet[:wave])
|
41
|
+
|
42
|
+
when packet[:signal_quality]
|
43
|
+
publish(event_topic_name("signal_quality"), packet[:signal_quality])
|
44
|
+
|
45
|
+
when packet[:attention]
|
46
|
+
publish(event_topic_name("attention"), packet[:attention])
|
47
|
+
|
48
|
+
when packet[:meditation]
|
49
|
+
publish(event_topic_name("meditation"), packet[:meditation])
|
50
|
+
|
51
|
+
when packet[:delta]
|
52
|
+
publish(event_topic_name("eeg"), packet)
|
53
|
+
|
54
|
+
else
|
55
|
+
puts packet.inspect
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
{:signal_quality=>200}
|
61
|
+
{:delta=>7023617, :theta=>15294464, :lo_alpha=>15209472, :hi_alpha=>13321984, :lo_beta=>4527616, :hi_beta=>12073472, :lo_gamma=>862464, :mid_gamma=>13637632}
|
62
|
+
{:attention=>0}
|
63
|
+
{:meditation=>0}
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: artoo-neurosky
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ron Evans
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: artoo
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mindset
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Artoo adaptor and driver for Neurosky
|
42
|
+
email:
|
43
|
+
- artoo@hybridgroup.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- artoo-neurosky.gemspec
|
55
|
+
- example/eeg.rb
|
56
|
+
- example/neuro.rb
|
57
|
+
- lib/artoo-neurosky.rb
|
58
|
+
- lib/artoo-neurosky/version.rb
|
59
|
+
- lib/artoo/adaptors/neurosky.rb
|
60
|
+
- lib/artoo/drivers/neurosky.rb
|
61
|
+
- test/adaptors/neurosky_adaptor_test.rb
|
62
|
+
- test/drivers/neurosky_driver_test.rb
|
63
|
+
- test/test_helper.rb
|
64
|
+
homepage: https://github.com/hybridgroup/artoo-neurosky
|
65
|
+
licenses:
|
66
|
+
- Apache 2.0
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project: artoo-neurosky
|
84
|
+
rubygems_version: 2.2.1
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Artoo adaptor and driver for Neurosky
|
88
|
+
test_files: []
|