sgslib 0.3.1 → 1.5.0
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 +4 -4
- data/LICENSE +24 -17
- data/README.md +43 -7
- data/Rakefile +2 -2
- data/bin/console +34 -1
- data/exe/sgs_alarm +41 -0
- data/exe/sgs_diag +41 -0
- data/exe/sgs_gpsread +42 -0
- data/exe/sgs_logger +45 -0
- data/exe/sgs_mission +45 -0
- data/exe/sgs_nav +43 -0
- data/exe/sgs_otto +46 -0
- data/exe/sgs_report +44 -0
- data/lib/sgs/alarm.rb +55 -23
- data/lib/sgs/bearing.rb +150 -0
- data/lib/sgs/config.rb +35 -24
- data/lib/sgs/course.rb +29 -24
- data/lib/sgs/diagnostics.rb +49 -0
- data/lib/sgs/gps.rb +37 -21
- data/lib/sgs/location.rb +58 -159
- data/lib/sgs/logger.rb +35 -82
- data/lib/sgs/mission.rb +96 -173
- data/lib/sgs/mission_status.rb +128 -0
- data/lib/sgs/navigate.rb +37 -21
- data/lib/sgs/nmea.rb +32 -22
- data/lib/sgs/otto.rb +37 -21
- data/lib/sgs/redis_base.rb +32 -24
- data/lib/sgs/report.rb +49 -0
- data/lib/sgs/rpc.rb +29 -21
- data/lib/sgs/timing.rb +32 -24
- data/lib/sgs/version.rb +35 -1
- data/lib/sgs/waypoint.rb +69 -33
- data/lib/sgslib.rb +40 -24
- data/sgslib.gemspec +15 -5
- metadata +61 -19
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.travis.yml +0 -4
- data/CODE_OF_CONDUCT.md +0 -49
- data/bin/setup +0 -8
data/lib/sgs/otto.rb
CHANGED
@@ -1,28 +1,36 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2013, Kalopa
|
3
|
-
#
|
4
|
-
# GNU General Public License as published by the Free Software Foundation;
|
5
|
-
# either version 2, or (at your option) any later version.
|
2
|
+
# Copyright (c) 2013-2023, Kalopa Robotics Limited. All rights
|
3
|
+
# reserved.
|
6
4
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
5
|
+
# This program is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 2 of
|
8
|
+
# the License, or (at your option) any later version.
|
11
9
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
15
14
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301, USA.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA ROBOTICS LIMITED "AS IS" AND
|
21
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
22
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
23
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KALOPA
|
24
|
+
# ROBOTICS LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
27
|
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
29
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
31
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# ABSTRACT
|
26
34
|
#
|
27
35
|
|
28
36
|
##
|
@@ -66,6 +74,14 @@ module SGS
|
|
66
74
|
super
|
67
75
|
end
|
68
76
|
|
77
|
+
#
|
78
|
+
# Main daemon function (called from executable)
|
79
|
+
def self.daemon
|
80
|
+
loop do
|
81
|
+
sleep 300
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
69
85
|
#
|
70
86
|
# Set the required rudder angle. Input values range from +/- 40.0 degrees
|
71
87
|
def rudder=(val)
|
data/lib/sgs/redis_base.rb
CHANGED
@@ -1,28 +1,36 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2013, Kalopa
|
3
|
-
#
|
4
|
-
# GNU General Public License as published by the Free Software Foundation;
|
5
|
-
# either version 2, or (at your option) any later version.
|
2
|
+
# Copyright (c) 2013-2023, Kalopa Robotics Limited. All rights
|
3
|
+
# reserved.
|
6
4
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
5
|
+
# This program is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 2 of
|
8
|
+
# the License, or (at your option) any later version.
|
11
9
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
15
14
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301, USA.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA ROBOTICS LIMITED "AS IS" AND
|
21
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
22
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
23
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KALOPA
|
24
|
+
# ROBOTICS LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
27
|
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
29
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
31
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# ABSTRACT
|
26
34
|
#
|
27
35
|
|
28
36
|
##
|
@@ -133,11 +141,11 @@ module SGS
|
|
133
141
|
#
|
134
142
|
# Inside a multi-block, set all the variables and increment
|
135
143
|
# the count.
|
136
|
-
SGS::RedisBase.redis.multi do
|
144
|
+
SGS::RedisBase.redis.multi do |pipeline|
|
137
145
|
var_list.each do |key, value|
|
138
|
-
|
146
|
+
pipeline.set key, value
|
139
147
|
end
|
140
|
-
|
148
|
+
pipeline.incr count_name
|
141
149
|
end
|
142
150
|
true
|
143
151
|
end
|
data/lib/sgs/report.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013-2023, Kalopa Robotics Limited. All rights
|
3
|
+
# reserved.
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 2 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301, USA.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA ROBOTICS LIMITED "AS IS" AND
|
21
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
22
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
23
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KALOPA
|
24
|
+
# ROBOTICS LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
27
|
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
29
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
31
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# ABSTRACT
|
34
|
+
#
|
35
|
+
|
36
|
+
##
|
37
|
+
# Routines for handling sailboat navigation and route planning.
|
38
|
+
#
|
39
|
+
module SGS
|
40
|
+
class Report < RedisBase
|
41
|
+
#
|
42
|
+
# Main daemon function (called from executable)
|
43
|
+
def self.daemon
|
44
|
+
loop do
|
45
|
+
sleep 300
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/sgs/rpc.rb
CHANGED
@@ -1,28 +1,36 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2018, Kalopa
|
3
|
-
#
|
4
|
-
# GNU General Public License as published by the Free Software Foundation;
|
5
|
-
# either version 2, or (at your option) any later version.
|
2
|
+
# Copyright (c) 2018-2023, Kalopa Robotics Limited. All rights
|
3
|
+
# reserved.
|
6
4
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
5
|
+
# This program is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 2 of
|
8
|
+
# the License, or (at your option) any later version.
|
11
9
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
15
14
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301, USA.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA ROBOTICS LIMITED "AS IS" AND
|
21
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
22
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
23
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KALOPA
|
24
|
+
# ROBOTICS LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
27
|
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
29
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
31
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# ABSTRACT
|
26
34
|
#
|
27
35
|
|
28
36
|
##
|
data/lib/sgs/timing.rb
CHANGED
@@ -1,28 +1,36 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2013, Kalopa
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
2
|
+
# Copyright (c) 2013-2023, Kalopa Robotics Limited. All rights
|
3
|
+
# reserved.
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 2 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301, USA.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA ROBOTICS LIMITED "AS IS" AND
|
21
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
22
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
23
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KALOPA
|
24
|
+
# ROBOTICS LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
27
|
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
29
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
31
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# ABSTRACT
|
26
34
|
#
|
27
35
|
|
28
36
|
##
|
data/lib/sgs/version.rb
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013-2023, Kalopa Robotics Limited. All rights
|
3
|
+
# reserved.
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 2 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301, USA.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA ROBOTICS LIMITED "AS IS" AND
|
21
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
22
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
23
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KALOPA
|
24
|
+
# ROBOTICS LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
27
|
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
29
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
31
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# ABSTRACT
|
34
|
+
#
|
1
35
|
module SGS
|
2
|
-
VERSION = "
|
36
|
+
VERSION = "1.5.0"
|
3
37
|
end
|
data/lib/sgs/waypoint.rb
CHANGED
@@ -1,54 +1,80 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2013, Kalopa
|
3
|
-
#
|
4
|
-
# GNU General Public License as published by the Free Software Foundation;
|
5
|
-
# either version 2, or (at your option) any later version.
|
2
|
+
# Copyright (c) 2013-2023, Kalopa Robotics Limited. All rights
|
3
|
+
# reserved.
|
6
4
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
5
|
+
# This program is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 2 of
|
8
|
+
# the License, or (at your option) any later version.
|
11
9
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
15
14
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301, USA.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA ROBOTICS LIMITED "AS IS" AND
|
21
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
22
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
23
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KALOPA
|
24
|
+
# ROBOTICS LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
27
|
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
29
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
31
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# ABSTRACT
|
26
34
|
#
|
27
35
|
|
28
36
|
##
|
29
37
|
# Routines for handling sailboat navigation and route planning.
|
30
38
|
#
|
31
|
-
require 'date'
|
32
|
-
|
33
39
|
module SGS
|
34
40
|
#
|
35
41
|
# Waypoint, Attractor, and Repellor definitions
|
36
42
|
class Waypoint < RedisBase
|
37
|
-
attr_accessor :location, :normal, :
|
43
|
+
attr_accessor :location, :normal, :range, :name, :attractor
|
38
44
|
attr_reader :bearing, :distance
|
39
45
|
|
46
|
+
@@count = 0
|
47
|
+
|
48
|
+
#
|
49
|
+
# Parse a waypoint from a hash. Uses the instance method to do the work.
|
50
|
+
def self.parse(data)
|
51
|
+
waypt = new
|
52
|
+
waypt.parse(data)
|
53
|
+
waypt
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# Parse the waypoint data and save it
|
58
|
+
def parse(data)
|
59
|
+
@@count += 1
|
60
|
+
@name = data["name"] || "Waypoint ##{@@count}"
|
61
|
+
@location = SGS::Location.parse(data)
|
62
|
+
@normal = data["normal"] || 0.0
|
63
|
+
@range = data["range"] || 0.1
|
64
|
+
end
|
65
|
+
|
40
66
|
#
|
41
67
|
# Define a new Attractor or Repellor, based on certain parameters.
|
42
68
|
# The location is the centre of the waypoint. The normal is the compass
|
43
|
-
# angle of the start of the semicircle, and the
|
69
|
+
# angle of the start of the semicircle, and the range is the size of
|
44
70
|
# the arc. You can specify an optional name for the waypoint and also
|
45
71
|
# indicate if we should be attracted or repelled by it.
|
46
|
-
def initialize(location = nil, normal = 0.0,
|
72
|
+
def initialize(location = nil, normal = 0.0, range = 0.1, name = "", attractor = true)
|
47
73
|
@location = location || Location.new
|
48
74
|
@normal = normal
|
49
|
-
@
|
75
|
+
@range = range
|
50
76
|
@name = name
|
51
|
-
@
|
77
|
+
@attractor = attractor
|
52
78
|
@bearing = nil
|
53
79
|
@distance = 0
|
54
80
|
end
|
@@ -66,8 +92,8 @@ module SGS
|
|
66
92
|
d = Bearing.new(@bearing.back_angle - @normal, @bearing.distance)
|
67
93
|
# A chord angle of 0 gives a semicircle from 0 to 180 degrees. If our
|
68
94
|
# approach angle is within range, then reduce our distance to the mark
|
69
|
-
# by the chord distance (
|
70
|
-
@distance -= @
|
95
|
+
# by the chord distance (range).
|
96
|
+
@distance -= @range if d.angle >= 0.0 and d.angle < Math::PI
|
71
97
|
@distance = 0.0 if @distance < 0.0
|
72
98
|
@distance
|
73
99
|
end
|
@@ -75,13 +101,13 @@ module SGS
|
|
75
101
|
#
|
76
102
|
# Is this an attractor?
|
77
103
|
def attractor?
|
78
|
-
@
|
104
|
+
@attractor == true
|
79
105
|
end
|
80
106
|
|
81
107
|
#
|
82
108
|
# Is this a repellor?
|
83
109
|
def repellor?
|
84
|
-
@
|
110
|
+
@attractor == true
|
85
111
|
end
|
86
112
|
|
87
113
|
#
|
@@ -103,10 +129,20 @@ module SGS
|
|
103
129
|
@normal = Bearing.dtor val
|
104
130
|
end
|
105
131
|
|
132
|
+
#
|
133
|
+
# Convert to a hash
|
134
|
+
def to_hash
|
135
|
+
hash = @location.to_hash
|
136
|
+
hash["name"] = @name
|
137
|
+
hash["normal"] = @normal
|
138
|
+
hash["range"] = @range
|
139
|
+
hash
|
140
|
+
end
|
141
|
+
|
106
142
|
#
|
107
143
|
# Pretty version of the waypoint.
|
108
144
|
def to_s
|
109
|
-
"'#{@name}' at #{@location} => #{normal_d}%#{@
|
145
|
+
"'#{@name}' at #{@location} => #{normal_d}%#{@range}"
|
110
146
|
end
|
111
147
|
|
112
148
|
#
|
data/lib/sgslib.rb
CHANGED
@@ -1,37 +1,51 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2013, Kalopa
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
2
|
+
# Copyright (c) 2013-2023, Kalopa Robotics Limited. All rights
|
3
|
+
# reserved.
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 2 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301, USA.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA ROBOTICS LIMITED "AS IS" AND
|
21
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
22
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
23
|
+
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KALOPA
|
24
|
+
# ROBOTICS LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
27
|
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
29
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
31
|
+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
33
|
+
# ABSTRACT
|
26
34
|
#
|
27
35
|
|
28
36
|
##
|
29
37
|
#
|
38
|
+
require 'date'
|
39
|
+
require 'logger'
|
40
|
+
|
30
41
|
require "sgs/version"
|
31
42
|
require 'sgs/redis_base'
|
32
43
|
require 'sgs/config'
|
44
|
+
require 'sgs/logger'
|
45
|
+
require 'sgs/mission_status'
|
33
46
|
require 'sgs/rpc'
|
34
47
|
require 'sgs/location'
|
48
|
+
require 'sgs/bearing'
|
35
49
|
require 'sgs/nmea'
|
36
50
|
require 'sgs/gps'
|
37
51
|
require 'sgs/waypoint'
|
@@ -41,3 +55,5 @@ require 'sgs/otto'
|
|
41
55
|
require 'sgs/course'
|
42
56
|
require 'sgs/navigate'
|
43
57
|
require 'sgs/mission'
|
58
|
+
require 'sgs/diagnostics'
|
59
|
+
require 'sgs/report'
|