Class: SGS::Navigate
- Inherits:
-
Object
- Object
- SGS::Navigate
- Defined in:
- lib/sgs/navigate.rb
Constant Summary collapse
- MODE_SLEEP =
0
- MODE_TEST =
1
- MODE_MANUAL =
2
- MODE_UPDOWN =
3
- MODE_OLYMPIC =
4
- MODE_PRE_MISSION =
5
- MODE_MISSION =
6
- MODE_MISSION_END =
7
- MODE_MISSION_ABORT =
8
- MODENAMES =
[ "Sleeping...", "Test Mode", "Manual Steering", "Sail Up and Down", "Sail a Triangle", "Pre-Mission Wait", "On Mission", "Mission Ended", "** Mission Abort **" ].freeze
Instance Attribute Summary collapse
-
#mode ⇒ Object
Returns the value of attribute mode.
Class Method Summary collapse
-
.daemon ⇒ Object
Main daemon function (called from executable).
Instance Method Summary collapse
-
#curpos ⇒ Object
What is our current position?.
-
#initialize ⇒ Navigate
constructor
A new instance of Navigate.
-
#mission ⇒ Object
Navigate the mission.
-
#mission_abort ⇒ Object
The mission is aborted.
-
#mission_end ⇒ Object
The mission has ended - sail to the rendezvous point.
-
#mode_name ⇒ Object
What is the mode name?.
-
#olympic_course ⇒ Object
Navigate around an olympic triangle.
-
#run ⇒ Object
This is the main navigator function.
-
#upwind_downwind_course ⇒ Object
Navigate a course up to a windward mark which is one nautical mile upwind of the start position.
-
#waypoint ⇒ Object
What is the next waypoint?.
Constructor Details
#initialize ⇒ Navigate
Returns a new instance of Navigate.
64 65 66 67 68 69 |
# File 'lib/sgs/navigate.rb', line 64 def initialize @mode = MODE_SLEEP @waypoint = nil @curpos = nil super end |
Instance Attribute Details
#mode ⇒ Object
Returns the value of attribute mode.
40 41 42 |
# File 'lib/sgs/navigate.rb', line 40 def mode @mode end |
Class Method Details
.daemon ⇒ Object
Main daemon function (called from executable)
73 74 75 76 77 |
# File 'lib/sgs/navigate.rb', line 73 def self.daemon loop do sleep 300 end end |
Instance Method Details
#curpos ⇒ Object
What is our current position?
147 148 149 |
# File 'lib/sgs/navigate.rb', line 147 def curpos @curpos ||= SGS::GPS.load end |
#mission ⇒ Object
Navigate the mission. This is the main “meat and potatoes” navigation. It concerns itself with finding the best route to the next mark and sailing to that
132 133 |
# File 'lib/sgs/navigate.rb', line 132 def mission end |
#mission_abort ⇒ Object
The mission is aborted. Determine what to do next
142 143 |
# File 'lib/sgs/navigate.rb', line 142 def mission_abort end |
#mission_end ⇒ Object
The mission has ended - sail to the rendezvous point
137 138 |
# File 'lib/sgs/navigate.rb', line 137 def mission_end end |
#mode_name ⇒ Object
What is the mode name?
81 82 83 |
# File 'lib/sgs/navigate.rb', line 81 def mode_name MODENAMES[@mode] end |
#olympic_course ⇒ Object
Navigate around an olympic triangle. Sail one nautical mile upwind of the current position, then sail to a point to the left-side of the course which is at an angle of 120 degrees to the wind. From there, sail back to the start position
125 126 |
# File 'lib/sgs/navigate.rb', line 125 def olympic_course end |
#run ⇒ Object
This is the main navigator function. It does several things;
-
Look for the next waypoint and compute bearing and distance to it
-
Decide if we have reached the waypoint (and adjust accordingly)
-
Compute the boat heading (and adjust accordingly)
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/sgs/navigate.rb', line 95 def run puts "Navigator mode is #{mode_name}: Current Position:" p curpos p waypoint case @mode when MODE_UPDOWN upwind_downwind_course when MODE_OLYMPIC olympic_course when MODE_MISSION mission when MODE_MISSION_END mission_end when MODE_MISSION_ABORT mission_abort end end |
#upwind_downwind_course ⇒ Object
Navigate a course up to a windward mark which is one nautical mile upwind of the start position. From there, navigate downwind to the finish position
117 118 |
# File 'lib/sgs/navigate.rb', line 117 def upwind_downwind_course end |