Class: Argus::Drone

Inherits:
Object
  • Object
show all
Defined in:
lib/argus/drone.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Drone

Returns a new instance of Drone


9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/argus/drone.rb', line 9

def initialize(opts={})
  host = opts[:remote_host] || '192.168.1.1'
  port = opts[:post] || '5556'
  @sender = opts[:sender] || Argus::UdpSender.new(socket: opts[:socket], remote_host: host, port: port)
  @at = opts[:commander] || Argus::ATCommander.new(@sender)
  @controller = opts[:controller] || Argus::Controller.new(@at)
  if opts[:nav_monitor]
    @nav = opts[:nav_monitor]
  elsif opts.fetch(:enable_nav_monitor, true)
    @nav =  NavMonitor.new(@controller, host)
  else
    @nav = NullNavMonitor.new
  end
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller


7
8
9
# File 'lib/argus/drone.rb', line 7

def controller
  @controller
end

Returns the value of attribute nav


7
8
9
# File 'lib/argus/drone.rb', line 7

def nav
  @nav
end

Instance Method Details

#commanderObject


24
25
26
# File 'lib/argus/drone.rb', line 24

def commander
  @at
end

43
44
45
# File 'lib/argus/drone.rb', line 43

def nav_callback(*args, &block)
  @nav.callback(*args, &block)
end

#start(enable_nav_monitor = true) ⇒ Object


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

def start(enable_nav_monitor=true)
  @nav.start
  @at.start
end

#stopObject


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

def stop
  @controller.land

  @at.stop
  @nav.stop

  @at.join
  @nav.join
end