Class: GPS::PVT_minimal
- Inherits:
-
Object
- Object
- GPS::PVT_minimal
- Defined in:
- lib/gps_pvt/pvt.rb
Instance Attribute Summary collapse
-
#hsigma ⇒ Object
Returns the value of attribute hsigma.
-
#pdop ⇒ Object
Returns the value of attribute pdop.
-
#used_satellites ⇒ Object
Returns the value of attribute used_satellites.
-
#vel_sigma ⇒ Object
Returns the value of attribute vel_sigma.
-
#velocity ⇒ Object
Returns the value of attribute velocity.
-
#vsigma ⇒ Object
Returns the value of attribute vsigma.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ PVT_minimal
constructor
A new instance of PVT_minimal.
- #llh ⇒ Object
- #llh=(args) ⇒ Object
-
#position_solved? ⇒ Boolean
unknown.
- #velocity_solved? ⇒ Boolean
- #xyz ⇒ Object
- #xyz=(args) ⇒ Object
Constructor Details
#initialize ⇒ PVT_minimal
Returns a new instance of PVT_minimal.
6 7 8 9 10 11 12 13 14 |
# File 'lib/gps_pvt/pvt.rb', line 6 def initialize # GLOBAL POSITIONING SYSTEM STANDARD POSITIONING SERVICE # PERFORMANCE STANDARD 5th edition (Apr. 2020) 3.8 @hsigma = 8.0 # 95% @vsigma = 13.0 # 95% @pdop = 6.0 # 98% global @vel_sigma = 0.2 # 85% @use_satellites = 0 # unknown end |
Instance Attribute Details
#hsigma ⇒ Object
Returns the value of attribute hsigma.
23 24 25 |
# File 'lib/gps_pvt/pvt.rb', line 23 def hsigma @hsigma end |
#pdop ⇒ Object
Returns the value of attribute pdop.
23 24 25 |
# File 'lib/gps_pvt/pvt.rb', line 23 def pdop @pdop end |
#used_satellites ⇒ Object
Returns the value of attribute used_satellites.
23 24 25 |
# File 'lib/gps_pvt/pvt.rb', line 23 def used_satellites @used_satellites end |
#vel_sigma ⇒ Object
Returns the value of attribute vel_sigma.
23 24 25 |
# File 'lib/gps_pvt/pvt.rb', line 23 def vel_sigma @vel_sigma end |
#velocity ⇒ Object
Returns the value of attribute velocity.
22 23 24 |
# File 'lib/gps_pvt/pvt.rb', line 22 def velocity @velocity end |
#vsigma ⇒ Object
Returns the value of attribute vsigma.
23 24 25 |
# File 'lib/gps_pvt/pvt.rb', line 23 def vsigma @vsigma end |
Class Method Details
.parse_csv(csv_fname, &b) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/gps_pvt/pvt.rb', line 25 def parse_csv(csv_fname, &b) require_relative 'util' $stderr.puts "Reading CSV file (%s) "%[csv_fname] io = open(Util::get_txt(csv_fname), 'r') header = io.readline.chomp.split(/ *, */) idx_table = [ :week, [:tow, /^i?t(?:ime_)?o(?:f_)?w(?:eek)?/], :year, :month, :mday, :hour, :min, [:sec, /^sec/], [:lng, /^(?:long(?:itude)?|lng)/], [:lat, /^lat(?:itude)/], [:alt, /^(?:alt(?:itude)?|h(?:$|eight|_))/], # assumption: [deg], [deg], [m] :x, :y, :z, # ECEF xyz :hsigma, :vsigma, :pdop, [:vn, /^v(?:el)?_?n(?:orth)?/], [:ve, /^v(?:el)?_?e(?:ast)?/], [:vd, /^v(?:el)?_?d(?:own)?/], [:vu, /^v(?:el)?_?u(?:p)?/], :vx, :vy, :vz, # ECEF xyz [:vel_sigma, /^v(?:el)?_sigma/], [:used_satellites, /^(?:used_)?sat(?:ellite)?s/], ].collect{|k, re| re ||= k.to_s idx = header.find_index{|str| re === str} idx && [k, idx] }.compact enum = Enumerator::new{|y| io.each_line{|line| values = line.chomp.split(/ *, */) items = Hash[*(idx_table.collect{|k, idx| v = values[idx] (v == '') ? nil : [k, (Integer(v) rescue Float(v))] }.compact.flatten(1))] if items.include?(:week) then t = GPS::Time::new(items[:week], items[:tow]) else # UTC assumption, thus leap seconds must be added. t = GPS::Time::new([:year, :month, :mday, :hour, :min, :sec].collect{|k| items[k]}) t += GPS::Time::guess_leap_seconds(t) end pvt = GPS::PVT_minimal::new if items.include?(:lat) then pvt.llh = ([:lat, :lng].collect{|k| Math::PI / 180 * items[k]} + [items[:alt]]) elsif items.include?(:xyz) then pvt.xyz = [:x, :y, :z].collect{|k| items[k]} end if items.include?(:vn) then pvt.velocity = ([:vn, :ve].collect{|k| items[k]} + [items[:vu] || -items[:vd]]) elsif items.include?(:vx) then pvt.velocity = Coordinate::ENU::relative_rel( Coordinate::XYZ::new(*([:vx, :vy, :vz].collect{|k| items[k]})), pvt.llh) end [:pdop, :hsigma, :vsigma, :vel_sigma, :used_satellites].each{|k| pvt.send("#{k}=", items[k])} y.yield(t, pvt) } } b ? enum.each{|*res| b.call(*res)} : enum end |
Instance Method Details
#llh ⇒ Object
18 |
# File 'lib/gps_pvt/pvt.rb', line 18 def llh; @xyz ? @xyz.llh : @llh; end |
#llh=(args) ⇒ Object
20 |
# File 'lib/gps_pvt/pvt.rb', line 20 def llh=(args); @llh = Coordinate::LLH::new(*args); end |
#position_solved? ⇒ Boolean
unknown
15 |
# File 'lib/gps_pvt/pvt.rb', line 15 def position_solved?; @xyz || @llh; end |
#velocity_solved? ⇒ Boolean
16 |
# File 'lib/gps_pvt/pvt.rb', line 16 def velocity_solved?; @velocity; end |
#xyz ⇒ Object
17 |
# File 'lib/gps_pvt/pvt.rb', line 17 def xyz; @xyz || @llh.xyz; end |
#xyz=(args) ⇒ Object
19 |
# File 'lib/gps_pvt/pvt.rb', line 19 def xyz=(args); @xyz = Coordinate::XYZ::new(*args); end |