class Argus::Controller

Constants

REF_BASE
REF_EMERGENCY_BIT
REF_FLY_BIT

Public Class Methods

new(at_commander) click to toggle source
   # File lib/argus/controller.rb
 8 def initialize(at_commander)
 9   @at_commander = at_commander
10 
11   @emergency = false
12   land
13   hover
14 end

Public Instance Methods

ack_control_mode() click to toggle source
    # File lib/argus/controller.rb
130 def ack_control_mode
131   @at_commander.ctrl(ArdroneControlModes::ACK_CONTROL_MODE)
132   self
133 end
backward(amount) click to toggle source
   # File lib/argus/controller.rb
48 def backward(amount)
49   @moving = true
50   @pitch = amount
51   update_pcmd
52 end
bottom_camera() click to toggle source
    # File lib/argus/controller.rb
121 def bottom_camera
122   config("video:video_channel", "1")
123 end
config(key, value) click to toggle source
    # File lib/argus/controller.rb
108 def config(key, value)
109   @at_commander.config(key, value)
110   self
111 end
demo_mode() click to toggle source
    # File lib/argus/controller.rb
113 def demo_mode
114   config("general:navdata_demo", "TRUE")
115 end
down(amount) click to toggle source
   # File lib/argus/controller.rb
72 def down(amount)
73   @moving = true
74   @gaz = -amount
75   update_pcmd
76 end
emergency() click to toggle source
   # File lib/argus/controller.rb
27 def emergency
28   @flying = false
29   @emergency = true
30   update_ref
31 end
enable_detection(colors, type=10, select=32) click to toggle source
    # File lib/argus/controller.rb
101 def enable_detection(colors, type=10, select=32)
102   config("detect:enemy_colors",colors.to_s)
103   config("detect:detect_type", type.to_s)
104   config("detect:detections_select_h", select.to_s)
105   self
106 end
forward(amount) click to toggle source
   # File lib/argus/controller.rb
42 def forward(amount)
43   @moving = true
44   @pitch = -amount
45   update_pcmd
46 end
front_camera() click to toggle source
    # File lib/argus/controller.rb
117 def front_camera
118   config("video:video_channel", "2")
119 end
hover() click to toggle source
   # File lib/argus/controller.rb
33 def hover
34   @moving = false
35   @roll = 0.0
36   @pitch = 0.0
37   @gaz = 0.0
38   @yaw = 0.0
39   update_pcmd
40 end
land() click to toggle source
   # File lib/argus/controller.rb
22 def land
23   @flying = false
24   update_ref
25 end
led(selection, hertz, duration) click to toggle source
   # File lib/argus/controller.rb
90 def led(selection, hertz, duration)
91   selection = LedAnimation.lookup_value(selection)
92   value = [
93     selection,
94     FloatEncoding.encode_float(hertz),
95     duration
96   ].join(',')
97   @at_commander.config("leds:leds_anim",value)
98   self
99 end
left(amount) click to toggle source
   # File lib/argus/controller.rb
54 def left(amount)
55   @moving = true
56   @roll = -amount
57   update_pcmd
58 end
reset_watchdog() click to toggle source
    # File lib/argus/controller.rb
125 def reset_watchdog
126   @at_commander.comwdg
127   self
128 end
right(amount) click to toggle source
   # File lib/argus/controller.rb
60 def right(amount)
61   @moving = true
62   @roll = amount
63   update_pcmd
64 end
take_off() click to toggle source
   # File lib/argus/controller.rb
16 def take_off
17   @flying = true
18   @emergency = false
19   update_ref
20 end
turn_left(amount) click to toggle source
   # File lib/argus/controller.rb
78 def turn_left(amount)
79   @moving = true
80   @yaw = -amount
81   update_pcmd
82 end
turn_right(amount) click to toggle source
   # File lib/argus/controller.rb
84 def turn_right(amount)
85   @moving = true
86   @yaw = amount
87   update_pcmd
88 end
up(amount) click to toggle source
   # File lib/argus/controller.rb
66 def up(amount)
67   @moving = true
68   @gaz = amount
69   update_pcmd
70 end

Private Instance Methods

update_pcmd() click to toggle source
    # File lib/argus/controller.rb
150 def update_pcmd
151   flags = 0
152   if @moving
153     flags = 1
154     iroll = encode_float(@roll)
155     ipitch = encode_float(@pitch)
156     igaz = encode_float(@gaz)
157     iyaw = encode_float(@yaw)
158     data = "#{flags},#{iroll},#{ipitch},#{igaz},#{iyaw}"
159   else
160     data = "0,0,0,0,0"
161   end
162   @at_commander.pcmd(data)
163   self
164 end
update_ref() click to toggle source
    # File lib/argus/controller.rb
142 def update_ref
143   n = REF_BASE
144   n |= REF_FLY_BIT if @flying
145   n |= REF_EMERGENCY_BIT if @emergency
146   @at_commander.ref(n.to_s)
147   self
148 end