artoo-crazyflie 0.1.0 → 0.2.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +15 -0
- data/examples/crazy_hop.rb +3 -3
- data/examples/crazy_hover.rb +19 -0
- data/examples/crazy_joystick.rb +18 -11
- data/examples/crazy_leapmotion.rb +12 -8
- data/lib/artoo-crazyflie/version.rb +1 -1
- data/lib/artoo/adaptors/crazyflie.rb +1 -0
- data/lib/artoo/drivers/crazyflie.rb +34 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6890ddc5ec889db00a3ed9468fec67b3a03ac599
|
4
|
+
data.tar.gz: fef07e21f062f4beccd9127c36557e6ddf1894fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5545493e93429a491b820265ded8ee2b6a07d6be120e51a1454ebaa4af6988bccdab01bb48af243fad90c9be400bf6abd98cd73af549b9075be304a91e11b35f
|
7
|
+
data.tar.gz: ebf8c585bd3eeb666170b84ee5695fc4a534e8909314f43b71dd7ebce572dd51ce34d81c3d9f639db329426396b3919b63ecc6fafc8030f6c143cb506fe1043c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -35,6 +35,21 @@ end
|
|
35
35
|
|
36
36
|
The Crazyflie uses a 2.4 GHz radio to communicate. There is a USB dongle called the Crazyradio that is required to control the Crazyflie quadcopter.
|
37
37
|
|
38
|
+
If you are have a USB 3.0 port, you might run into this issue http://stackoverflow.com/questions/17204253/crazyflie-usb-3-0-incompability
|
39
|
+
|
40
|
+
## Crazyflie Hover
|
41
|
+
|
42
|
+
To use Crazyflie with the hover command, requires installing the https://bitbucket.org/omwdunkley/crazyflie-firmware fork of the Crazyflie firmware. The easiest way to currently do this, is to install the Crazyflie PC Client, download the 'hover' branch BIN file from here https://bitbucket.org/omwdunkley/crazyflie-firmware/downloads/cflie.bin and then use the Crazyflie PC tools to update the Crazyflie firmware.
|
43
|
+
|
44
|
+
Once you have updated the Crazyflie firmware, you will NEED to use the following syntax in your Artoo code to use it:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
connection :crazyflie, :adaptor => :crazyflie, :supports_hover => true
|
48
|
+
```
|
49
|
+
|
50
|
+
If you do not add `:supports_hover => true` to your connection code to the Crazyflie, it will go crazy out of control as you as you try to connect to it. You have been warned...
|
51
|
+
|
52
|
+
|
38
53
|
## Contributing
|
39
54
|
|
40
55
|
1. Fork it
|
data/examples/crazy_hop.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'artoo'
|
2
2
|
|
3
|
-
connection :crazyflie, :adaptor => :crazyflie
|
3
|
+
connection :crazyflie, :adaptor => :crazyflie, :supports_hover => true
|
4
4
|
device :drone, :driver => :crazyflie, :connection => :crazyflie, :interval => 0.1
|
5
5
|
|
6
6
|
work do
|
7
|
-
drone.
|
8
|
-
|
7
|
+
drone.take_off
|
8
|
+
|
9
9
|
after(1.seconds) {drone.stop}
|
10
10
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'artoo'
|
2
|
+
|
3
|
+
connection :crazyflie, :adaptor => :crazyflie, :supports_hover => true
|
4
|
+
device :drone, :driver => :crazyflie, :connection => :crazyflie, :interval => 0.1
|
5
|
+
|
6
|
+
work do
|
7
|
+
drone.start
|
8
|
+
drone.take_off
|
9
|
+
|
10
|
+
after(1.5) {drone.hover(:start)}
|
11
|
+
|
12
|
+
after(3.seconds) {
|
13
|
+
drone.land
|
14
|
+
}
|
15
|
+
|
16
|
+
after(5.seconds) {
|
17
|
+
drone.stop
|
18
|
+
}
|
19
|
+
end
|
data/examples/crazy_joystick.rb
CHANGED
@@ -1,23 +1,20 @@
|
|
1
1
|
require 'artoo'
|
2
2
|
|
3
|
-
connection :crazyflie, :adaptor => :crazyflie
|
3
|
+
connection :crazyflie, :adaptor => :crazyflie, :supports_hover => true
|
4
4
|
device :drone, :driver => :crazyflie, :connection => :crazyflie, :interval => 0.01
|
5
5
|
|
6
6
|
connection :joystick, :adaptor => :joystick
|
7
|
-
device :controller, :driver => :xbox360, :connection => :joystick, :interval => 0.01
|
8
|
-
|
7
|
+
#device :controller, :driver => :xbox360, :connection => :joystick, :interval => 0.01
|
8
|
+
device :controller, :driver => :ps3, :connection => :joystick, :interval => 0.01
|
9
9
|
#device :controller, :driver => :joystick, :connection => :joystick, :interval => 0.01
|
10
10
|
|
11
11
|
work do
|
12
|
-
on controller, :joystick_0 =>
|
13
|
-
|
14
|
-
|
15
|
-
on controller, :joystick_1 => proc { |caller, data|
|
16
|
-
handle_joystick_1 data
|
17
|
-
}
|
12
|
+
on controller, :joystick_0 => :handle_joystick_0
|
13
|
+
on controller, :joystick_1 => :handle_joystick_1
|
14
|
+
on controller, :button_x => :handle_hover
|
18
15
|
end
|
19
16
|
|
20
|
-
def handle_joystick_0 data
|
17
|
+
def handle_joystick_0 caller, data
|
21
18
|
thrust_scale = 1.46
|
22
19
|
yaw_scale = 0.000191753
|
23
20
|
degrade = 700
|
@@ -41,7 +38,7 @@ def handle_joystick_0 data
|
|
41
38
|
end
|
42
39
|
end
|
43
40
|
|
44
|
-
def handle_joystick_1 data
|
41
|
+
def handle_joystick_1 caller, data
|
45
42
|
deg_scale = 0.00091
|
46
43
|
|
47
44
|
if data[:y] < 0
|
@@ -60,3 +57,13 @@ def handle_joystick_1 data
|
|
60
57
|
drone.left(0)
|
61
58
|
end
|
62
59
|
end
|
60
|
+
|
61
|
+
def handle_hover caller
|
62
|
+
if @hover
|
63
|
+
@hover = false
|
64
|
+
drone.hover(:stop)
|
65
|
+
else
|
66
|
+
@hover = true
|
67
|
+
drone.hover
|
68
|
+
end
|
69
|
+
end
|
@@ -1,19 +1,25 @@
|
|
1
1
|
require 'artoo'
|
2
2
|
|
3
|
-
connection :crazyflie, :adaptor => :crazyflie
|
4
|
-
device :drone, :driver => :crazyflie, :connection => :crazyflie
|
3
|
+
connection :crazyflie, :adaptor => :crazyflie, :supports_hover => true
|
4
|
+
device :drone, :driver => :crazyflie, :connection => :crazyflie
|
5
5
|
|
6
6
|
connection :leap, :adaptor => :leapmotion, :port => '127.0.0.1:6437'
|
7
7
|
device :leap, :connection => :leap, :driver => :leapmotion
|
8
8
|
|
9
9
|
work do
|
10
10
|
on leap, :hand => :wave
|
11
|
-
every(0.
|
11
|
+
every(0.05) do
|
12
|
+
calculate_power
|
12
13
|
handle_thrust
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
def
|
17
|
+
def wave sender, hand
|
18
|
+
return unless hand
|
19
|
+
@thrust = hand.palm_z.from_scale(100..800).to_scale(0..60000)
|
20
|
+
end
|
21
|
+
|
22
|
+
def calculate_power
|
17
23
|
@degrade = 700
|
18
24
|
@power = 0 if @power.nil?
|
19
25
|
@thrust = 0 if @thrust.nil?
|
@@ -25,10 +31,8 @@ def handle_thrust
|
|
25
31
|
else
|
26
32
|
@power = @power - @degrade
|
27
33
|
end
|
28
|
-
drone.power(@power)
|
29
34
|
end
|
30
35
|
|
31
|
-
def
|
32
|
-
|
33
|
-
@thrust = hand.palm_z.from_scale(100..800).to_scale(0..60000)
|
36
|
+
def handle_thrust
|
37
|
+
drone.power(@power)
|
34
38
|
end
|
@@ -9,7 +9,7 @@ module Artoo
|
|
9
9
|
:turn_left, :turn_right, :power].freeze
|
10
10
|
|
11
11
|
|
12
|
-
attr_reader :roll, :pitch, :yaw, :thrust, :xmode
|
12
|
+
attr_reader :roll, :pitch, :yaw, :thrust, :xmode, :hover_mode
|
13
13
|
|
14
14
|
def initialize(params={})
|
15
15
|
@roll = 0
|
@@ -17,6 +17,7 @@ module Artoo
|
|
17
17
|
@yaw = 0
|
18
18
|
@thrust = 0
|
19
19
|
@xmode = false # TODO what is this?
|
20
|
+
@hover_mode = 0
|
20
21
|
super
|
21
22
|
end
|
22
23
|
|
@@ -36,24 +37,43 @@ module Artoo
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def start
|
40
|
+
@hover_mode = 0
|
39
41
|
@roll = 0
|
40
42
|
@pitch = 0
|
41
43
|
@yaw = 0
|
42
|
-
|
44
|
+
power(10001)
|
43
45
|
end
|
44
46
|
|
45
47
|
def stop
|
46
48
|
set_thrust_off
|
47
49
|
end
|
48
50
|
|
49
|
-
def hover
|
50
|
-
|
51
|
+
def hover(h=:start)
|
52
|
+
if h == :start
|
53
|
+
@hover_mode = 1
|
54
|
+
set_thrust_hover
|
55
|
+
else
|
56
|
+
@hover_mode = 0
|
57
|
+
set_thrust_off
|
58
|
+
end
|
51
59
|
end
|
52
60
|
|
53
|
-
def land
|
61
|
+
def land(secs=1)
|
62
|
+
@hover_mode = 0
|
63
|
+
power(32000)
|
64
|
+
|
65
|
+
after(secs) {
|
66
|
+
power(22000)
|
67
|
+
}
|
54
68
|
end
|
55
69
|
|
56
|
-
def take_off
|
70
|
+
def take_off(secs=1)
|
71
|
+
forward(0)
|
72
|
+
set_thrust_on
|
73
|
+
|
74
|
+
after(secs) {
|
75
|
+
power(33000)
|
76
|
+
}
|
57
77
|
end
|
58
78
|
|
59
79
|
def power(deg)
|
@@ -85,17 +105,22 @@ module Artoo
|
|
85
105
|
end
|
86
106
|
|
87
107
|
def set_thrust_on
|
88
|
-
|
108
|
+
power(40000)
|
89
109
|
end
|
90
110
|
|
91
111
|
def set_thrust_off
|
92
|
-
|
112
|
+
power(0)
|
113
|
+
end
|
114
|
+
|
115
|
+
def set_thrust_hover
|
116
|
+
power(32597)
|
93
117
|
end
|
94
118
|
|
95
119
|
private
|
96
120
|
|
97
121
|
def send_command
|
98
|
-
|
122
|
+
set_thrust_hover if hover_mode == 1
|
123
|
+
connection.commander.send_setpoint(roll, pitch, yaw, thrust, xmode, hover_mode)
|
99
124
|
end
|
100
125
|
end
|
101
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artoo-crazyflie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Zankich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: artoo
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- Rakefile
|
96
96
|
- artoo-crazyflie.gemspec
|
97
97
|
- examples/crazy_hop.rb
|
98
|
+
- examples/crazy_hover.rb
|
98
99
|
- examples/crazy_joystick.rb
|
99
100
|
- examples/crazy_leapmotion.rb
|
100
101
|
- lib/artoo-crazyflie.rb
|