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.



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

def initialize(at_commander)
  @at_commander = at_commander

  @emergency = false
  land
  hover
end

Instance Method Details

#backward(amount) ⇒ Object



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

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

#bottom_cameraObject



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

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

#config(key, value) ⇒ Object



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

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

#demo_modeObject



111
112
113
# File 'lib/argus/controller.rb', line 111

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

#down(amount) ⇒ Object



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

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

#emergencyObject



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

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

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



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

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



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

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

#front_cameraObject



115
116
117
# File 'lib/argus/controller.rb', line 115

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

#hoverObject



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

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

#landObject



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

def land
  @flying = false
  update_ref
end

#led(selection, hertz, duration) ⇒ Object



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

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



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

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

#reset_watchdogObject



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

def reset_watchdog
  @at_commander.reset_watchdog
end

#right(amount) ⇒ Object



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

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

#take_offObject



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

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

#turn_left(amount) ⇒ Object



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

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

#turn_right(amount) ⇒ Object



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

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

#up(amount) ⇒ Object



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

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