gps_pvt 0.1.1 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +117 -86
- data/Rakefile +85 -85
- data/exe/gps_pvt +46 -0
- data/ext/gps_pvt/Coordinate/Coordinate_wrap.cxx +6613 -6613
- data/ext/gps_pvt/GPS/GPS_wrap.cxx +16029 -16019
- data/ext/gps_pvt/SylphideMath/SylphideMath_wrap.cxx +21050 -21050
- data/ext/gps_pvt/extconf.rb +70 -70
- data/ext/ninja-scan-light/tool/swig/GPS.i +20 -9
- data/gps_pvt.gemspec +57 -57
- data/lib/gps_pvt/receiver.rb +353 -375
- data/lib/gps_pvt/ubx.rb +147 -147
- data/lib/gps_pvt/version.rb +5 -5
- data/lib/gps_pvt.rb +9 -9
- data/sig/gps_pvt.rbs +4 -4
- metadata +6 -4
data/lib/gps_pvt/ubx.rb
CHANGED
@@ -1,148 +1,148 @@
|
|
1
|
-
# U-blox file utilities
|
2
|
-
# The origin is ninja-scan-light/tool/misc/ubx.rb
|
3
|
-
|
4
|
-
# Copyright (c) 2016, M.Naruoka (fenrir)
|
5
|
-
# All rights reserved.
|
6
|
-
#
|
7
|
-
# Redistribution and use in source and binary forms, with or without modification,
|
8
|
-
# are permitted provided that the following conditions are met:
|
9
|
-
#
|
10
|
-
# - Redistributions of source code must retain the above copyright notice,
|
11
|
-
# this list of conditions and the following disclaimer.
|
12
|
-
# - Redistributions in binary form must reproduce the above copyright notice,
|
13
|
-
# this list of conditions and the following disclaimer in the documentation
|
14
|
-
# and/or other materials provided with the distribution.
|
15
|
-
# - Neither the name of the naruoka.org nor the names of its contributors
|
16
|
-
# may be used to endorse or promote products derived from this software
|
17
|
-
# without specific prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
21
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
23
|
-
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
-
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
25
|
-
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
26
|
-
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
27
|
-
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
28
|
-
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
30
|
-
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
|
32
|
-
module GPS_PVT
|
33
|
-
class UBX
|
34
|
-
def initialize(io)
|
35
|
-
@io = io
|
36
|
-
@buf = []
|
37
|
-
end
|
38
|
-
def UBX.checksum(packet, range = 2..-3)
|
39
|
-
ck_a, ck_b = [0, 0]
|
40
|
-
packet[range].each{|b|
|
41
|
-
ck_a += b
|
42
|
-
ck_b += ck_a
|
43
|
-
}
|
44
|
-
ck_a &= 0xFF
|
45
|
-
ck_b &= 0xFF
|
46
|
-
[ck_a, ck_b]
|
47
|
-
end
|
48
|
-
def UBX.update_checksum(packet)
|
49
|
-
packet[-2..-1] = checksum(packet)
|
50
|
-
packet
|
51
|
-
end
|
52
|
-
def UBX.update_size(packet, size = nil)
|
53
|
-
size ||= packet.size - 8
|
54
|
-
size = size.divmod(0x100)
|
55
|
-
packet[4] = size[1]
|
56
|
-
packet[5] = size[0]
|
57
|
-
packet
|
58
|
-
end
|
59
|
-
def UBX.update(packet)
|
60
|
-
[:update_size, :update_checksum].inject(packet){|arg, f|
|
61
|
-
UBX.send(f, arg)
|
62
|
-
}
|
63
|
-
end
|
64
|
-
def read_packet
|
65
|
-
while !@io.eof?
|
66
|
-
if @buf.size < 8 then
|
67
|
-
@buf += @io.read(8 - @buf.size).unpack('C*')
|
68
|
-
return nil if @buf.size < 8
|
69
|
-
end
|
70
|
-
|
71
|
-
if @buf[0] != 0xB5 then
|
72
|
-
@buf.shift
|
73
|
-
next
|
74
|
-
elsif @buf[1] != 0x62 then
|
75
|
-
@buf = @buf[2..-1]
|
76
|
-
next
|
77
|
-
end
|
78
|
-
|
79
|
-
len = (@buf[5] << 8) + @buf[4]
|
80
|
-
if @buf.size < len + 8 then
|
81
|
-
@buf += @io.read(len + 8 - @buf.size).unpack('C*')
|
82
|
-
return nil if @buf.size < len + 8
|
83
|
-
end
|
84
|
-
|
85
|
-
ck_a, ck_b = UBX::checksum(@buf, 2..(len + 5))
|
86
|
-
if (@buf[len + 6] != ck_a) || (@buf[len + 7] != ck_b) then
|
87
|
-
@buf = @buf[2..-1]
|
88
|
-
next
|
89
|
-
end
|
90
|
-
|
91
|
-
packet = @buf[0..(len + 7)]
|
92
|
-
@buf = @buf[(len + 8)..-1]
|
93
|
-
|
94
|
-
return packet
|
95
|
-
end
|
96
|
-
return nil
|
97
|
-
end
|
98
|
-
|
99
|
-
def each_packet(&b)
|
100
|
-
res = Enumerator::new{|y|
|
101
|
-
while packet = read_packet
|
102
|
-
y << packet
|
103
|
-
end
|
104
|
-
}
|
105
|
-
b ? res.each(&b) : res
|
106
|
-
end
|
107
|
-
|
108
|
-
def read_packets
|
109
|
-
each_packet.to_a
|
110
|
-
end
|
111
|
-
|
112
|
-
GNSS_ID = {
|
113
|
-
:GPS => 0,
|
114
|
-
:SBAS => 1,
|
115
|
-
:Galileo => 2,
|
116
|
-
:BeiDou => 3,
|
117
|
-
:QZSS => 5,
|
118
|
-
:GLONASS => 6,
|
119
|
-
}
|
120
|
-
|
121
|
-
SIGNAL_ID = {
|
122
|
-
:GPS => {:L1CA => 0, :L2CL => 3, :L2CM => 4},
|
123
|
-
:SBAS => {:L1CA => 0},
|
124
|
-
:Galileo => {:E1C => 0, :E1B => 1, :E5_bI => 5, :E5_bQ => 6},
|
125
|
-
:BeiDou => {:B1I_D1 => 0, :B1I_D2 => 1, :B2I_D1 => 2, :B2I_D2 => 3},
|
126
|
-
:QZSS => {:L1CA => 0, :L2CL => 4, :L2CM => 5},
|
127
|
-
:GLONASS => {:L1OF => 0, :L2OF => 2},
|
128
|
-
}
|
129
|
-
|
130
|
-
def UBX.svid(id, gnss = :GPS)
|
131
|
-
gnss = GNSS_ID[gnss] if gnss.kind_of?(Symbol)
|
132
|
-
case gnss
|
133
|
-
when GNSS_ID[:GPS], GNSS_ID[:SBAS]
|
134
|
-
id
|
135
|
-
when GNSS_ID[:Galileo]
|
136
|
-
id + 210
|
137
|
-
when GNSS_ID[:Beido]
|
138
|
-
(id < 6) ? (id + 158) : (id + 27)
|
139
|
-
when GNSS_ID[:QZSS]
|
140
|
-
id + 192
|
141
|
-
when GNSS_ID[:GLONASS]
|
142
|
-
id + 64
|
143
|
-
else
|
144
|
-
nil
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
1
|
+
# U-blox file utilities
|
2
|
+
# The origin is ninja-scan-light/tool/misc/ubx.rb
|
3
|
+
|
4
|
+
# Copyright (c) 2016, M.Naruoka (fenrir)
|
5
|
+
# All rights reserved.
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
8
|
+
# are permitted provided that the following conditions are met:
|
9
|
+
#
|
10
|
+
# - Redistributions of source code must retain the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer.
|
12
|
+
# - Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
# this list of conditions and the following disclaimer in the documentation
|
14
|
+
# and/or other materials provided with the distribution.
|
15
|
+
# - Neither the name of the naruoka.org nor the names of its contributors
|
16
|
+
# may be used to endorse or promote products derived from this software
|
17
|
+
# without specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
21
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
23
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
+
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
25
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
26
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
27
|
+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
28
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
30
|
+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
|
32
|
+
module GPS_PVT
|
33
|
+
class UBX
|
34
|
+
def initialize(io)
|
35
|
+
@io = io
|
36
|
+
@buf = []
|
37
|
+
end
|
38
|
+
def UBX.checksum(packet, range = 2..-3)
|
39
|
+
ck_a, ck_b = [0, 0]
|
40
|
+
packet[range].each{|b|
|
41
|
+
ck_a += b
|
42
|
+
ck_b += ck_a
|
43
|
+
}
|
44
|
+
ck_a &= 0xFF
|
45
|
+
ck_b &= 0xFF
|
46
|
+
[ck_a, ck_b]
|
47
|
+
end
|
48
|
+
def UBX.update_checksum(packet)
|
49
|
+
packet[-2..-1] = checksum(packet)
|
50
|
+
packet
|
51
|
+
end
|
52
|
+
def UBX.update_size(packet, size = nil)
|
53
|
+
size ||= packet.size - 8
|
54
|
+
size = size.divmod(0x100)
|
55
|
+
packet[4] = size[1]
|
56
|
+
packet[5] = size[0]
|
57
|
+
packet
|
58
|
+
end
|
59
|
+
def UBX.update(packet)
|
60
|
+
[:update_size, :update_checksum].inject(packet){|arg, f|
|
61
|
+
UBX.send(f, arg)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
def read_packet
|
65
|
+
while !@io.eof?
|
66
|
+
if @buf.size < 8 then
|
67
|
+
@buf += @io.read(8 - @buf.size).unpack('C*')
|
68
|
+
return nil if @buf.size < 8
|
69
|
+
end
|
70
|
+
|
71
|
+
if @buf[0] != 0xB5 then
|
72
|
+
@buf.shift
|
73
|
+
next
|
74
|
+
elsif @buf[1] != 0x62 then
|
75
|
+
@buf = @buf[2..-1]
|
76
|
+
next
|
77
|
+
end
|
78
|
+
|
79
|
+
len = (@buf[5] << 8) + @buf[4]
|
80
|
+
if @buf.size < len + 8 then
|
81
|
+
@buf += @io.read(len + 8 - @buf.size).unpack('C*')
|
82
|
+
return nil if @buf.size < len + 8
|
83
|
+
end
|
84
|
+
|
85
|
+
ck_a, ck_b = UBX::checksum(@buf, 2..(len + 5))
|
86
|
+
if (@buf[len + 6] != ck_a) || (@buf[len + 7] != ck_b) then
|
87
|
+
@buf = @buf[2..-1]
|
88
|
+
next
|
89
|
+
end
|
90
|
+
|
91
|
+
packet = @buf[0..(len + 7)]
|
92
|
+
@buf = @buf[(len + 8)..-1]
|
93
|
+
|
94
|
+
return packet
|
95
|
+
end
|
96
|
+
return nil
|
97
|
+
end
|
98
|
+
|
99
|
+
def each_packet(&b)
|
100
|
+
res = Enumerator::new{|y|
|
101
|
+
while packet = read_packet
|
102
|
+
y << packet
|
103
|
+
end
|
104
|
+
}
|
105
|
+
b ? res.each(&b) : res
|
106
|
+
end
|
107
|
+
|
108
|
+
def read_packets
|
109
|
+
each_packet.to_a
|
110
|
+
end
|
111
|
+
|
112
|
+
GNSS_ID = {
|
113
|
+
:GPS => 0,
|
114
|
+
:SBAS => 1,
|
115
|
+
:Galileo => 2,
|
116
|
+
:BeiDou => 3,
|
117
|
+
:QZSS => 5,
|
118
|
+
:GLONASS => 6,
|
119
|
+
}
|
120
|
+
|
121
|
+
SIGNAL_ID = {
|
122
|
+
:GPS => {:L1CA => 0, :L2CL => 3, :L2CM => 4},
|
123
|
+
:SBAS => {:L1CA => 0},
|
124
|
+
:Galileo => {:E1C => 0, :E1B => 1, :E5_bI => 5, :E5_bQ => 6},
|
125
|
+
:BeiDou => {:B1I_D1 => 0, :B1I_D2 => 1, :B2I_D1 => 2, :B2I_D2 => 3},
|
126
|
+
:QZSS => {:L1CA => 0, :L2CL => 4, :L2CM => 5},
|
127
|
+
:GLONASS => {:L1OF => 0, :L2OF => 2},
|
128
|
+
}
|
129
|
+
|
130
|
+
def UBX.svid(id, gnss = :GPS)
|
131
|
+
gnss = GNSS_ID[gnss] if gnss.kind_of?(Symbol)
|
132
|
+
case gnss
|
133
|
+
when GNSS_ID[:GPS], GNSS_ID[:SBAS]
|
134
|
+
id
|
135
|
+
when GNSS_ID[:Galileo]
|
136
|
+
id + 210
|
137
|
+
when GNSS_ID[:Beido]
|
138
|
+
(id < 6) ? (id + 158) : (id + 27)
|
139
|
+
when GNSS_ID[:QZSS]
|
140
|
+
id + 192
|
141
|
+
when GNSS_ID[:GLONASS]
|
142
|
+
id + 64
|
143
|
+
else
|
144
|
+
nil
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
148
|
end
|
data/lib/gps_pvt/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GPS_PVT
|
4
|
-
VERSION = "0.1.
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GPS_PVT
|
4
|
+
VERSION = "0.1.5"
|
5
|
+
end
|
data/lib/gps_pvt.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "gps_pvt/version"
|
4
|
-
require_relative "gps_pvt/receiver"
|
5
|
-
|
6
|
-
module GPS_PVT
|
7
|
-
class Error < StandardError; end
|
8
|
-
# Your code goes here...
|
9
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "gps_pvt/version"
|
4
|
+
require_relative "gps_pvt/receiver"
|
5
|
+
|
6
|
+
module GPS_PVT
|
7
|
+
class Error < StandardError; end
|
8
|
+
# Your code goes here...
|
9
|
+
end
|
data/sig/gps_pvt.rbs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module GpsPvt
|
2
|
-
VERSION: String
|
3
|
-
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
|
4
|
-
end
|
1
|
+
module GpsPvt
|
2
|
+
VERSION: String
|
3
|
+
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
|
4
|
+
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.1.
|
4
|
+
version: 0.1.5
|
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: 2021-12-
|
11
|
+
date: 2021-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -42,7 +42,8 @@ description: This module calculate PVT by using raw observation obtained from a
|
|
42
42
|
receiver
|
43
43
|
email:
|
44
44
|
- fenrir.naru@gmail.com
|
45
|
-
executables:
|
45
|
+
executables:
|
46
|
+
- gps_pvt
|
46
47
|
extensions:
|
47
48
|
- ext/gps_pvt/extconf.rb
|
48
49
|
extra_rdoc_files: []
|
@@ -55,6 +56,7 @@ files:
|
|
55
56
|
- Rakefile
|
56
57
|
- bin/console
|
57
58
|
- bin/setup
|
59
|
+
- exe/gps_pvt
|
58
60
|
- ext/gps_pvt/Coordinate/Coordinate_wrap.cxx
|
59
61
|
- ext/gps_pvt/GPS/GPS_wrap.cxx
|
60
62
|
- ext/gps_pvt/SylphideMath/SylphideMath_wrap.cxx
|
@@ -103,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
105
|
requirements:
|
104
106
|
- - ">="
|
105
107
|
- !ruby/object:Gem::Version
|
106
|
-
version: 2.
|
108
|
+
version: 2.3.0
|
107
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
110
|
requirements:
|
109
111
|
- - ">="
|