gps_pvt 0.2.1 → 0.2.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.
@@ -73,12 +73,12 @@ class Receiver
73
73
  next ([nil] * 6 * opt[:satellites].size) unless pvt.position_solved?
74
74
  sats = pvt.used_satellite_list
75
75
  r, w = [:delta_r, :W].collect{|f| pvt.send(f)}
76
- opt[:satellites].collect{|i|
77
- next ([nil] * 6) unless i2 = sats.index(i)
76
+ opt[:satellites].collect{|prn, label|
77
+ next ([nil] * 6) unless i2 = sats.index(prn)
78
78
  [r[i2, 0], w[i2, i2]] +
79
79
  [:azimuth, :elevation].collect{|f|
80
- pvt.send(f)[i] / Math::PI * 180
81
- } + [pvt.slopeH[i], pvt.slopeV[i]]
80
+ pvt.send(f)[prn] / Math::PI * 180
81
+ } + [pvt.slopeH[prn], pvt.slopeV[prn]]
82
82
  }.flatten
83
83
  },
84
84
  ]] + [[
@@ -106,16 +106,19 @@ class Receiver
106
106
  opt = {
107
107
  :satellites => (1..32).to_a,
108
108
  }.merge(opt)
109
+ keys = [:PSEUDORANGE, :RANGE_RATE, :DOPPLER, :FREQUENCY].collect{|k|
110
+ GPS::Measurement.const_get("L1_#{k}".to_sym)
111
+ }
109
112
  [[
110
113
  opt[:satellites].collect{|prn, label|
111
114
  [:L1_range, :L1_rate].collect{|str| "#{str}(#{label || prn})"}
112
115
  }.flatten,
113
116
  proc{|meas|
114
- meas_hash = Hash[*(meas.collect{|prn, k, v| [[prn, k], v]}.flatten(1))]
115
- opt[:satellites].collect{|prn|
116
- [:L1_PSEUDORANGE, [:L1_DOPPLER, GPS::SpaceNode.L1_WaveLength]].collect{|k, sf|
117
- meas_hash[[prn, GPS::Measurement.const_get(k)]] * (sf || 1) rescue nil
118
- }
117
+ meas_hash = meas.to_hash
118
+ opt[:satellites].collect{|prn, label|
119
+ pr, rate, doppler, freq = keys.collect{|k| meas_hash[prn][k] rescue nil}
120
+ freq ||= GPS::SpaceNode.L1_Frequency
121
+ [pr, rate || ((doppler * GPS::SpaceNode::light_speed / freq) rescue nil)]
119
122
  }
120
123
  }
121
124
  ]]
@@ -135,6 +138,11 @@ class Receiver
135
138
  rel_prop
136
139
  }
137
140
  @debug = {}
141
+ [:gps_options, :sbas_options].each{|target|
142
+ opt = @solver.send(target) # default solver options
143
+ opt.elevation_mask = 0.0 / 180 * Math::PI # 0 deg (use satellite over horizon)
144
+ opt.residual_mask = 1E4 # 10 km (without residual filter, practically)
145
+ }
138
146
  output_options = {
139
147
  :system => [[:GPS, 1..32], [:QZSS, 193..202]],
140
148
  :satellites => (1..32).to_a + (193..202).to_a, # [idx, ...] or [[idx, label], ...] is acceptable
@@ -193,9 +201,9 @@ class Receiver
193
201
  sys, svid = case spec
194
202
  when Integer
195
203
  [nil, spec]
196
- when /([a-zA-Z]+)(?::(-?\d+))?/
197
- [$1.upcase.to_sym, (Integre($2) rescue nil)]
198
- when /-?\d+/
204
+ when /^([a-zA-Z]+)(?::(-?\d+))?$/
205
+ [$1.upcase.to_sym, (Integer($2) rescue nil)]
206
+ when /^-?\d+$/
199
207
  [nil, $&.to_i]
200
208
  else
201
209
  next false
@@ -206,27 +214,35 @@ class Receiver
206
214
  else
207
215
  (k == :with) ? :include : :exclude
208
216
  end
209
- if (sys == :GPS) || (sys == :QZSS) \
210
- || (svid && ((1..32).include?(svid) || (193..202).include?(svid))) then
211
- [svid || ((1..32).to_a + (193..202).to_a)].flatten.each{
212
- @solver.gps_options.send(mode, svid)
213
- }
214
- elsif (sys == :SBAS) || (svid && (120..158).include?(svid)) then
215
- prns = [svid || (120..158).to_a].flatten
216
- unless (i = output_options[:system].index{|sys, range| sys == :SBAS}) then
217
+ update_output = proc{|sys_target, prns, labels|
218
+ unless (i = output_options[:system].index{|sys, range| sys == sys_target}) then
217
219
  i = -1
218
- output_options[:system] << [:SBAS, []]
220
+ output_options[:system] << [sys_target, []]
219
221
  else
220
222
  output_options[:system][i].reject!{|prn| prns.include?(prn)}
221
223
  end
222
224
  output_options[:satellites].reject!{|prn, label| prns.include?(prn)}
223
225
  if mode == :include then
224
226
  output_options[:system][i][1] += prns
225
- output_options[:satellites] += prns
227
+ output_options[:satellites] += (labels ? prns.zip(labels) : prns)
226
228
  end
229
+ }
230
+ check_sys_svid = proc{|sys_target, range_in_sys, offset|
231
+ next range_in_sys.include?(svid - (offset || 0)) unless sys # svid is specified without system
232
+ next false unless sys == sys_target
233
+ next true unless svid # All satellites in a target system (svid == nil)
234
+ range_in_sys.include?(svid)
235
+ }
236
+ if check_sys_svid.call(:GPS, 1..32) then
237
+ [svid || (1..32).to_a].flatten.each{|prn| @solver.gps_options.send(mode, prn)}
238
+ elsif check_sys_svid.call(:SBAS, 120..158) then
239
+ prns = [svid || (120..158).to_a].flatten
240
+ update_output.call(:SBAS, prns)
227
241
  prns.each{|prn| @solver.sbas_options.send(mode, prn)}
242
+ elsif check_sys_svid.call(:QZSS, 193..202) then
243
+ [svid || (193..202).to_a].flatten.each{|prn| @solver.gps_options.send(mode, prn)}
228
244
  else
229
- next false
245
+ raise "Unknown satellite: #{spec}"
230
246
  end
231
247
  $stderr.puts "#{mode.capitalize} satellite: #{[sys, svid].compact.join(':')}"
232
248
  }
@@ -235,10 +251,6 @@ class Receiver
235
251
  false
236
252
  }
237
253
  raise "Unknown receiver options: #{options.inspect}" unless options.empty?
238
- proc{|opt|
239
- opt.elevation_mask = 0.0 / 180 * Math::PI # 0 deg
240
- opt.residual_mask = 1E4 # 10 km
241
- }.call(@solver.gps_options)
242
254
  @output = {
243
255
  :pvt => Receiver::pvt_items(output_options),
244
256
  :meas => Receiver::meas_items(output_options),
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GPS_PVT
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gps_pvt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - fenrir(M.Naruoka)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-31 00:00:00.000000000 Z
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -89,6 +89,7 @@ files:
89
89
  - ext/ninja-scan-light/tool/swig/makefile
90
90
  - ext/ninja-scan-light/tool/swig/spec/GPS_spec.rb
91
91
  - ext/ninja-scan-light/tool/swig/spec/SylphideMath_spec.rb
92
+ - gps_pvt.gemspec
92
93
  - lib/gps_pvt.rb
93
94
  - lib/gps_pvt/receiver.rb
94
95
  - lib/gps_pvt/ubx.rb
@@ -114,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  - !ruby/object:Gem::Version
115
116
  version: '0'
116
117
  requirements: []
117
- rubygems_version: 3.0.3
118
+ rubygems_version: 3.3.7
118
119
  signing_key:
119
120
  specification_version: 4
120
121
  summary: GPS position, velocity, and time (PVT) solver