mavlink-log 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2aa7c3553fcad5fa98c61094e850ed0b23e9e28a
4
- data.tar.gz: 95db6b58d4f7c4bf4af1ca0d5c97218dcf385d01
3
+ metadata.gz: 1f2ccd8859542f1c3980ef2e82e771c82b6c5a1c
4
+ data.tar.gz: 6a08466974f2e16eb8cf2177c68ad424fe563eb6
5
5
  SHA512:
6
- metadata.gz: d2f934aed5b2e6c68f31cec773efe744ded1bf7d0b21497e3e3ddf57a236ad1bacccc86b16e8541a0146050716bd883e8ea14fba02651dcdeebb1fa7c5319896
7
- data.tar.gz: dc241610e2b09e2dc5e32e1d90898ec026dd0986034a3326097d482ece1ebf1b6dd924865f676c5f5aea13be6e3b220b25f0e6b6a5a9583a58332c9ccafc55b5
6
+ metadata.gz: 4c297d769749ef45691c58cd659459a0fdf772af9ac46affb47aab2832a091d4bc94e82b02b0c498f5d3eabee679d68583e2831fbde71549709f683ff600767b
7
+ data.tar.gz: 4aea05a6affd339af3766269b0033b5bf5f024eb3e443f571282149710b8678d447c756ad28c269f8890914d0f30748a9899b6798c2d9cd10cc7a4e1cbe7e00d
@@ -11,7 +11,7 @@ module MAVLink
11
11
  @payload = payload
12
12
  @crc = to_crc(raw_crc)
13
13
 
14
- if false && header.id==22
14
+ if false && header.id==40
15
15
  puts raw_time.unpack('H*')
16
16
  puts payload.unpack("H*")
17
17
  puts raw_crc.unpack('H*')
@@ -36,10 +36,11 @@ module MAVLink
36
36
  if @entries.empty?
37
37
  raise 'No entries found in file'
38
38
  end
39
-
40
- #puts @messages.inspect
41
39
  rescue => e
42
- raise ArgumentError, "File does not appear to be an MAVLink log (#{e})"
40
+ unless @entries.length >= 2
41
+ # bad ending message, give the file benefit of the doubt...
42
+ raise ArgumentError, "File does not appear to be an MAVLink log (#{e})"
43
+ end
43
44
  end
44
45
 
45
46
  # Gets the duration of the session, in seconds.
@@ -47,15 +48,27 @@ module MAVLink
47
48
  # @return [Float] duration of the session, in seconds
48
49
  def duration
49
50
  return 0 if @entries.empty?
50
- (@entries.last.time - @entries.first.time) / 1000000.0
51
+ ended_at - started_at
51
52
  end
52
53
 
54
+ # Gets the starting time as a Unix Epoch time stamp in seconds.
55
+ #
56
+ # @return [Float] unix epoch time the log began
53
57
  def started_at
54
- Time.at(@entries.first.time / 1000000.0)
58
+ time_in_seconds(@entries.first.time)
55
59
  end
56
60
 
61
+ # Gets the ending time as a Unix Epoch time stamp in seconds.
62
+ #
63
+ # @return [Float] unix epoch time the log ended
57
64
  def ended_at
58
- Time.at(@entries.last.time / 1000000.0)
65
+ time_in_seconds(@entries.last.time)
66
+ end
67
+
68
+ private
69
+
70
+ def time_in_seconds(stamp)
71
+ stamp / 1000000.0
59
72
  end
60
73
 
61
74
  end
@@ -21,11 +21,14 @@ module MAVLink; module Log; module Messages
21
21
  when 33; GlobalPositionInt.new(entry)
22
22
  when 35; RcChannelsRaw.new(entry)
23
23
  when 36; ServoOutputRaw.new(entry)
24
+ when 39; MissionItem.new(entry)
25
+ when 40; MissionRequest.new(entry)
24
26
  when 42; MissionCurrent.new(entry)
25
27
  when 62; NavControllerOutput.new(entry)
26
28
  when 66; RequestDataStream.new(entry)
27
29
  when 74; VfrHud.new(entry)
28
30
  when 150..240; Dummy.new(entry)
31
+ when 253; StatusText.new(entry)
29
32
  else
30
33
  puts entry.header.inspect
31
34
  nil
@@ -3,6 +3,8 @@ require_relative 'global_position_int'
3
3
  require_relative 'gps_raw_int'
4
4
  require_relative 'heart_beat'
5
5
  require_relative 'mission_current'
6
+ require_relative 'mission_item'
7
+ require_relative 'mission_request'
6
8
  require_relative 'nav_controller_output'
7
9
  require_relative 'param_request_list'
8
10
  require_relative 'param_value'
@@ -11,5 +13,6 @@ require_relative 'rc_channels_raw'
11
13
  require_relative 'request_data_stream'
12
14
  require_relative 'scaled_pressure'
13
15
  require_relative 'servo_output_raw'
16
+ require_relative 'status_text'
14
17
  require_relative 'sys_status'
15
18
  require_relative 'vfr_hud'
@@ -0,0 +1,63 @@
1
+ module MAVLink; module Log; module Messages
2
+
3
+ class MissionItem < Message
4
+
5
+ def param1
6
+ @param1 ||= float(0..3)
7
+ end
8
+
9
+ def param2
10
+ @param2 ||= float(4..7)
11
+ end
12
+
13
+ def param3
14
+ @param3 ||= float(8..11)
15
+ end
16
+
17
+ def param4
18
+ @param4 ||= float(12..15)
19
+ end
20
+
21
+ def x
22
+ @x ||= float(16..19)
23
+ end
24
+
25
+ def y
26
+ @y ||= float(20..23)
27
+ end
28
+
29
+ def z
30
+ @z ||= float(24..27)
31
+ end
32
+
33
+ def seq
34
+ @seq ||= uint16_t(28..29)
35
+ end
36
+
37
+ def command
38
+ @command ||= uint16_t(30..31)
39
+ end
40
+
41
+ def target_system
42
+ @target_system ||= uint8_t(32)
43
+ end
44
+
45
+ def target_component
46
+ @target_component ||= uint8_t(33)
47
+ end
48
+
49
+ def frame
50
+ @frame ||= uint8_t(34)
51
+ end
52
+
53
+ def current
54
+ @current ||= !!uint8_t(35)
55
+ end
56
+
57
+ def autocontinue
58
+ @autocontinue ||= !!uint8_t(36)
59
+ end
60
+
61
+ end
62
+
63
+ end; end; end
@@ -0,0 +1,19 @@
1
+ module MAVLink; module Log; module Messages
2
+
3
+ class MissionRequest < Message
4
+
5
+ def seq
6
+ @seq ||= 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
+ end
18
+
19
+ end; end; end
@@ -0,0 +1,15 @@
1
+ module MAVLink; module Log; module Messages
2
+
3
+ class StatusText < Message
4
+
5
+ def severity
6
+ @severity ||= uint8_t(0)
7
+ end
8
+
9
+ def text
10
+ @text ||= string(1..50)
11
+ end
12
+
13
+ end
14
+
15
+ end; end; end
@@ -1,5 +1,5 @@
1
1
  module MAVLink
2
2
  module Log
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -4,18 +4,57 @@ describe MAVLink::Log::File do
4
4
 
5
5
  describe '#new' do
6
6
 
7
- context 'with data file delete-me-soon.tlog' do
7
+ context 'with data file 2013-10-13 16-58-51.tlog' do
8
8
 
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") }
9
+ before(:all) { @file = MAVLink::Log::File.new(data_file('2013-10-13 16-58-51.tlog')) }
11
10
 
12
11
  subject { @file }
13
12
 
14
- its(:duration) { should be_within(0.1).of(99.7) }
13
+ its(:duration) { should be_within(0.1).of(570.8) }
15
14
 
16
- it { should have(21138).entries }
15
+ its(:started_at) { should be_within(0.0001).of(1381701533.3125) }
17
16
 
18
- it { should have(21138).messages }
17
+ its(:ended_at) { should be_within(0.0001).of(1381702104.1094) }
18
+
19
+ it { should have(16187).entries }
20
+
21
+ it { should have(16187).messages }
22
+
23
+ end
24
+
25
+ context 'with data file 2013-10-13 18-31-24.tlog' do
26
+
27
+ before(:all) { @file = MAVLink::Log::File.new(data_file('2013-10-13 18-31-24.tlog')) }
28
+
29
+ subject { @file }
30
+
31
+ its(:duration) { should be_within(0.1).of(1113.8) }
32
+
33
+ its(:started_at) { should be_within(0.0001).of(1381707086.4375) }
34
+
35
+ its(:ended_at) { should be_within(0.0001).of(1381708200.2188) }
36
+
37
+ it { should have(13382).entries }
38
+
39
+ it { should have(13382).messages }
40
+
41
+ end
42
+
43
+ context 'with data file 2013-10-13 18-50-10.tlog' do
44
+
45
+ before(:all) { @file = MAVLink::Log::File.new(data_file('2013-10-13 18-50-10.tlog')) }
46
+
47
+ subject { @file }
48
+
49
+ its(:duration) { should be_within(0.1).of(629.9) }
50
+
51
+ its(:started_at) { should be_within(0.0001).of(1381708212.0313) }
52
+
53
+ its(:ended_at) { should be_within(0.0001).of(1381708842.0) }
54
+
55
+ it { should have(19359).entries }
56
+
57
+ it { should have(19359).messages }
19
58
 
20
59
  end
21
60
 
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe MAVLink::Log::Messages::MissionItem do
4
+
5
+ let(:time) { ["0004E8A67D4E5686"].pack('H*') }
6
+
7
+ let(:header) { MAVLink::Log::Header.new(["FE25BB010127"].pack('H*')) }
8
+
9
+ let(:payload) { ["0000000000000000000000000000000016BE24425C05C0C20000000000001000FFBE000101"].pack('H*') }
10
+
11
+ let(:crc) { ["9E5A"].pack('H*') }
12
+
13
+ subject do
14
+ entry = MAVLink::Log::Entry.new(time, header, payload, crc)
15
+ MAVLink::Log::Messages::MissionItem.new(entry)
16
+ end
17
+
18
+ it_behaves_like 'a message'
19
+
20
+ its(:param1) { should be_within(0.1).of(0) }
21
+
22
+ its(:param2) { should be_within(0.1).of(0) }
23
+
24
+ its(:param3) { should be_within(0.1).of(0) }
25
+
26
+ its(:param4) { should be_within(0.1).of(0) }
27
+
28
+ its(:x) { should be_within(0.00001).of(41.18563) }
29
+
30
+ its(:y) { should be_within(0.00001).of(-96.01047) }
31
+
32
+ its(:z) { should be_within(0.1).of(0) }
33
+
34
+ its(:seq) { should eql(0) }
35
+
36
+ its(:command) { should eql(16) }
37
+
38
+ its(:target_system) { should eql(255) }
39
+
40
+ its(:target_component) { should eql(190) }
41
+
42
+ its(:frame) { should eql(0) }
43
+
44
+ its(:current) { should be_true }
45
+
46
+ its(:autocontinue) { should be_true }
47
+
48
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe MAVLink::Log::Messages::MissionRequest do
4
+
5
+ let(:time) { ["0004E8A7C0EAD571"].pack('H*') }
6
+
7
+ let(:header) { MAVLink::Log::Header.new(["FE0449FFBE28"].pack('H*')) }
8
+
9
+ let(:payload) { ["00000101"].pack('H*') }
10
+
11
+ let(:crc) { ["14B9"].pack('H*') }
12
+
13
+ subject do
14
+ entry = MAVLink::Log::Entry.new(time, header, payload, crc)
15
+ MAVLink::Log::Messages::MissionRequest.new(entry)
16
+ end
17
+
18
+ it_behaves_like 'a message'
19
+
20
+ its(:seq) { should eql(0) }
21
+
22
+ its(:target_system) { should eql(1) }
23
+
24
+ its(:target_component) { should eql(1) }
25
+
26
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe MAVLink::Log::Messages::StatusText do
4
+
5
+ let(:time) { ["0004E8A824FF4B55"].pack('H*') }
6
+
7
+ let(:header) { MAVLink::Log::Header.new(["FE331C0101FD"].pack('H*')) }
8
+
9
+ let(:payload) { ["01496E697469616C6973696E672041504D2E2E2E00000000000000000000000000000000000000000000000000000000000000"].pack('H*') }
10
+
11
+ let(:crc) { ["BD5C"].pack('H*') }
12
+
13
+ subject do
14
+ entry = MAVLink::Log::Entry.new(time, header, payload, crc)
15
+ MAVLink::Log::Messages::StatusText.new(entry)
16
+ end
17
+
18
+ it_behaves_like 'a message'
19
+
20
+ its(:severity) { should eql(1) }
21
+
22
+ its(:text) { should eql('Initialising APM...') }
23
+
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mavlink-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Veys
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-13 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -161,6 +161,8 @@ files:
161
161
  - lib/mavlink/log/messages/heart_beat.rb
162
162
  - lib/mavlink/log/messages/messages.rb
163
163
  - lib/mavlink/log/messages/mission_current.rb
164
+ - lib/mavlink/log/messages/mission_item.rb
165
+ - lib/mavlink/log/messages/mission_request.rb
164
166
  - lib/mavlink/log/messages/nav_controller_output.rb
165
167
  - lib/mavlink/log/messages/param_request_list.rb
166
168
  - lib/mavlink/log/messages/param_value.rb
@@ -169,11 +171,14 @@ files:
169
171
  - lib/mavlink/log/messages/request_data_stream.rb
170
172
  - lib/mavlink/log/messages/scaled_pressure.rb
171
173
  - lib/mavlink/log/messages/servo_output_raw.rb
174
+ - lib/mavlink/log/messages/status_text.rb
172
175
  - lib/mavlink/log/messages/sys_status.rb
173
176
  - lib/mavlink/log/messages/vfr_hud.rb
174
177
  - lib/mavlink/log/version.rb
175
178
  - mavlink-log.gemspec
176
- - spec/data/delete-me-soon.tlog
179
+ - spec/data/2013-10-13 16-58-51.tlog
180
+ - spec/data/2013-10-13 18-31-24.tlog
181
+ - spec/data/2013-10-13 18-50-10.tlog
177
182
  - spec/data/invalid/castle/long-flight.csv
178
183
  - spec/data/invalid/eagle_tree/multi-session-2.fdr
179
184
  - spec/data/invalid/empty.file
@@ -183,9 +188,12 @@ files:
183
188
  - spec/messages/global_position_int_spec.rb
184
189
  - spec/messages/gps_raw_int_spec.rb
185
190
  - spec/messages/heart_beat_spec.rb
191
+ - spec/messages/mission_item_spec.rb
192
+ - spec/messages/mission_request_spec.rb
186
193
  - spec/messages/param_value_spec.rb
187
194
  - spec/messages/raw_imu_spec.rb
188
195
  - spec/messages/rc_channels_raw_spec.rb
196
+ - spec/messages/status_text_spec.rb
189
197
  - spec/messages/sys_status_spec.rb
190
198
  - spec/messages/vfr_hud_spec.rb
191
199
  - spec/spec_helper.rb
@@ -218,7 +226,9 @@ signing_key:
218
226
  specification_version: 4
219
227
  summary: MAVLink telemetry log file reader
220
228
  test_files:
221
- - spec/data/delete-me-soon.tlog
229
+ - spec/data/2013-10-13 16-58-51.tlog
230
+ - spec/data/2013-10-13 18-31-24.tlog
231
+ - spec/data/2013-10-13 18-50-10.tlog
222
232
  - spec/data/invalid/castle/long-flight.csv
223
233
  - spec/data/invalid/eagle_tree/multi-session-2.fdr
224
234
  - spec/data/invalid/empty.file
@@ -228,9 +238,12 @@ test_files:
228
238
  - spec/messages/global_position_int_spec.rb
229
239
  - spec/messages/gps_raw_int_spec.rb
230
240
  - spec/messages/heart_beat_spec.rb
241
+ - spec/messages/mission_item_spec.rb
242
+ - spec/messages/mission_request_spec.rb
231
243
  - spec/messages/param_value_spec.rb
232
244
  - spec/messages/raw_imu_spec.rb
233
245
  - spec/messages/rc_channels_raw_spec.rb
246
+ - spec/messages/status_text_spec.rb
234
247
  - spec/messages/sys_status_spec.rb
235
248
  - spec/messages/vfr_hud_spec.rb
236
249
  - spec/spec_helper.rb