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

mode[R]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/sgs/navigate.rb, line 56
def initialize
  @mode = MODE_SLEEP
  @waypoint = nil
  @curpos = nil
  super
end

Public Instance Methods

curpos() click to toggle source

What is our current position?

# File lib/sgs/navigate.rb, line 131
def curpos
  @curpos ||= SGS::GPS.load
end
mission() click to toggle source

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
mission_abort() click to toggle source

The mission is aborted. Determine what to do next

# File lib/sgs/navigate.rb, line 126
def mission_abort
end
mission_end() click to toggle source

The mission has ended - sail to the rendezvous point

# File lib/sgs/navigate.rb, line 121
def mission_end
end
mode=(val) click to toggle source
# File lib/sgs/navigate.rb, line 69
def mode=(val)
  puts "SETTING NEW MODE TO #{MODENAMES[val]}"
  @mode = val
end
mode_name() click to toggle source

What is the mode name?

# File lib/sgs/navigate.rb, line 65
def mode_name
  MODENAMES[@mode]
end
olympic_course() click to toggle source

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
run() click to toggle source

This is the main navigator function. It does several things;

  1. Look for the next waypoint and compute bearing and distance to it

  2. Decide if we have reached the waypoint (and adjust accordingly)

  3. 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
upwind_downwind_course() click to toggle source

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
waypoint() click to toggle source

What is the next waypoint?

# File lib/sgs/navigate.rb, line 137
def waypoint
  @waypoint ||= SGS::Waypoint.load
end