artoo 1.0.0.rc3 → 1.0.0.rc4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dada91f56c875c86f6f1f4a689a27417a65d760
4
- data.tar.gz: c66e5a9aa2311d76d7af2648bf6a362a14b8ed48
3
+ metadata.gz: 093191ca9b5924aab013a277c184b17098df5bc3
4
+ data.tar.gz: 637f3c2c3238c71af123329f0f4cd630cbf7b739
5
5
  SHA512:
6
- metadata.gz: 4b6b2c71e48df2bba926db39e2561b9cd23b8ef6ea74852ee996e78b480c5a8f888c6aeae01099e192e5cf2ead9e1c07b6ab84afea4f1c6b40d03091da2796f0
7
- data.tar.gz: 2fb9018b0178c87e21f6ae024564f0ea1ee51ee4293b6031bf65bfee2fcfb525e0e3f8be4e77e1d95a42ede9dbc2872330d33d84674b4db7d4cc2429cb2801a4
6
+ metadata.gz: a832d9d28b6f1775512baedb4ab1310da0232cfba55647830a53f6aee81d518e5b26753a29df6d53a41b2214bfec1b9635fcbcb41d94e60bb61a76e6084917c5
7
+ data.tar.gz: 985ecb0348dd5597bb744bc8d20fcda398e35e6faf3d3388198671a5e1e43ca2bbc6e9a3dfd7b17d7c2547e176f60ff75ef222dfebd93ce4cbe298fe34a818e3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- artoo (1.0.0.rc3)
4
+ artoo (1.0.0.rc4)
5
5
  celluloid (~> 0.14.1)
6
6
  celluloid-io (~> 0.14.1)
7
7
  multi_json (~> 1.6)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # artoo
1
+ [![Artoo](https://raw.github.com/hybridgroup/artoo/gh-pages/images/artoo-logo.png)](http://artoo.io)
2
2
 
3
3
  http://artoo.io/
4
4
 
@@ -76,21 +76,22 @@ SpheroRobot.work!(robots)
76
76
  Ruby versions supported: Ruby 2.0, Ruby 1.9.3, JRuby 1.7.4, and Rubinius 2.0-rc1
77
77
 
78
78
 
79
- Artoo is conceptualy influenced by Sinatra (https://github.com/sinatra/sinatra) as well as borrowing some code from it.
79
+ Artoo is conceptualy influenced by [Sinatra](https://github.com/sinatra/sinatra) as well as borrowing some code from it.
80
80
 
81
81
  Artoo provides a robust actor-based messaging architecture, that can support fully multi-threaded operation and high-concurrency, as long as it is supported by the Ruby version in which it is executing. This means you will need to use JRuby or Rubinius for maximum concurrency.
82
82
 
83
- To a large extent, this is due to being built on top of Celluloid (https://github.com/celluloid/celluloid), Celluloid::IO (https://github.com/celluloid/celluloid-io), and Reel (https://github.com/celluloid/reel).
83
+ To a large extent, this is due to being built on top of [Celluloid](https://github.com/celluloid/celluloid), [Celluloid::IO](https://github.com/celluloid/celluloid-io), and [Reel](https://github.com/celluloid/reel).
84
84
 
85
85
  ## Hardware support:
86
86
 
87
87
  Artoo has a extensible system for connecting to hardware devices. The following robotics and physical computing platforms are currently supported:
88
88
 
89
- - Arduino (http://www.arduino.cc/) adaptor (https://github.com/hybridgroup/artoo-arduino)
90
- - ARDrone (http://ardrone2.parrot.com/) adaptor (https://github.com/hybridgroup/artoo-ardrone)
91
- - Pebble (http://getpebble.com/) adaptor (https://github.com/hybridgroup/artoo-pebble)
92
- - Roomba (http://www.irobot.com/us/robots/Educators/Create.aspx) adaptor (https://github.com/hybridgroup/artoo-roomba)
93
- - Sphero (http://www.gosphero.com/) adaptor (https://github.com/hybridgroup/artoo-sphero)
89
+ - [Arduino](http://www.arduino.cc/) <=> [Adaptor](https://github.com/hybridgroup/artoo-arduino)
90
+ - [ARDrone](http://ardrone2.parrot.com/) <=> [Adaptor](https://github.com/hybridgroup/artoo-ardrone)
91
+ - [Leap Motion](https://www.leapmotion.com/) <=> [Adaptor](https://github.com/hybridgroup/artoo-leapmotion)
92
+ - [Pebble](http://getpebble.com/) <=> [Adaptor](https://github.com/hybridgroup/artoo-pebble)
93
+ - [Roomba](http://www.irobot.com/us/robots/Educators/Create.aspx) <=> [Adaptor](https://github.com/hybridgroup/artoo-roomba)
94
+ - [Sphero](http://www.gosphero.com/) <=> [Adaptor](https://github.com/hybridgroup/artoo-sphero)
94
95
 
95
96
  More platforms are coming soon!
96
97
 
@@ -238,7 +239,7 @@ You can scan your computer for paired Bluetooth devices, bind them to unix ports
238
239
 
239
240
  ### Console:
240
241
 
241
- Artoo includes Robi, a console based on Pry (http://pryrepl.org/) to allow you to interactively debug and control your robot.
242
+ Artoo includes Robi, a console based on [Pry](http://pryrepl.org/) to allow you to interactively debug and control your robot.
242
243
 
243
244
  ```
244
245
  $ artoo console ./examples/hello.rb
data/artoo.gemspec CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "https://github.com/hybridgroup/artoo"
12
12
  s.summary = %q{Ruby-based microframework for robotics}
13
13
  s.description = %q{Ruby-based microframework for robotics}
14
+ s.license = 'Apache 2.0'
14
15
 
15
16
  s.rubyforge_project = "artoo"
16
17
 
@@ -9,15 +9,17 @@ module Artoo
9
9
  class Adaptor
10
10
  include Celluloid::IO
11
11
 
12
- attr_reader :parent, :port
12
+ attr_reader :parent, :port, :additional_params
13
13
 
14
14
  # Initialize an adaptor
15
15
  # @param params [hash]
16
16
  # @option params [String] :parent
17
17
  # @option params [String] :port
18
+ # @option params [String] :additional_params
18
19
  def initialize(params={})
19
20
  @parent = params[:parent]
20
21
  @port = params[:port]
22
+ @additional_params = params[:additional_params]
21
23
  @connected = false
22
24
  end
23
25
 
@@ -8,10 +8,17 @@ module Artoo
8
8
  include Artoo::Utility
9
9
 
10
10
  desc "scan", "scan for connected devices"
11
+ option :type, :default => "bluetooth", :desc => "type of scan [bluetooth, serial]"
11
12
  def scan
12
13
  case os
13
14
  when :linux
14
- run("hcitool scan")
15
+ if options[:type] == 'bluetooth'
16
+ run("hcitool scan")
17
+ elsif options[:type] == 'serial'
18
+ run("ls /dev/tty.*")
19
+ else
20
+ say "ERROR: scan type '#{options[:type]}' not supported!"
21
+ end
15
22
  when :macosx
16
23
  run("ls /dev/tty.*")
17
24
  else
@@ -25,7 +32,7 @@ module Artoo
25
32
  def bind(address, name)
26
33
  case os
27
34
  when :linux
28
- run("rfcomm -i #{options[:radio]} bind /dev/rfcomm#{options[:comm]} #{address} 1")
35
+ run("sudo rfcomm -i #{options[:radio]} bind /dev/rfcomm#{options[:comm]} #{address} 1")
29
36
  run("sudo ln -s /dev/rfcomm#{options[:comm]} /dev/#{name}")
30
37
  when :macosx
31
38
  say "OSX binds devices on its own volition."
@@ -24,7 +24,7 @@ module Artoo
24
24
  @port = Port.new(params[:port])
25
25
  @parent = params[:parent]
26
26
 
27
- require_adaptor(params[:adaptor] || :loopback)
27
+ require_adaptor(params[:adaptor] || :loopback, params)
28
28
  end
29
29
 
30
30
  # Creates adaptor connection
@@ -92,14 +92,14 @@ module Artoo
92
92
 
93
93
  private
94
94
 
95
- def require_adaptor(type)
95
+ def require_adaptor(type, params)
96
96
  if Artoo::Robot.test?
97
97
  original_type = type
98
98
  type = :test
99
99
  end
100
100
 
101
101
  require "artoo/adaptors/#{type.to_s}"
102
- @adaptor = constantize("Artoo::Adaptors::#{classify(type.to_s)}").new(:port => port, :parent => current_instance)
102
+ @adaptor = constantize("Artoo::Adaptors::#{classify(type.to_s)}").new(:port => port, :parent => current_instance, :additional_params => params)
103
103
  end
104
104
  end
105
105
  end
data/lib/artoo/device.rb CHANGED
@@ -23,7 +23,7 @@ module Artoo
23
23
  @connection = determine_connection(params[:connection]) || default_connection
24
24
  @interval = params[:interval] || 0.5
25
25
 
26
- require_driver(params[:driver] || :passthru)
26
+ require_driver(params[:driver] || :passthru, params)
27
27
  end
28
28
 
29
29
  # Retrieve connections from parent
@@ -94,14 +94,14 @@ module Artoo
94
94
 
95
95
  private
96
96
 
97
- def require_driver(d)
97
+ def require_driver(d, params)
98
98
  if Artoo::Robot.test?
99
99
  original_type = d
100
100
  d = :test
101
101
  end
102
102
 
103
103
  require "artoo/drivers/#{d.to_s}"
104
- @driver = constantize("Artoo::Drivers::#{classify(d.to_s)}").new(:parent => current_instance)
104
+ @driver = constantize("Artoo::Drivers::#{classify(d.to_s)}").new(:parent => current_instance, :additional_params => params)
105
105
  end
106
106
  end
107
107
  end
@@ -10,15 +10,17 @@ module Artoo
10
10
  include Celluloid
11
11
  include Celluloid::Notifications
12
12
 
13
- attr_reader :parent
13
+ attr_reader :parent, :additional_params
14
14
 
15
15
  COMMANDS = [].freeze
16
16
 
17
17
  # Create new driver
18
18
  # @param [Hash] params
19
19
  # @option params [Object] :parent
20
+ # @option params [Object] :additional_params
20
21
  def initialize(params={})
21
22
  @parent = params[:parent]
23
+ @additional_params = params[:additional_params]
22
24
  end
23
25
 
24
26
  # @return [Connection] parent connection
@@ -11,3 +11,13 @@ For more information abut Artoo, check out our repo at https://github.com/hybrid
11
11
  ```
12
12
  gem install artoo-<%= adaptor_name %>
13
13
  ```
14
+
15
+ ## Using
16
+
17
+ ```ruby
18
+ # your example code here...
19
+ ```
20
+
21
+ ## Connecting
22
+
23
+ Explain how to connect from the computer to the device here...
@@ -11,6 +11,7 @@ module Artoo
11
11
  # Closes connection with device if connected
12
12
  # @return [Boolean]
13
13
  def finalize
14
+ disconnect if connected?
14
15
  end
15
16
 
16
17
  # Creates a connection with device
data/lib/artoo/port.rb CHANGED
@@ -6,8 +6,8 @@ module Artoo
6
6
 
7
7
  # Create new port
8
8
  # @param [Object] data
9
- def initialize(data)
10
- @is_tcp, @is_serial = false
9
+ def initialize(data=nil)
10
+ @is_tcp, @is_serial, @is_portless = false
11
11
  parse(data)
12
12
  end
13
13
 
@@ -21,9 +21,16 @@ module Artoo
21
21
  @is_tcp == true
22
22
  end
23
23
 
24
+ # @return [Boolean] True if does not have real port
25
+ def is_portless?
26
+ @is_portless == true
27
+ end
28
+
24
29
  # @return [String] port
25
30
  def to_s
26
- if is_serial?
31
+ if is_portless?
32
+ "none"
33
+ elsif is_serial?
27
34
  port
28
35
  else
29
36
  "#{host}:#{port}"
@@ -33,14 +40,20 @@ module Artoo
33
40
  private
34
41
 
35
42
  def parse(data)
43
+ case
44
+ # portless
45
+ when data.nil?
46
+ @port = "none"
47
+ @is_portless = true
48
+
36
49
  # is TCP host/port?
37
- if m = /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})/.match(data)
50
+ when m = /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})/.match(data)
38
51
  @port = m[2]
39
52
  @host = m[1]
40
53
  @is_tcp = true
41
54
 
42
55
  # is it a numeric port for localhost tcp?
43
- elsif /^[0-9]{1,5}$/.match(data)
56
+ when /^[0-9]{1,5}$/.match(data)
44
57
  @port = data
45
58
  @host = "localhost"
46
59
  @is_tcp = true
@@ -4,21 +4,19 @@ module Artoo
4
4
  #
5
5
  # This module contains the class-level methods used by Artoo::Robot
6
6
  class Robot
7
- module ClassMethods
8
- attr_accessor :device_types, :working_code,
9
- :use_api, :api_host, :api_port
7
+ class << self; attr_accessor :connection_types, :device_types; end
10
8
 
11
- def connection_types
12
- @@connection_types ||= []
13
- end
9
+ module ClassMethods
10
+ attr_accessor :working_code, :use_api, :api_host, :api_port
14
11
 
15
12
  # Connection to some hardware that has one or more devices via some specific protocol
16
13
  # @example connection :arduino, :adaptor => :firmata, :port => '/dev/tty.usbmodemxxxxx'
17
14
  # @param [String] name
18
15
  # @param [Hash] params
19
16
  def connection(name, params = {})
17
+ @connection_types ||= []
20
18
  Celluloid::Logger.info "Registering connection '#{name}'..."
21
- self.connection_types << {:name => name}.merge(params)
19
+ @connection_types << {:name => name}.merge(params)
22
20
  end
23
21
 
24
22
  # Device that uses a connection to communicate
@@ -26,9 +24,9 @@ module Artoo
26
24
  # @param [String] name
27
25
  # @param [Hash] params
28
26
  def device(name, params = {})
27
+ @device_types ||= []
29
28
  Celluloid::Logger.info "Registering device '#{name}'..."
30
- self.device_types ||= []
31
- self.device_types << {:name => name}.merge(params)
29
+ @device_types << {:name => name}.merge(params)
32
30
  end
33
31
 
34
32
  # The work that needs to be performed
data/lib/artoo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Artoo
2
2
  unless const_defined?('VERSION')
3
- VERSION = "1.0.0.rc3"
3
+ VERSION = "1.0.0.rc4"
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
2
 
3
3
  class ConnectionTestRobot < Artoo::Robot
4
- connection :test_connection
4
+ connection :my_test_connection, :awesomeness => :high, :super_powers => :active
5
5
  end
6
6
 
7
7
  describe Artoo::Connection do
@@ -22,7 +22,11 @@ describe Artoo::Connection do
22
22
  end
23
23
 
24
24
  it 'Artoo::Connection#as_json' do
25
- MultiJson.load(@connection.as_json, :symbolize_keys => true)[:name].must_equal "test_connection"
25
+ MultiJson.load(@connection.as_json, :symbolize_keys => true)[:name].must_equal "my_test_connection"
26
26
  MultiJson.load(@connection.as_json, :symbolize_keys => true)[:connected].must_equal false
27
27
  end
28
+
29
+ it 'Artoo::Connection#additional_params' do
30
+ @robot.default_connection.adaptor.additional_params[:awesomeness].must_equal :high
31
+ end
28
32
  end
data/test/device_test.rb CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
3
3
  class DeviceTestRobot < Artoo::Robot
4
4
  connection :test_connection
5
5
  device :test_device_1
6
- device :test_device_2
6
+ device :test_device_2, :cool_factor => 11
7
7
  end
8
8
 
9
9
  class MultipleDeviceConnectionTestRobot < Artoo::Robot
@@ -38,4 +38,9 @@ describe Artoo::Device do
38
38
  @device = @robot.devices[:test_device_1]
39
39
  MultiJson.load(@device.as_json, :symbolize_keys => true)[:name].must_equal "test_device_1"
40
40
  end
41
+
42
+ it 'Artoo::Device#additional_params' do
43
+ @device = @robot.devices[:test_device_2]
44
+ @device.driver.additional_params[:cool_factor].must_equal 11
45
+ end
41
46
  end
data/test/port_test.rb CHANGED
@@ -5,29 +5,41 @@ describe Artoo::Port do
5
5
  @remote_tcp_port = Artoo::Port.new("192.168.0.1:8080")
6
6
  @local_tcp_port = Artoo::Port.new("5678")
7
7
  @serial_port = Artoo::Port.new("/dev/tty.usb12345")
8
+ @portless = Artoo::Port.new
8
9
  end
9
10
 
10
11
  it 'Artoo::Port#port' do
11
12
  @remote_tcp_port.port.must_equal "8080"
12
13
  @local_tcp_port.port.must_equal "5678"
13
14
  @serial_port.port.must_equal "/dev/tty.usb12345"
15
+ @portless.port.must_equal "none"
14
16
  end
15
17
 
16
18
  it 'Artoo::Port#is_tcp?' do
17
19
  @remote_tcp_port.is_tcp?.must_equal true
18
20
  @local_tcp_port.is_tcp?.must_equal true
19
21
  @serial_port.is_tcp?.must_equal false
22
+ @portless.is_tcp?.must_equal false
20
23
  end
21
24
 
22
25
  it 'Artoo::Port#is_serial?' do
23
26
  @remote_tcp_port.is_serial?.must_equal false
24
27
  @local_tcp_port.is_serial?.must_equal false
25
28
  @serial_port.is_serial?.must_equal true
29
+ @portless.is_tcp?.must_equal false
30
+ end
31
+
32
+ it 'Artoo::Port#is_portless?' do
33
+ @remote_tcp_port.is_portless?.must_equal false
34
+ @local_tcp_port.is_portless?.must_equal false
35
+ @serial_port.is_portless?.must_equal false
36
+ @portless.is_portless?.must_equal true
26
37
  end
27
38
 
28
39
  it 'Artoo::Port#to_s' do
29
40
  @remote_tcp_port.to_s.must_equal "192.168.0.1:8080"
30
41
  @local_tcp_port.to_s.must_equal "localhost:5678"
31
42
  @serial_port.to_s.must_equal "/dev/tty.usb12345"
43
+ @portless.to_s.must_equal "none"
32
44
  end
33
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc3
4
+ version: 1.0.0.rc4
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: 2013-07-27 00:00:00.000000000 Z
15
+ date: 2013-08-16 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: celluloid
@@ -254,7 +254,8 @@ files:
254
254
  - test/utility_test.rb
255
255
  - test/utility_test_cases.rb
256
256
  homepage: https://github.com/hybridgroup/artoo
257
- licenses: []
257
+ licenses:
258
+ - Apache 2.0
258
259
  metadata: {}
259
260
  post_install_message:
260
261
  rdoc_options: []