mavlink-log 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/mavlink/log.rb +5 -1
- data/lib/mavlink/log/entry.rb +34 -0
- data/lib/mavlink/log/file.rb +16 -41
- data/lib/mavlink/log/header.rb +20 -0
- data/lib/mavlink/log/message.rb +83 -0
- data/lib/mavlink/log/messages/attitude.rb +37 -0
- data/lib/mavlink/log/messages/factory.rb +37 -0
- data/lib/mavlink/log/messages/global_position_int.rb +47 -0
- data/lib/mavlink/log/messages/gps_raw_int.rb +51 -0
- data/lib/mavlink/log/messages/heart_beat.rb +31 -0
- data/lib/mavlink/log/messages/messages.rb +15 -0
- data/lib/mavlink/log/messages/mission_current.rb +11 -0
- data/lib/mavlink/log/messages/nav_controller_output.rb +39 -0
- data/lib/mavlink/log/messages/param_request_list.rb +15 -0
- data/lib/mavlink/log/messages/param_value.rb +27 -0
- data/lib/mavlink/log/messages/raw_imu.rb +43 -0
- data/lib/mavlink/log/messages/rc_channels_raw.rb +47 -0
- data/lib/mavlink/log/messages/request_data_stream.rb +27 -0
- data/lib/mavlink/log/messages/scaled_pressure.rb +19 -0
- data/lib/mavlink/log/messages/servo_output_raw.rb +43 -0
- data/lib/mavlink/log/messages/sys_status.rb +64 -0
- data/lib/mavlink/log/messages/vfr_hud.rb +37 -0
- data/lib/mavlink/log/version.rb +1 -1
- data/spec/file_spec.rb +11 -1
- data/spec/messages/attitude_spec.rb +34 -0
- data/spec/messages/global_position_int_spec.rb +38 -0
- data/spec/messages/gps_raw_int_spec.rb +40 -0
- data/spec/messages/heart_beat_spec.rb +32 -0
- data/spec/messages/param_value_spec.rb +30 -0
- data/spec/messages/raw_imu_spec.rb +40 -0
- data/spec/messages/rc_channels_raw_spec.rb +42 -0
- data/spec/messages/sys_status_spec.rb +46 -0
- data/spec/messages/vfr_hud_spec.rb +32 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/shared_examples_for_message.rb +13 -0
- data/spec/support/shared_examples_for_timed_message_micro.rb +9 -0
- data/spec/support/shared_examples_for_timed_message_milli.rb +9 -0
- data/spec/sys_status_spec.rb +0 -0
- metadata +48 -3
- data/lib/mavlink/log/messages.rb +0 -138
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative 'attitude'
|
2
|
+
require_relative 'global_position_int'
|
3
|
+
require_relative 'gps_raw_int'
|
4
|
+
require_relative 'heart_beat'
|
5
|
+
require_relative 'mission_current'
|
6
|
+
require_relative 'nav_controller_output'
|
7
|
+
require_relative 'param_request_list'
|
8
|
+
require_relative 'param_value'
|
9
|
+
require_relative 'raw_imu'
|
10
|
+
require_relative 'rc_channels_raw'
|
11
|
+
require_relative 'request_data_stream'
|
12
|
+
require_relative 'scaled_pressure'
|
13
|
+
require_relative 'servo_output_raw'
|
14
|
+
require_relative 'sys_status'
|
15
|
+
require_relative 'vfr_hud'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module MAVLink; module Log; module Messages
|
2
|
+
|
3
|
+
class NavControllerOutput < Message
|
4
|
+
|
5
|
+
def nav_roll
|
6
|
+
@nav_roll ||= float(0..3)
|
7
|
+
end
|
8
|
+
|
9
|
+
def nav_pitch
|
10
|
+
@nav_pitch ||= float(4..7)
|
11
|
+
end
|
12
|
+
|
13
|
+
def alt_error
|
14
|
+
@alt_error ||= float(8..11)
|
15
|
+
end
|
16
|
+
|
17
|
+
def aspd_error
|
18
|
+
@aspd_error ||= float(12..15)
|
19
|
+
end
|
20
|
+
|
21
|
+
def xtrack_error
|
22
|
+
@xtrack_error ||= float(16..19)
|
23
|
+
end
|
24
|
+
|
25
|
+
def nav_bearing
|
26
|
+
@nav_bearing ||= int16_t(20..21)
|
27
|
+
end
|
28
|
+
|
29
|
+
def target_bearing
|
30
|
+
@target_bearing ||= int16_t(22..23)
|
31
|
+
end
|
32
|
+
|
33
|
+
def wp_dist
|
34
|
+
@wp_dist ||= uint16_t(24..25)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end; end; end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module MAVLink; module Log; module Messages
|
2
|
+
|
3
|
+
class ParamValue < Message
|
4
|
+
|
5
|
+
def param_value
|
6
|
+
@param_value ||= float(0..3)
|
7
|
+
end
|
8
|
+
|
9
|
+
def param_count
|
10
|
+
@param_count ||= uint16_t(4..5)
|
11
|
+
end
|
12
|
+
|
13
|
+
def param_index
|
14
|
+
@param_index ||= uint16_t(6..7)
|
15
|
+
end
|
16
|
+
|
17
|
+
def param_id
|
18
|
+
@param_id ||= string(8..23)
|
19
|
+
end
|
20
|
+
|
21
|
+
def param_type
|
22
|
+
@param_type ||= uint8_t(24)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end; end; end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module MAVLink; module Log; module Messages
|
2
|
+
|
3
|
+
class RawImu < TimedMessageMicro
|
4
|
+
|
5
|
+
def xacc
|
6
|
+
@xacc ||= int16_t(8..9)
|
7
|
+
end
|
8
|
+
|
9
|
+
def yacc
|
10
|
+
@yacc ||= int16_t(10..11)
|
11
|
+
end
|
12
|
+
|
13
|
+
def zacc
|
14
|
+
@zacc ||= int16_t(12..13)
|
15
|
+
end
|
16
|
+
|
17
|
+
def xgyro
|
18
|
+
@xgyro ||= int16_t(14..15)
|
19
|
+
end
|
20
|
+
|
21
|
+
def ygyro
|
22
|
+
@ygyro ||= int16_t(16..17)
|
23
|
+
end
|
24
|
+
|
25
|
+
def zgyro
|
26
|
+
@zgyro ||= int16_t(18..19)
|
27
|
+
end
|
28
|
+
|
29
|
+
def xmag
|
30
|
+
@xmag ||= int16_t(20..21)
|
31
|
+
end
|
32
|
+
|
33
|
+
def ymag
|
34
|
+
@ymag ||= int16_t(22..23)
|
35
|
+
end
|
36
|
+
|
37
|
+
def zmag
|
38
|
+
@zmag ||= int16_t(24..25)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end; end; end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module MAVLink; module Log; module Messages
|
2
|
+
|
3
|
+
class RcChannelsRaw < TimedMessageMilli
|
4
|
+
|
5
|
+
def chan1_raw
|
6
|
+
@chan1_raw ||= uint16_t(4..5)
|
7
|
+
end
|
8
|
+
|
9
|
+
def chan2_raw
|
10
|
+
@chan2_raw ||= uint16_t(6..7)
|
11
|
+
end
|
12
|
+
|
13
|
+
def chan3_raw
|
14
|
+
@chan3_raw ||= uint16_t(8..9)
|
15
|
+
end
|
16
|
+
|
17
|
+
def chan4_raw
|
18
|
+
@chan4_raw ||= uint16_t(10..11)
|
19
|
+
end
|
20
|
+
|
21
|
+
def chan5_raw
|
22
|
+
@chan5_raw ||= uint16_t(12..13)
|
23
|
+
end
|
24
|
+
|
25
|
+
def chan6_raw
|
26
|
+
@chan6_raw ||= uint16_t(14..15)
|
27
|
+
end
|
28
|
+
|
29
|
+
def chan7_raw
|
30
|
+
@chan7_raw ||= uint16_t(16..17)
|
31
|
+
end
|
32
|
+
|
33
|
+
def chan8_raw
|
34
|
+
@chan8_raw ||= uint16_t(18..19)
|
35
|
+
end
|
36
|
+
|
37
|
+
def port
|
38
|
+
@port ||= uint8_t(20)
|
39
|
+
end
|
40
|
+
|
41
|
+
def rssi
|
42
|
+
@rssi ||= uint8_t(21)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end; end; end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module MAVLink; module Log; module Messages
|
2
|
+
|
3
|
+
class RequestDataStream < Message
|
4
|
+
|
5
|
+
def req_message_rate
|
6
|
+
@req_message_rate ||= uint16_t(0..1)
|
7
|
+
end
|
8
|
+
|
9
|
+
def target_system
|
10
|
+
@target_system ||= uint8_t(2)
|
11
|
+
end
|
12
|
+
|
13
|
+
def target_component
|
14
|
+
@target_component ||= uint8_t(3)
|
15
|
+
end
|
16
|
+
|
17
|
+
def req_stream_id
|
18
|
+
@req_stream_id ||= uint8_t(4)
|
19
|
+
end
|
20
|
+
|
21
|
+
def start_stop
|
22
|
+
@start_stop ||= uint8_t(5)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end; end; end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module MAVLink; module Log; module Messages
|
2
|
+
|
3
|
+
class ScaledPressure < TimedMessageMilli
|
4
|
+
|
5
|
+
def press_abs
|
6
|
+
@press_abs ||= float(4..7)
|
7
|
+
end
|
8
|
+
|
9
|
+
def press_diff
|
10
|
+
@press_diff ||= float(8..11)
|
11
|
+
end
|
12
|
+
|
13
|
+
def temperature
|
14
|
+
@temperature ||= int16_t(12..13)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end; end; end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module MAVLink; module Log; module Messages
|
2
|
+
|
3
|
+
class ServoOutputRaw < TimedMessageMicro
|
4
|
+
|
5
|
+
def servo1_raw
|
6
|
+
@servo1_raw ||= uint16_t(4..5)
|
7
|
+
end
|
8
|
+
|
9
|
+
def servo2_raw
|
10
|
+
@servo2_raw ||= uint16_t(6..7)
|
11
|
+
end
|
12
|
+
|
13
|
+
def servo3_raw
|
14
|
+
@servo3_raw ||= uint16_t(8..9)
|
15
|
+
end
|
16
|
+
|
17
|
+
def servo4_raw
|
18
|
+
@servo4_raw ||= uint16_t(10..11)
|
19
|
+
end
|
20
|
+
|
21
|
+
def servo5_raw
|
22
|
+
@servo5_raw ||= uint16_t(12..13)
|
23
|
+
end
|
24
|
+
|
25
|
+
def servo6_raw
|
26
|
+
@servo6_raw ||= uint16_t(14..15)
|
27
|
+
end
|
28
|
+
|
29
|
+
def servo7_raw
|
30
|
+
@servo7_raw ||= uint16_t(16..17)
|
31
|
+
end
|
32
|
+
|
33
|
+
def servo8_raw
|
34
|
+
@servo8_raw ||= uint16_t(18..19)
|
35
|
+
end
|
36
|
+
|
37
|
+
def port
|
38
|
+
@port ||= uint8_t(20)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end; end; end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module MAVLink; module Log; module Messages
|
2
|
+
|
3
|
+
class SysStatus < Message
|
4
|
+
|
5
|
+
def onboard_control_sensors_present
|
6
|
+
@onboard_control_sensors_present ||= uint32_t(0..3)
|
7
|
+
end
|
8
|
+
|
9
|
+
def onboard_control_sensors_enabled
|
10
|
+
@onboard_control_sensors_enabled ||= uint32_t(4..7)
|
11
|
+
end
|
12
|
+
|
13
|
+
def onboard_control_sensors_health
|
14
|
+
@onboard_control_sensors_health ||= uint32_t(8..11)
|
15
|
+
end
|
16
|
+
|
17
|
+
# 0%..100%
|
18
|
+
def load
|
19
|
+
@load ||= (uint16_t(12..13) / 10.0)
|
20
|
+
end
|
21
|
+
|
22
|
+
# V
|
23
|
+
def voltage_battery
|
24
|
+
@load ||= (uint16_t(14..15) / 1000.0)
|
25
|
+
end
|
26
|
+
|
27
|
+
# A (-1: not measured)
|
28
|
+
def current_battery
|
29
|
+
@load ||= (int16_t(16..17) / 100.0)
|
30
|
+
end
|
31
|
+
|
32
|
+
# 0%..100% (-1: not measured)
|
33
|
+
def battery_remaining
|
34
|
+
@battery_remaining ||= uint8_t(18)
|
35
|
+
end
|
36
|
+
|
37
|
+
# 0%..100% (bad packet %age)
|
38
|
+
def drop_rate_comm
|
39
|
+
@drop_rate_comm ||= (uint16_t(19..20) / 100)
|
40
|
+
end
|
41
|
+
|
42
|
+
def errors_comm
|
43
|
+
@errors_comm ||= uint16_t(21..22)
|
44
|
+
end
|
45
|
+
|
46
|
+
def errors_count1
|
47
|
+
@errors_count1 ||= uint16_t(23..24)
|
48
|
+
end
|
49
|
+
|
50
|
+
def errors_count2
|
51
|
+
@errors_count2 ||= uint16_t(25..26)
|
52
|
+
end
|
53
|
+
|
54
|
+
def errors_count3
|
55
|
+
@errors_count3 ||= uint16_t(27..28)
|
56
|
+
end
|
57
|
+
|
58
|
+
def errors_count4
|
59
|
+
@errors_count4 ||= uint16_t(29..30)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end; end; end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module MAVLink; module Log; module Messages
|
2
|
+
|
3
|
+
class VfrHud < Message
|
4
|
+
|
5
|
+
# m/s
|
6
|
+
def airspeed
|
7
|
+
@airspeed ||= float(0..3)
|
8
|
+
end
|
9
|
+
|
10
|
+
# m/s
|
11
|
+
def groundspeed
|
12
|
+
@groundspeed ||= float(4..7)
|
13
|
+
end
|
14
|
+
|
15
|
+
# 0..360
|
16
|
+
def heading
|
17
|
+
@heading ||= int16_t(8..9)
|
18
|
+
end
|
19
|
+
|
20
|
+
# 0..100%
|
21
|
+
def throttle
|
22
|
+
@throttle ||= uint16_t(10..11)
|
23
|
+
end
|
24
|
+
|
25
|
+
# meters (MSL)
|
26
|
+
def alt
|
27
|
+
@alt ||= float(12..15)
|
28
|
+
end
|
29
|
+
|
30
|
+
# m/s
|
31
|
+
def climb
|
32
|
+
@climb ||= float(16..19)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end; end; end
|
data/lib/mavlink/log/version.rb
CHANGED
data/spec/file_spec.rb
CHANGED
@@ -7,6 +7,7 @@ describe MAVLink::Log::File do
|
|
7
7
|
context 'with data file delete-me-soon.tlog' do
|
8
8
|
|
9
9
|
before(:all) { @file = MAVLink::Log::File.new(data_file('delete-me-soon.tlog')) }
|
10
|
+
#before(:all) { @file = MAVLink::Log::File.new("/Users/nick/Desktop/2013-10-11 16-28-33.tlog") }
|
10
11
|
|
11
12
|
subject { @file }
|
12
13
|
|
@@ -14,10 +15,19 @@ describe MAVLink::Log::File do
|
|
14
15
|
|
15
16
|
it { should have(21138).entries }
|
16
17
|
|
17
|
-
|
18
|
+
it { should have(21138).messages }
|
18
19
|
|
19
20
|
end
|
20
21
|
|
22
|
+
it 'should raise for invalid or missing files' do
|
23
|
+
files = invalid_data_files
|
24
|
+
files.should have(6).files
|
25
|
+
|
26
|
+
files.each do |f|
|
27
|
+
expect { MAVLink::Log::File.new(f) }.to raise_error
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
21
31
|
end
|
22
32
|
|
23
33
|
end
|