sgslib 1.6.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sgs/bearing.rb +1 -1
- data/lib/sgs/location.rb +4 -3
- data/lib/sgs/mission.rb +6 -2
- data/lib/sgs/navigate.rb +2 -0
- data/lib/sgs/nmea.rb +1 -1
- data/lib/sgs/otto.rb +12 -5
- data/lib/sgs/redis_base.rb +2 -2
- data/lib/sgs/version.rb +1 -1
- data/lib/sgs/waypoint.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bdbf4fe47373b9771e9727d8a259d5ddfb545ee64ef51a3fb4b569d4d4e3e1f
|
4
|
+
data.tar.gz: 5664da38c87316350e921af2432f81079732f1942b8fd9896bb59107ea1e49f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10336b0228e40cd9b86e51206d4c0f33bdbe0a456ae6ab99de6e0cc57b2cff569f459f0fb94d0658bea9e248da8cd2eec874fafa8fa0bc14e6b25f1cb45818e2
|
7
|
+
data.tar.gz: a358fd0c6a7eb67c091d857428a70c2ad738c2f98658cc1d7daf60b0dc83e8623e37c5bb2df4ed7c27de65928c20809d943a2f2263b5e5a8cd2db78e835c0e2c
|
data/lib/sgs/bearing.rb
CHANGED
@@ -113,7 +113,7 @@ module SGS
|
|
113
113
|
# This code was derived from formulae on the Movable Type site:
|
114
114
|
# http://www.movable-type.co.uk/scripts/latlong.html
|
115
115
|
#
|
116
|
-
# var d = Math.acos(Math.sin(lat1)*Math.sin(lat2) +
|
116
|
+
# var d = Math.acos(Math.sin(lat1)*Math.sin(lat2) +
|
117
117
|
# Math.cos(lat1)*Math.cos(lat2) *
|
118
118
|
# Math.cos(lon2-lon1)) * R;
|
119
119
|
# var y = Math.sin(dLon) * Math.cos(lat2);
|
data/lib/sgs/location.rb
CHANGED
@@ -75,9 +75,9 @@ module SGS
|
|
75
75
|
# This code was derived from formulae on the Movable Type site:
|
76
76
|
# http://www.movable-type.co.uk/scripts/latlong.html
|
77
77
|
#
|
78
|
-
# var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) +
|
78
|
+
# var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) +
|
79
79
|
# Math.cos(lat1)*Math.sin(d/R)*Math.cos(angle) );
|
80
|
-
# var lon2 = lon1 + Math.atan2(Math.sin(angle)*Math.sin(d/R)*Math.cos(lat1),
|
80
|
+
# var lon2 = lon1 + Math.atan2(Math.sin(angle)*Math.sin(d/R)*Math.cos(lat1),
|
81
81
|
# Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));
|
82
82
|
def +(bearing)
|
83
83
|
loc = Location.new
|
@@ -144,7 +144,7 @@ module SGS
|
|
144
144
|
#
|
145
145
|
# Is this location valid?
|
146
146
|
def valid?
|
147
|
-
|
147
|
+
!@latitude.nil? and !@longitude.nil?
|
148
148
|
end
|
149
149
|
|
150
150
|
#
|
@@ -227,6 +227,7 @@ module SGS
|
|
227
227
|
# Can also strip out the special degrees unicode, as well as
|
228
228
|
# single and double quotes.
|
229
229
|
def _ll_parse(arg, nsew)
|
230
|
+
return arg.to_f if arg.kind_of? Float or arg.kind_of? Integer
|
230
231
|
str = arg.chomp.gsub /[\u00B0'"]/, ' '
|
231
232
|
if str[-1].upcase =~ /[#{nsew}]/
|
232
233
|
sign = (str[-1].upcase == nsew[1]) ? -1 : 1
|
data/lib/sgs/mission.rb
CHANGED
@@ -126,7 +126,8 @@ module SGS
|
|
126
126
|
@description = data["description"]
|
127
127
|
if data["launch"]
|
128
128
|
@launch_site = data["launch"]["site"] || "Launch Site"
|
129
|
-
@launch_location = Location.
|
129
|
+
@launch_location = Location.new
|
130
|
+
@launch_location.parse_hash data["launch"]
|
130
131
|
end
|
131
132
|
if data["attractors"]
|
132
133
|
data["attractors"].each do |waypt_data|
|
@@ -165,7 +166,10 @@ module SGS
|
|
165
166
|
hash["attractors"] << waypt.to_hash
|
166
167
|
end
|
167
168
|
hash["repellors"] = []
|
168
|
-
|
169
|
+
@repellors.each do |waypt|
|
170
|
+
hash["repellors"] << waypt.to_hash
|
171
|
+
end
|
172
|
+
return hash
|
169
173
|
end
|
170
174
|
end
|
171
175
|
end
|
data/lib/sgs/navigate.rb
CHANGED
data/lib/sgs/nmea.rb
CHANGED
data/lib/sgs/otto.rb
CHANGED
@@ -69,7 +69,16 @@ module SGS
|
|
69
69
|
MAX_AWA_REGISTER = 11
|
70
70
|
WAKE_DURATION_REGISTER = 12
|
71
71
|
NEXT_WAKEUP_REGISTER = 13
|
72
|
-
|
72
|
+
RUDDER_PID_P = 14
|
73
|
+
RUDDER_PID_I = 15
|
74
|
+
RUDDER_PID_D = 16
|
75
|
+
RUDDER_PID_E_NUM = 17
|
76
|
+
RUDDER_PID_E_DEN = 18
|
77
|
+
RUDDER_PID_U_DIV = 19
|
78
|
+
SAIL_MXC_M_VALUE = 20
|
79
|
+
SAIL_MXC_C_VALUE = 21
|
80
|
+
SAIL_MXC_U_DIV = 22
|
81
|
+
MAX_REGISTER = 23
|
73
82
|
|
74
83
|
#
|
75
84
|
# This is different from mission mode. This mode defines how Otto should
|
@@ -103,7 +112,7 @@ module SGS
|
|
103
112
|
|
104
113
|
#
|
105
114
|
# Set up some useful defaults. We assume rudder goes from 0 to 255 as does
|
106
|
-
# the sail angle.
|
115
|
+
# the sail angle.
|
107
116
|
def initialize
|
108
117
|
serial_port = nil
|
109
118
|
#
|
@@ -246,8 +255,6 @@ module SGS
|
|
246
255
|
cmd = "R%d=%X\r\n" % params
|
247
256
|
puts "Command: #{cmd}"
|
248
257
|
@serial_port.write cmd
|
249
|
-
puts "> Sending command: #{str}"
|
250
|
-
@serial_port.puts "#{str}"
|
251
258
|
end
|
252
259
|
end
|
253
260
|
|
@@ -285,7 +292,7 @@ module SGS
|
|
285
292
|
# representing the elapsed seconds since Otto restarted.
|
286
293
|
def parse_tstamp(tstamp)
|
287
294
|
newval = tstamp.to_i(16)
|
288
|
-
if newval < @otto_timestamp
|
295
|
+
if @otto_timestamp.nil? or newval < @otto_timestamp
|
289
296
|
puts "ALARM! Otto rebooted (or something)..."
|
290
297
|
end
|
291
298
|
@otto_timestamp = newval
|
data/lib/sgs/redis_base.rb
CHANGED
@@ -96,7 +96,7 @@ module SGS
|
|
96
96
|
# It's an array - iterate and read the values.
|
97
97
|
lval.size.times do |idx|
|
98
98
|
idx_val = lval[idx]
|
99
|
-
lval[idx] = redis_read_var var, idx_val.class, :idx => idx
|
99
|
+
lval[idx] = redis_read_var var, idx_val.class, :idx => idx
|
100
100
|
end
|
101
101
|
elsif lval.kind_of? Location
|
102
102
|
#
|
@@ -206,7 +206,7 @@ module SGS
|
|
206
206
|
case
|
207
207
|
when klass == Time
|
208
208
|
redis_val = Time.at(redis_val.to_f).gmtime
|
209
|
-
when klass ==
|
209
|
+
when klass == Integer
|
210
210
|
redis_val = redis_val.to_i
|
211
211
|
when klass == Float
|
212
212
|
redis_val = redis_val.to_f
|
data/lib/sgs/version.rb
CHANGED
data/lib/sgs/waypoint.rb
CHANGED
@@ -58,7 +58,8 @@ module SGS
|
|
58
58
|
def parse(data)
|
59
59
|
@@count += 1
|
60
60
|
@name = data["name"] || "Waypoint ##{@@count}"
|
61
|
-
@location = Location.
|
61
|
+
@location = Location.new
|
62
|
+
@location.parse_hash(data)
|
62
63
|
@normal = data["normal"] || 0.0
|
63
64
|
@range = data["range"] || 0.1
|
64
65
|
end
|
@@ -136,7 +137,7 @@ module SGS
|
|
136
137
|
hash["name"] = @name
|
137
138
|
hash["normal"] = @normal
|
138
139
|
hash["range"] = @range
|
139
|
-
hash
|
140
|
+
return hash
|
140
141
|
end
|
141
142
|
|
142
143
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sgslib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dermot Tynan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|