class SGS::Navigate
Constants
- MODENAMES
- MODE_MANUAL
- MODE_MISSION
- MODE_MISSION_ABORT
- MODE_MISSION_END
- MODE_OLYMPIC
- MODE_PRE_MISSION
- MODE_SLEEP
- MODE_TEST
- MODE_UPDOWN
Attributes
Public Class Methods
# File lib/sgs/navigate.rb, line 56 def initialize @mode = MODE_SLEEP @waypoint = nil @curpos = nil super end
Public Instance Methods
What is our current position?
# File lib/sgs/navigate.rb, line 131 def curpos @curpos ||= SGS::GPS.load end
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
# File lib/sgs/navigate.rb, line 116 def mission end
The mission is aborted. Determine what to do next
# File lib/sgs/navigate.rb, line 126 def mission_abort end
The mission has ended - sail to the rendezvous point
# File lib/sgs/navigate.rb, line 121 def mission_end end
# File lib/sgs/navigate.rb, line 69 def mode=(val) puts "SETTING NEW MODE TO #{MODENAMES[val]}" @mode = val end
What is the mode name?
# File lib/sgs/navigate.rb, line 65 def mode_name MODENAMES[@mode] end
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
# File lib/sgs/navigate.rb, line 109 def olympic_course end
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)
# File lib/sgs/navigate.rb, line 79 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
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
# File lib/sgs/navigate.rb, line 101 def upwind_downwind_course end
What is the next waypoint?
# File lib/sgs/navigate.rb, line 137 def waypoint @waypoint ||= SGS::Waypoint.load end