artoo 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/.yardopts +10 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +10 -7
- data/README.md +2 -2
- data/api/assets/javascripts/artoo/controllers/robot.js.coffee +2 -1
- data/api/public/core.js +3 -1
- data/artoo.gemspec +0 -1
- data/lib/artoo/adaptors/adaptor.rb +27 -6
- data/lib/artoo/adaptors/ardrone.rb +10 -2
- data/lib/artoo/adaptors/ardrone_navigation.rb +9 -2
- data/lib/artoo/adaptors/ardrone_video.rb +13 -5
- data/lib/artoo/adaptors/firmata.rb +10 -2
- data/lib/artoo/adaptors/loopback.rb +2 -1
- data/lib/artoo/adaptors/roomba.rb +12 -4
- data/lib/artoo/adaptors/sphero.rb +15 -3
- data/lib/artoo/api.rb +48 -5
- data/lib/artoo/api_route_helpers.rb +22 -3
- data/lib/artoo/basic.rb +3 -7
- data/lib/artoo/connection.rb +25 -7
- data/lib/artoo/delegator.rb +6 -16
- data/lib/artoo/device.rb +39 -10
- data/lib/artoo/device_event_client.rb +6 -0
- data/lib/artoo/drivers/ardrone.rb +5 -1
- data/lib/artoo/drivers/ardrone_navigation.rb +5 -1
- data/lib/artoo/drivers/ardrone_video.rb +9 -4
- data/lib/artoo/drivers/button.rb +7 -1
- data/lib/artoo/drivers/driver.rb +44 -4
- data/lib/artoo/drivers/led.rb +12 -1
- data/lib/artoo/drivers/motor.rb +12 -1
- data/lib/artoo/drivers/pinger.rb +10 -1
- data/lib/artoo/drivers/pinger2.rb +10 -1
- data/lib/artoo/drivers/roomba.rb +65 -17
- data/lib/artoo/drivers/servo.rb +12 -2
- data/lib/artoo/drivers/sphero.rb +19 -5
- data/lib/artoo/drivers/wiichuck.rb +7 -1
- data/lib/artoo/drivers/wiiclassic.rb +14 -5
- data/lib/artoo/drivers/wiidriver.rb +4 -1
- data/lib/artoo/events.rb +11 -4
- data/lib/artoo/ext/actor.rb +1 -1
- data/lib/artoo/ext/timers.rb +1 -1
- data/lib/artoo/main.rb +2 -13
- data/lib/artoo/master.rb +20 -2
- data/lib/artoo/port.rb +8 -3
- data/lib/artoo/robot.rb +45 -17
- data/lib/artoo/utility.rb +53 -9
- data/lib/artoo/version.rb +1 -1
- data/test/drivers/driver_test.rb +15 -0
- data/test/drivers/led_test.rb +4 -0
- data/test/utility_test.rb +35 -18
- data/test/utility_test_cases.rb +56 -0
- metadata +5 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cca65df971ac15acb591d811d8664703046390a6
|
4
|
+
data.tar.gz: 78ce7b30d92c1ec9b111cfe23550e5067a8ea525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34a0ecc46495423973c52b345acb4fe7d99984c06bfc0b10b6741a35f4615caa4e89d5225b7119d3db504209e57a36245810f5052e61a5d21e9fe48cf5b00195
|
7
|
+
data.tar.gz: e2f70290fd6c9d2162a3bed8430f5741399f557c3c4b372c232313052da006e6e526f08c359afa80bf9a6d6a2e044e58967cbc6f81a54de519b8a46c3c5f0a7b
|
data/.travis.yml
CHANGED
data/.yardopts
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
artoo (0.4.
|
5
|
-
active_support (~> 3.0)
|
4
|
+
artoo (0.4.1)
|
6
5
|
celluloid (~> 0.14.0)
|
7
6
|
celluloid-io (~> 0.14.0)
|
8
7
|
multi_json (~> 1.6)
|
@@ -13,9 +12,6 @@ PATH
|
|
13
12
|
GEM
|
14
13
|
remote: http://rubygems.org/
|
15
14
|
specs:
|
16
|
-
active_support (3.0.0)
|
17
|
-
activesupport (= 3.0.0)
|
18
|
-
activesupport (3.0.0)
|
19
15
|
bootstrap-sass (2.2.2.0)
|
20
16
|
sass (~> 3.2)
|
21
17
|
celluloid (0.14.0)
|
@@ -90,6 +86,7 @@ GEM
|
|
90
86
|
spoon (~> 0.0)
|
91
87
|
rack (1.5.2)
|
92
88
|
rake (10.0.4)
|
89
|
+
redcarpet (2.2.2)
|
93
90
|
reel (0.4.0.pre)
|
94
91
|
celluloid-io (>= 0.8.0)
|
95
92
|
http (>= 0.2.0)
|
@@ -110,6 +107,9 @@ GEM
|
|
110
107
|
timers (1.1.0)
|
111
108
|
websocket_parser (0.1.2)
|
112
109
|
http
|
110
|
+
yard (0.8.6.1)
|
111
|
+
yard-sinatra (1.0.0)
|
112
|
+
yard (~> 0.7)
|
113
113
|
|
114
114
|
PLATFORMS
|
115
115
|
java
|
@@ -127,7 +127,10 @@ DEPENDENCIES
|
|
127
127
|
hybridgroup-argus
|
128
128
|
hybridgroup-firmata
|
129
129
|
hybridgroup-sphero
|
130
|
-
minitest
|
131
|
-
mocha
|
130
|
+
minitest
|
131
|
+
mocha
|
132
|
+
redcarpet
|
132
133
|
sass
|
133
134
|
sprockets
|
135
|
+
yard
|
136
|
+
yard-sinatra
|
data/README.md
CHANGED
@@ -100,9 +100,9 @@ end
|
|
100
100
|
|
101
101
|
Once the robot or group is working, you can view the main API page at the host and port specified.
|
102
102
|
|
103
|
-
##
|
103
|
+
## Console:
|
104
104
|
|
105
|
-
Artoo includes Robi, a
|
105
|
+
Artoo includes Robi, a console based on Pry (http://pryrepl.org/) to allow you to interactively debug and control your robot.
|
106
106
|
|
107
107
|
```
|
108
108
|
robi ./examples/hello.rb
|
@@ -20,7 +20,8 @@ window.driversWithOutput = ["Pinger", "Pinger2", "ardrone_navigation", "wiiclass
|
|
20
20
|
|
21
21
|
device = console: ->
|
22
22
|
window.ws.close() if window.ws
|
23
|
-
|
23
|
+
wspath = "ws://" + location.host + "/robots/"
|
24
|
+
window.ws = new WebSocket(wspath + $scope.robot.name + "/devices/" + $scope.deviceDetail.name + "/events")
|
24
25
|
$(".console code").empty()
|
25
26
|
ws.onmessage = (evt)->
|
26
27
|
$(".console code").prepend(evt.data + "\n")
|
data/api/public/core.js
CHANGED
@@ -241,10 +241,12 @@ ngChange:rd,required:dc,ngRequired:dc,ngValue:ud}).directive(lb).directive(ec);a
|
|
241
241
|
};
|
242
242
|
device = {
|
243
243
|
console: function() {
|
244
|
+
var wspath;
|
244
245
|
if (window.ws) {
|
245
246
|
window.ws.close();
|
246
247
|
}
|
247
|
-
|
248
|
+
wspath = "ws://" + location.host + "/robots/";
|
249
|
+
window.ws = new WebSocket(wspath + $scope.robot.name + "/devices/" + $scope.deviceDetail.name + "/events");
|
248
250
|
$(".console code").empty();
|
249
251
|
return ws.onmessage = function(evt) {
|
250
252
|
return $(".console code").prepend(evt.data + "\n");
|
data/artoo.gemspec
CHANGED
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_runtime_dependency 'celluloid-io', '~> 0.14.0'
|
24
24
|
s.add_runtime_dependency 'reel', '~> 0.4.pre'
|
25
25
|
s.add_runtime_dependency 'multi_json', '~> 1.6'
|
26
|
-
s.add_runtime_dependency 'active_support', '~> 3.0'
|
27
26
|
s.add_runtime_dependency 'rake', '~> 10.0'
|
28
27
|
s.add_runtime_dependency 'pry', '~> 0.9'
|
29
28
|
s.add_development_dependency 'minitest', '~> 4.6'
|
@@ -1,39 +1,53 @@
|
|
1
1
|
module Artoo
|
2
2
|
module Adaptors
|
3
|
-
# The Adaptor class is the base class used to
|
4
|
-
#
|
5
|
-
# would be an Arduino, a Sphero, or an ARDrone.
|
3
|
+
# The Adaptor class is the base class used to connect to a specific group
|
4
|
+
# of hardware devices. Examples would be an Arduino, a Sphero, or an ARDrone.
|
6
5
|
#
|
7
6
|
# Derive a class from this class, in order to implement communication
|
8
7
|
# with a new type of hardware device.
|
8
|
+
# @see https://github.com/celluloid/celluloid-io Celluloid::IO Documentation
|
9
9
|
class Adaptor
|
10
10
|
include Celluloid::IO
|
11
11
|
|
12
12
|
attr_reader :parent, :port
|
13
13
|
|
14
|
+
# Initialize an adaptor
|
15
|
+
# @param params [hash]
|
16
|
+
# @option params [String] :parent
|
17
|
+
# @option params [String] :port
|
14
18
|
def initialize(params={})
|
15
19
|
@parent = params[:parent]
|
16
20
|
@port = params[:port]
|
17
21
|
@connected = false
|
18
22
|
end
|
19
23
|
|
24
|
+
# Makes connected flag true
|
25
|
+
# @return [Boolean]
|
20
26
|
def connect
|
21
27
|
@connected = true
|
22
28
|
end
|
23
29
|
|
30
|
+
# Makes connected flag false
|
31
|
+
# @return [Boolean]
|
24
32
|
def disconnect
|
25
33
|
@connected = false
|
26
34
|
true
|
27
35
|
end
|
28
36
|
|
37
|
+
# Makes connected flag true
|
38
|
+
# @return [Boolean] true unless connected
|
29
39
|
def reconnect
|
30
40
|
connect unless connected?
|
31
41
|
end
|
32
42
|
|
43
|
+
# @return [Boolean] connected flag status
|
33
44
|
def connected?
|
34
45
|
@connected == true
|
35
46
|
end
|
36
47
|
|
48
|
+
# Connects to configured port
|
49
|
+
# @return [TCPSocket] tcp socket of tcp port
|
50
|
+
# @return [String] port configured
|
37
51
|
def connect_to
|
38
52
|
if port.is_tcp?
|
39
53
|
connect_to_tcp
|
@@ -42,15 +56,22 @@ module Artoo
|
|
42
56
|
end
|
43
57
|
end
|
44
58
|
|
59
|
+
# @return [TCPSocket] TCP socket connection
|
45
60
|
def connect_to_tcp
|
46
61
|
@socket ||= TCPSocket.new(port.host, port.port)
|
47
62
|
end
|
48
|
-
|
63
|
+
# @return [UDPSocket] UDP socket connection
|
49
64
|
def connect_to_udp
|
50
65
|
@udp_socket ||= UDPSocket.new
|
51
66
|
end
|
52
67
|
|
53
|
-
|
68
|
+
# Creates serial connection
|
69
|
+
# @param speed [int]
|
70
|
+
# @param data_bits [int]
|
71
|
+
# @param stop_bits [int]
|
72
|
+
# @param parity
|
73
|
+
# @return [SerialPort] new connection
|
74
|
+
def connect_to_serial(speed=57600, data_bits=8, stop_bits=1, parity=::SerialPort::NONE)
|
54
75
|
require 'serialport'
|
55
76
|
parity = ::SerialPort::NONE unless parity
|
56
77
|
@sp = ::SerialPort.new(port.port, speed, data_bits, stop_bits, parity)
|
@@ -59,4 +80,4 @@ module Artoo
|
|
59
80
|
end
|
60
81
|
end
|
61
82
|
end
|
62
|
-
end
|
83
|
+
end
|
@@ -2,11 +2,13 @@ require 'artoo/adaptors/adaptor'
|
|
2
2
|
|
3
3
|
module Artoo
|
4
4
|
module Adaptors
|
5
|
-
#
|
5
|
+
# This class connects to a ARDrone 2.0
|
6
|
+
# @see http://rubydoc.info/gems/hybridgroup-argus/0.2.0/Argus/Drone Argus Drone Documentation
|
6
7
|
class Ardrone < Adaptor
|
7
8
|
finalizer :finalize
|
8
9
|
attr_reader :ardrone
|
9
10
|
|
11
|
+
# Finalizes connection with ARDrone by landing and stopping the device
|
10
12
|
def finalize
|
11
13
|
if connected?
|
12
14
|
ardrone.land
|
@@ -14,20 +16,26 @@ module Artoo
|
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
19
|
+
# Creates Argus Drone connection with device
|
20
|
+
# @return [Boolean]
|
17
21
|
def connect
|
18
22
|
require 'argus' unless defined?(::Argus)
|
19
23
|
@ardrone = Argus::Drone.new(connect_to_udp, port.host, port.port)
|
20
24
|
super
|
21
25
|
end
|
22
26
|
|
27
|
+
# Disconnects device by stopping it and ending connection
|
28
|
+
# @return [Boolean]
|
23
29
|
def disconnect
|
24
30
|
ardrone.stop
|
25
31
|
super
|
26
32
|
end
|
27
33
|
|
34
|
+
# Calls ardrone actions using method missing
|
35
|
+
# @see https://github.com/hybridgroup/argus/blob/master/lib/argus/drone.rb hybridgroup-argus Drone
|
28
36
|
def method_missing(method_name, *arguments, &block)
|
29
37
|
ardrone.send(method_name, *arguments, &block)
|
30
38
|
end
|
31
39
|
end
|
32
40
|
end
|
33
|
-
end
|
41
|
+
end
|
@@ -2,10 +2,13 @@ require 'artoo/adaptors/adaptor'
|
|
2
2
|
|
3
3
|
module Artoo
|
4
4
|
module Adaptors
|
5
|
-
# Connect to a ARDrone 2.0
|
5
|
+
# Connect to a ARDrone 2.0 navigation data stream
|
6
|
+
# @see http://rubydoc.info/gems/hybridgroup-argus/0.2.0/Argus/NavStreamer Argus NavStremer Documentation
|
6
7
|
class ArdroneNavigation < Adaptor
|
7
8
|
attr_reader :ardrone
|
8
9
|
|
10
|
+
# Creates connection with Argus NavStreamer and starts ardrone device
|
11
|
+
# @return [Boolean]
|
9
12
|
def connect
|
10
13
|
require 'argus' unless defined?(::Argus)
|
11
14
|
@ardrone = Argus::NavStreamer.new(connect_to_udp, port.host, port.port.to_i)
|
@@ -13,14 +16,18 @@ module Artoo
|
|
13
16
|
super
|
14
17
|
end
|
15
18
|
|
19
|
+
# Closes connection with ardrone device
|
20
|
+
# @return [Boolean]
|
16
21
|
def disconnect
|
17
22
|
ardrone.close
|
18
23
|
super
|
19
24
|
end
|
20
25
|
|
26
|
+
# Calls ardrone actions using method missing
|
27
|
+
# @see http://rubydoc.info/gems/hybridgroup-argus/0.2.0/Argus/Drone Argus Drone Documentation
|
21
28
|
def method_missing(method_name, *arguments, &block)
|
22
29
|
ardrone.send(method_name, *arguments, &block)
|
23
30
|
end
|
24
31
|
end
|
25
32
|
end
|
26
|
-
end
|
33
|
+
end
|
@@ -2,26 +2,34 @@ require 'artoo/adaptors/adaptor'
|
|
2
2
|
|
3
3
|
module Artoo
|
4
4
|
module Adaptors
|
5
|
-
# Connect to a ARDrone 2.0
|
5
|
+
# Connect to a ARDrone 2.0 video data stream
|
6
|
+
# @see http://rubydoc.info/gems/hybridgroup-argus/0.2.0/Argus/TcpVideoStreamer TCP Video Streamer Documentation
|
7
|
+
# @see http://rubydoc.info/gems/hybridgroup-argus/0.2.0/Argus/PaVEParser PaVEParser Documentation
|
6
8
|
class ArdroneVideo < Adaptor
|
7
9
|
attr_reader :ardrone, :video_parser
|
8
10
|
|
11
|
+
# Creates connection to Argus TCP Video Streamer and
|
12
|
+
# Argus PaVE Parser starting a stream with ardrone device
|
13
|
+
# @return [Boolean]
|
9
14
|
def connect
|
10
15
|
require 'argus' unless defined?(::Argus)
|
11
|
-
@ardrone = Argus::
|
12
|
-
@
|
13
|
-
@ardrone.start_stream(connect_to_udp)
|
16
|
+
@ardrone = Argus::VideoStreamer.new(connect_to_tcp, port.host, port.port)
|
17
|
+
@ardrone.start(connect_to_udp)
|
14
18
|
super
|
15
19
|
end
|
16
20
|
|
21
|
+
# Closes ardrone connection
|
22
|
+
# @return [Boolean]
|
17
23
|
def disconnect
|
18
24
|
ardrone.close
|
19
25
|
super
|
20
26
|
end
|
21
27
|
|
28
|
+
# Calls ardrone actions using method missing
|
29
|
+
# @see https://github.com/hybridgroup/argus/blob/master/lib/argus/drone.rb hybridgroup-argus Drone
|
22
30
|
def method_missing(method_name, *arguments, &block)
|
23
31
|
ardrone.send(method_name, *arguments, &block)
|
24
32
|
end
|
25
33
|
end
|
26
34
|
end
|
27
|
-
end
|
35
|
+
end
|
@@ -2,9 +2,13 @@ require 'artoo/adaptors/adaptor'
|
|
2
2
|
|
3
3
|
module Artoo
|
4
4
|
module Adaptors
|
5
|
+
# Connect to Arduino using Firmata
|
6
|
+
# @see http://rubydoc.info/gems/hybridgroup-firmata/0.3.0/Firmata/Board HybridGroup Firmata Documentation
|
5
7
|
class Firmata < Adaptor
|
6
8
|
attr_reader :firmata
|
7
9
|
|
10
|
+
# Creates connection with firmata board
|
11
|
+
# @return [Boolean]
|
8
12
|
def connect
|
9
13
|
require 'firmata' unless defined?(::Firmata)
|
10
14
|
@firmata = ::Firmata::Board.new(connect_to)
|
@@ -13,13 +17,17 @@ module Artoo
|
|
13
17
|
return true
|
14
18
|
end
|
15
19
|
|
20
|
+
# Closes connection with firmata board
|
21
|
+
# @return [Boolean]
|
16
22
|
def disconnect
|
17
23
|
super
|
18
|
-
end
|
24
|
+
end
|
19
25
|
|
26
|
+
# Uses method missing to call Firmata Board methods
|
27
|
+
# @see http://rubydoc.info/gems/hybridgroup-firmata/0.3.0/Firmata/Board Firmata Board Documentation
|
20
28
|
def method_missing(method_name, *arguments, &block)
|
21
29
|
firmata.send(method_name, *arguments, &block)
|
22
30
|
end
|
23
|
-
|
31
|
+
end
|
24
32
|
end
|
25
33
|
end
|
@@ -2,17 +2,22 @@ require 'artoo/adaptors/adaptor'
|
|
2
2
|
|
3
3
|
module Artoo
|
4
4
|
module Adaptors
|
5
|
-
# Connect to a Roomba
|
5
|
+
# Connect to a Roomba
|
6
|
+
# @see http://www.irobot.com/en/us/robots/Educators/Create.aspx Roomba information
|
6
7
|
class Roomba < Adaptor
|
7
8
|
finalizer :finalize
|
8
9
|
attr_reader :sp
|
9
10
|
|
11
|
+
# Closes connection if already connected
|
12
|
+
# @return [Boolean]
|
10
13
|
def finalize
|
11
14
|
if connected?
|
12
15
|
@sp.close
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
19
|
+
# Creates serial or tcp connection
|
20
|
+
# @return [Boolean]
|
16
21
|
def connect
|
17
22
|
if port.is_serial?
|
18
23
|
@sp = connect_to_serial
|
@@ -23,7 +28,8 @@ module Artoo
|
|
23
28
|
end
|
24
29
|
super
|
25
30
|
end
|
26
|
-
|
31
|
+
|
32
|
+
# Send bytes to device
|
27
33
|
def send_bytes(bytes)
|
28
34
|
bytes = [bytes] unless bytes.respond_to?(:map)
|
29
35
|
bytes.map!(&:chr)
|
@@ -33,11 +39,13 @@ module Artoo
|
|
33
39
|
Logger.debug "returned: #{res.inspect}"
|
34
40
|
end
|
35
41
|
|
42
|
+
# Closes connection to device
|
43
|
+
# @return [Boolean]
|
36
44
|
def disconnect
|
37
45
|
@sp.close
|
38
46
|
super
|
39
47
|
end
|
40
|
-
|
48
|
+
|
41
49
|
end
|
42
50
|
end
|
43
|
-
end
|
51
|
+
end
|
@@ -2,18 +2,26 @@ require 'artoo/adaptors/adaptor'
|
|
2
2
|
|
3
3
|
module Artoo
|
4
4
|
module Adaptors
|
5
|
-
# Connect to a Sphero
|
5
|
+
# Connect to a Sphero device
|
6
|
+
# @see http://gosphero.com Sphero information
|
7
|
+
# @see http://rubydoc.info/gems/hybridgroup-sphero HybridGroup Sphero Documentation
|
6
8
|
class Sphero < Adaptor
|
7
9
|
finalizer :finalize
|
8
|
-
RETRY_COUNT = 5
|
9
10
|
attr_reader :sphero
|
10
11
|
|
12
|
+
# Number of retries when connecting
|
13
|
+
RETRY_COUNT = 5
|
14
|
+
|
15
|
+
# Closes connection with device if connected
|
16
|
+
# @return [Boolean]
|
11
17
|
def finalize
|
12
18
|
if connected?
|
13
19
|
sphero.close
|
14
20
|
end
|
15
21
|
end
|
16
22
|
|
23
|
+
# Creates a connection with Sphero object with retries
|
24
|
+
# @return [Boolean]
|
17
25
|
def connect
|
18
26
|
@retries_left = RETRY_COUNT
|
19
27
|
require 'sphero' unless defined?(::Sphero)
|
@@ -33,14 +41,18 @@ module Artoo
|
|
33
41
|
end
|
34
42
|
end
|
35
43
|
|
44
|
+
# Closes connection with device
|
45
|
+
# @return [Boolean]
|
36
46
|
def disconnect
|
37
47
|
sphero.close
|
38
48
|
super
|
39
49
|
end
|
40
50
|
|
51
|
+
# Uses method missing to call sphero actions
|
52
|
+
# @see http://rubydoc.info/gems/hybridgroup-sphero/Sphero Sphero documentation
|
41
53
|
def method_missing(method_name, *arguments, &block)
|
42
54
|
sphero.send(method_name, *arguments, &block)
|
43
55
|
end
|
44
56
|
end
|
45
57
|
end
|
46
|
-
end
|
58
|
+
end
|