Class: Argus::Controller

Inherits:
Object
  • Object
show all
Includes:
FloatEncoding
Defined in:
lib/argus/controller.rb

Instance Method Summary collapse

Methods included from FloatEncoding

decode_float, encode_float

Constructor Details

#initialize(at_commander) ⇒ Controller

Returns a new instance of Controller.


8
9
10
11
12
13
14
# File 'lib/argus/controller.rb', line 8

def initialize(at_commander)
  @at_commander = at_commander

  @emergency = false
  land
  hover
end

Instance Method Details

#ack_control_modeObject


146
147
148
149
# File 'lib/argus/controller.rb', line 146

def ack_control_mode
  @at_commander.ctrl(ArdroneControlModes::ACK_CONTROL_MODE)
  self
end

#animate(selection, duration) ⇒ Object


107
108
109
110
111
112
113
114
115
# File 'lib/argus/controller.rb', line 107

def animate(selection, duration)
  selection = FlightAnimation.lookup_value(selection)
  value = [
    selection,
    duration
  ].join(',')
  @at_commander.config("control:flight_anim",value)
  self
end

#backward(amount) ⇒ Object


54
55
56
57
58
# File 'lib/argus/controller.rb', line 54

def backward(amount)
  @moving = true
  @pitch = amount
  update_pcmd
end

#bottom_cameraObject


137
138
139
# File 'lib/argus/controller.rb', line 137

def bottom_camera
  config("video:video_channel", "1")
end

#config(key, value) ⇒ Object


124
125
126
127
# File 'lib/argus/controller.rb', line 124

def config(key, value)
  @at_commander.config(key, value)
  self
end

#demo_modeObject


129
130
131
# File 'lib/argus/controller.rb', line 129

def demo_mode
  config("general:navdata_demo", "TRUE")
end

#disable_emergency(state = true) ⇒ Object


33
34
35
36
37
# File 'lib/argus/controller.rb', line 33

def disable_emergency(state=true)
  @flying = false
  @emergency = state
  update_ref
end

#down(amount) ⇒ Object


78
79
80
81
82
# File 'lib/argus/controller.rb', line 78

def down(amount)
  @moving = true
  @gaz = -amount
  update_pcmd
end

#enable_detection(colors, type = 10, select = 32) ⇒ Object


117
118
119
120
121
122
# File 'lib/argus/controller.rb', line 117

def enable_detection(colors, type=10, select=32)
  config("detect:enemy_colors",colors.to_s)
  config("detect:detect_type", type.to_s)
  config("detect:detections_select_h", select.to_s)
  self
end

#enable_emergency(state = false) ⇒ Object


27
28
29
30
31
# File 'lib/argus/controller.rb', line 27

def enable_emergency(state=false)
  @flying = true
  @emergency = state
  update_ref
end

#forward(amount) ⇒ Object


48
49
50
51
52
# File 'lib/argus/controller.rb', line 48

def forward(amount)
  @moving = true
  @pitch = -amount
  update_pcmd
end

#front_cameraObject


133
134
135
# File 'lib/argus/controller.rb', line 133

def front_camera
  config("video:video_channel", "2")
end

#hoverObject


39
40
41
42
43
44
45
46
# File 'lib/argus/controller.rb', line 39

def hover
  @moving = false
  @roll = 0.0
  @pitch = 0.0
  @gaz = 0.0
  @yaw = 0.0
  update_pcmd
end

#landObject


22
23
24
25
# File 'lib/argus/controller.rb', line 22

def land
  @flying = false
  update_ref
end

#led(selection, hertz, duration) ⇒ Object


96
97
98
99
100
101
102
103
104
105
# File 'lib/argus/controller.rb', line 96

def led(selection, hertz, duration)
  selection = LedAnimation.lookup_value(selection)
  value = [
    selection,
    FloatEncoding.encode_float(hertz),
    duration
  ].join(',')
  @at_commander.config("leds:leds_anim",value)
  self
end

#left(amount) ⇒ Object


60
61
62
63
64
# File 'lib/argus/controller.rb', line 60

def left(amount)
  @moving = true
  @roll = -amount
  update_pcmd
end

#reset_watchdogObject


141
142
143
144
# File 'lib/argus/controller.rb', line 141

def reset_watchdog
  @at_commander.comwdg
  self
end

#right(amount) ⇒ Object


66
67
68
69
70
# File 'lib/argus/controller.rb', line 66

def right(amount)
  @moving = true
  @roll = amount
  update_pcmd
end

#take_offObject


16
17
18
19
20
# File 'lib/argus/controller.rb', line 16

def take_off
  @flying = true
  @emergency = false
  update_ref
end

#turn_left(amount) ⇒ Object


84
85
86
87
88
# File 'lib/argus/controller.rb', line 84

def turn_left(amount)
  @moving = true
  @yaw = -amount
  update_pcmd
end

#turn_right(amount) ⇒ Object


90
91
92
93
94
# File 'lib/argus/controller.rb', line 90

def turn_right(amount)
  @moving = true
  @yaw = amount
  update_pcmd
end

#up(amount) ⇒ Object


72
73
74
75
76
# File 'lib/argus/controller.rb', line 72

def up(amount)
  @moving = true
  @gaz = amount
  update_pcmd
end