crubyflie 0.1.0 → 0.1.1
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 +4 -4
- data/.travis.yml +8 -0
- data/README.md +4 -2
- data/crubyflie.gemspec +1 -0
- data/lib/crubyflie/crazyflie/log.rb +1 -1
- data/lib/crubyflie/driver/radio_driver.rb +38 -8
- data/lib/crubyflie/exceptions.rb +1 -1
- data/lib/crubyflie/input/joystick_input_reader.rb +2 -2
- data/lib/crubyflie/version.rb +1 -1
- data/spec/crazyflie_spec.rb +1 -1
- data/spec/crazyradio_spec.rb +6 -4
- data/spec/crubyflie_spec.rb +2 -1
- data/spec/spec_helper.rb +2 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c53014aa0e2af1f0f401853e934227e5f2950f38
|
4
|
+
data.tar.gz: 6729d96811026479a1a0984aa1316506be35af75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81452b7995d89199f233b55c132bded7b8790875754d020ada0831bef8cf9b100b4aa439c4ae340b197e8a3a3add072d9ee9cfb19ffbabc8d278b7bb35641cfe
|
7
|
+
data.tar.gz: a4ca9a64c904644c1dd756c77a9f47875da126cc1ea72844b2a5a191ec2d849481645c33e64f733054df54425c04e1faeb3fe6dbd84f0d361f6e4f90fb7ca01f
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
Crubyflie - A Ruby client
|
2
|
-
|
1
|
+
Crubyflie - A Ruby client for Crazyflie
|
2
|
+
=======================================
|
3
|
+
|
4
|
+
[](https://travis-ci.org/hsanjuan/crubyflie) [](https://coveralls.io/r/hsanjuan/crubyflie)
|
3
5
|
|
4
6
|
Crubyflie is a Ruby rewrite of the [Crazyflie quadcopter](http://www.bitcraze.se/category/crazyflie/) Python [client libraries](https://bitbucket.org/bitcraze/crazyflie-pc-client), with some customizations.
|
5
7
|
|
data/crubyflie.gemspec
CHANGED
@@ -18,13 +18,43 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
require 'thread'
|
21
|
-
require 'uri'
|
22
21
|
|
23
22
|
require 'exceptions'
|
24
23
|
require 'driver/crtp_packet'
|
25
24
|
require 'crazyradio/crazyradio'
|
26
25
|
|
26
|
+
|
27
|
+
|
27
28
|
module Crubyflie
|
29
|
+
# Small URI class since Ruby URI < 1.9.3 gives problems parsing
|
30
|
+
# Crazyflie URIs
|
31
|
+
class CrubyflieURI
|
32
|
+
attr_reader :scheme, :dongle, :channel, :rate
|
33
|
+
# Initialize an URI
|
34
|
+
# @param uri_str [String] the URI
|
35
|
+
def initialize(uri_str)
|
36
|
+
@uri_str = uri_str
|
37
|
+
@scheme, @dongle, @channel, @rate = split()
|
38
|
+
if @scheme.nil? || @dongle.nil? || @channel.nil? || @rate.nil? ||
|
39
|
+
@scheme != 'radio'
|
40
|
+
raise InvalidURIException.new('Bad URI')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Return URI as string
|
45
|
+
# @return [String] a string representation of the URI
|
46
|
+
def to_s
|
47
|
+
@uri_str
|
48
|
+
end
|
49
|
+
|
50
|
+
# Quick, dirty uri split
|
51
|
+
def split
|
52
|
+
@uri_str.sub(':', '').sub('//','/').split('/')
|
53
|
+
end
|
54
|
+
private :split
|
55
|
+
end
|
56
|
+
|
57
|
+
|
28
58
|
# This layer takes care of connecting to the crazyradio and
|
29
59
|
# managing the incoming and outgoing queues. This is done
|
30
60
|
# by spawing a thread.
|
@@ -64,7 +94,7 @@ module Crubyflie
|
|
64
94
|
# :out_queue_max_size (defaults to 50)
|
65
95
|
# @raise [CallbackMissing] when a necessary callback is not provided
|
66
96
|
# (see CALLBACKS constant values)
|
67
|
-
# @raise [
|
97
|
+
# @raise [InvalidURIException] when the URI is not a valid radio URI
|
68
98
|
# @raise [OpenLink] when a link is already open
|
69
99
|
def connect(uri_s, callbacks={}, opts={})
|
70
100
|
# Check if apparently there is an open link
|
@@ -76,12 +106,12 @@ module Crubyflie
|
|
76
106
|
|
77
107
|
# Parse URI to initialize Crazyradio
|
78
108
|
# @todo: better control input. It defaults to 0
|
79
|
-
@uri =
|
80
|
-
dongle_number = @uri.
|
81
|
-
channel
|
82
|
-
|
83
|
-
# @todo this should be taken care of in crazyradio
|
109
|
+
@uri = CrubyflieURI.new(uri_s)
|
110
|
+
dongle_number = @uri.dongle.to_i
|
111
|
+
channel = @uri.channel.to_i
|
112
|
+
rate = @uri.rate
|
84
113
|
|
114
|
+
# @todo this should be taken care of in crazyradio
|
85
115
|
case rate
|
86
116
|
when "250K"
|
87
117
|
rate = CrazyradioConstants::DR_250KPS
|
@@ -90,7 +120,7 @@ module Crubyflie
|
|
90
120
|
when "2M"
|
91
121
|
rate = CrazyradioConstants::DR_2MPS
|
92
122
|
else
|
93
|
-
raise
|
123
|
+
raise InvalidURIException.new("Bad radio rate")
|
94
124
|
end
|
95
125
|
|
96
126
|
# Fill in the callbacks Hash
|
data/lib/crubyflie/exceptions.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
module Crubyflie
|
20
20
|
# Raised when the radio URI is invalid
|
21
|
-
class
|
21
|
+
class InvalidURIException < Exception; end
|
22
22
|
# Raised when an radio link is already open
|
23
23
|
class OpenLink < Exception; end
|
24
24
|
# Raised when a radio driver callback parameter is missing
|
@@ -268,8 +268,8 @@ module Crubyflie
|
|
268
268
|
# @return [Float] the linear-corresponding value in the destination
|
269
269
|
# range
|
270
270
|
def normalize(value, from_range, to_range)
|
271
|
-
from_w = from_range.size.to_f - 1
|
272
|
-
to_w = to_range.size.to_f - 1
|
271
|
+
from_w = from_range.to_a.size.to_f - 1
|
272
|
+
to_w = to_range.to_a.size.to_f - 1
|
273
273
|
from_min = from_range.first.to_f
|
274
274
|
to_min = to_range.first.to_f
|
275
275
|
# puts "#{to_min}+(#{value.to_f}-#{from_min})*(#{to_w}/#{from_w})
|
data/lib/crubyflie/version.rb
CHANGED
data/spec/crazyflie_spec.rb
CHANGED
@@ -38,7 +38,7 @@ describe Crazyflie do
|
|
38
38
|
allow(@link).to receive(:connect)
|
39
39
|
allow(@link).to receive(:disconnect)
|
40
40
|
allow(@link).to receive(:receive_packet)
|
41
|
-
allow(@link).to receive(:uri).and_return(
|
41
|
+
allow(@link).to receive(:uri).and_return(CrubyflieURI.new(@uri))
|
42
42
|
|
43
43
|
#allow_any_instance_of(CrubyflieLogger).to receive(:info)
|
44
44
|
|
data/spec/crazyradio_spec.rb
CHANGED
@@ -106,16 +106,18 @@ describe Crazyradio do
|
|
106
106
|
|
107
107
|
describe "#factory" do
|
108
108
|
it "should raise an exception if no dongles are found" do
|
109
|
-
|
110
|
-
|
109
|
+
context = double("Context")
|
110
|
+
expect(LIBUSB::Context).to receive(:new).and_return(context)
|
111
|
+
expect(context).to receive(:devices).and_return([])
|
111
112
|
|
112
113
|
expect { Crazyradio.factory() }.to raise_error(USBDongleException,
|
113
114
|
"No dongles found")
|
114
115
|
end
|
115
116
|
|
116
117
|
it "should provide a new crazyradio item" do
|
117
|
-
|
118
|
-
|
118
|
+
context = double("Context")
|
119
|
+
expect(LIBUSB::Context).to receive(:new).and_return(context)
|
120
|
+
expect(context).to receive(:devices).and_return([@device])
|
119
121
|
Crazyradio.factory()
|
120
122
|
end
|
121
123
|
end
|
data/spec/crubyflie_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -17,6 +17,8 @@
|
|
17
17
|
# along with Crubyflie. If not, see <http://www.gnu.org/licenses/>
|
18
18
|
|
19
19
|
require 'simplecov'
|
20
|
+
require 'coveralls'
|
21
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
20
22
|
SimpleCov.at_exit do
|
21
23
|
SimpleCov.minimum_coverage 95
|
22
24
|
SimpleCov.result.format!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crubyflie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hector Sanjuan
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: coveralls
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: |
|
126
140
|
Client library to control a Crazyflie. This library allows to talk to a
|
127
141
|
crazyflie using the USB radio dongle.
|
@@ -133,6 +147,7 @@ extensions: []
|
|
133
147
|
extra_rdoc_files: []
|
134
148
|
files:
|
135
149
|
- .gitignore
|
150
|
+
- .travis.yml
|
136
151
|
- Gemfile
|
137
152
|
- LICENSE.txt
|
138
153
|
- README.md
|