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


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


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

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

#backward(amount) ⇒ Object


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

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

#bottom_cameraObject


121
122
123
# File 'lib/argus/controller.rb', line 121

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

#config(key, value) ⇒ Object


108
109
110
111
# File 'lib/argus/controller.rb', line 108

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

#demo_modeObject


113
114
115
# File 'lib/argus/controller.rb', line 113

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

#down(amount) ⇒ Object


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

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

#emergencyObject


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

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

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


101
102
103
104
105
106
# File 'lib/argus/controller.rb', line 101

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

#forward(amount) ⇒ Object


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

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

#front_cameraObject


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

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

#hoverObject


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

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


90
91
92
93
94
95
96
97
98
99
# File 'lib/argus/controller.rb', line 90

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


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

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

#reset_watchdogObject


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

def reset_watchdog
  @at_commander.comwdg
  self
end

#right(amount) ⇒ Object


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

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


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

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

#turn_right(amount) ⇒ Object


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

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

#up(amount) ⇒ Object


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

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