Class: ARbDrone
- Inherits:
-
Object
show all
- Defined in:
- lib/arbdrone.rb,
lib/arbdrone/control.rb,
lib/arbdrone/version.rb,
lib/arbdrone/nav_data.rb,
lib/arbdrone/tcp_control.rb
Defined Under Namespace
Modules: Control, NavData, TcpControl
Classes: Version
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ ARbDrone
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/arbdrone.rb', line 10
def initialize(options = {})
@drone_ip = options.delete(:drone_ip) || '192.168.1.1'
@drone_firmware_port = options.delete(:drone_firmware_port) || 5551
@drone_navdata_port = options.delete(:drone_navdata_port) || 5554
@drone_video_port = options.delete(:drone_video_port) || 5555
@drone_control_port = options.delete(:drone_control_port) || 5556
@drone_raw_capture_port = options.delete(:drone_raw_capture_port) || 5557 @drone_tcp_console_port = options.delete(:drone_tcp_console_port) || 5558 @drone_tcp_control_port = options.delete(:drone_tcp_control_port) || 5559
@listen_ip = options.delete(:listen_ip) || '0.0.0.0'
end
|
Instance Attribute Details
#control ⇒ Object
Returns the value of attribute control.
8
9
10
|
# File 'lib/arbdrone.rb', line 8
def control
@control
end
|
#control_config ⇒ Object
Returns the value of attribute control_config.
8
9
10
|
# File 'lib/arbdrone.rb', line 8
def control_config
@control_config
end
|
#navdata ⇒ Object
Returns the value of attribute navdata.
8
9
10
|
# File 'lib/arbdrone.rb', line 8
def navdata
@navdata
end
|
Instance Method Details
#run ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/arbdrone.rb', line 22
def run
EventMachine.run do
@control = run_control
@control_config = run_control_config
@navdata = run_navdata
end
end
|
#run_control ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/arbdrone.rb', line 30
def run_control
connection = EventMachine.open_datagram_socket @listen_ip, @drone_control_port, Control
connection.setup @drone_ip, @drone_control_port
@control_timer = EventMachine.add_periodic_timer 0.02 do
connection.send_queued_messages
end
connection
end
|
#run_control_config ⇒ Object
41
42
43
44
45
|
# File 'lib/arbdrone.rb', line 41
def run_control_config
connection = EventMachine.connect @drone_ip, @drone_tcp_control_port, TcpControl
connection.control_channel = @control
connection
end
|
#run_navdata ⇒ Object
52
53
54
55
56
57
58
59
60
|
# File 'lib/arbdrone.rb', line 52
def run_navdata
connection = EventMachine.open_datagram_socket '0.0.0.0', @drone_navdata_port, NavData
connection.setup @drone_ip, @drone_navdata_port
ip = IPAddr.new('224.1.1.1').hton + IPAddr.new(@listen_ip).hton
connection.set_sock_opt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip)
connection.send_initial_message
connection
end
|
#stop_control ⇒ Object
47
48
49
50
|
# File 'lib/arbdrone.rb', line 47
def stop_control
@control.land
@control_timer.cancel
end
|