class SGS::Otto
Constants
- MODE_DIAGNOSTICS
- MODE_INERT
- MODE_MANUAL
- MODE_NAMES
- MODE_TRACK_AWA
- MODE_TRACK_COMPASS
Attributes
bi_c[RW]
bi_m[RW]
bt_c[RW]
bt_m[RW]
bv_c[RW]
bv_m[RW]
mode[RW]
raw_awa[RW]
raw_compass[RW]
raw_rudder[RW]
raw_sail[RW]
raw_ta[RW]
raw_tc[RW]
rudder_c[RW]
rudder_m[RW]
sail_c[RW]
sail_m[RW]
sv_c[RW]
sv_m[RW]
Public Class Methods
new()
click to toggle source
Set up some useful defaults. We assume rudder goes from 0 to 200 as does the sail angle.
Calls superclass method
# File lib/sgs/otto.rb, line 51 def initialize # # Configure the Mx + C values for sail and rudder @rudder_m = 2.5 @rudder_c = 100.0 @sail_m = 2.0 @sail_c = 0.0 # # Now set the rudder and sail to default positions (rudder is centered) rudder = 0.0 sail = 0.0 # # Set up some basic parameters for battery/solar readings @bv_m = @bi_m = @bt_m = @sv_m = 1.0 @bv_c = @bi_c = @bt_c = @sv_c = 0.0 super end
Public Instance Methods
awa()
click to toggle source
Return the apparent wind angle (in radians)
# File lib/sgs/otto.rb, line 105 def awa @raw_awa.to_f * Math::PI / 128.0 end
compass()
click to toggle source
Return the compass angle (in radians)
# File lib/sgs/otto.rb, line 99 def compass @raw_compass.to_f * Math::PI / 128.0 end
rudder()
click to toggle source
Return the rudder angle in degrees
# File lib/sgs/otto.rb, line 79 def rudder (@raw_rudder.to_f - @rudder_c) / @rudder_m end
rudder=(val)
click to toggle source
Set the required rudder angle. Input values range from +/- 40.0 degrees
# File lib/sgs/otto.rb, line 71 def rudder=(val) val = -40.0 if val < -40.0 val = 40.0 if val > 40.0 @raw_rudder = (@rudder_m * val.to_f + @rudder_c).to_i end
sail()
click to toggle source
Return the sail setting (0.0 -> 100.0)
# File lib/sgs/otto.rb, line 93 def sail (@raw_sail.to_f - @sail_c) / @sail_m end
sail=(val)
click to toggle source
Set the required sail angle. Input values range from 0 -> 90 degrees.
# File lib/sgs/otto.rb, line 85 def sail=(val) val = 0.0 if val < 0.0 val = 100.0 if val > 100.0 @raw_sail = (@sail_m * val.to_f + @sail_c).to_i end
track_awa()
click to toggle source
Return the current tracking AWA.
# File lib/sgs/otto.rb, line 135 def track_awa @raw_ta.to_f * Math::PI / 128.0 end
track_awa=(val)
click to toggle source
Set the required AWA for tracking.
# File lib/sgs/otto.rb, line 127 def track_awa=(val) val = -180.0 if val < -180.0 val = 180.0 if val > 180.0 @raw_ta = (val.to_f * 128.0 / Math::PI).to_i end
track_compass()
click to toggle source
Return the compass value for tracking.
# File lib/sgs/otto.rb, line 121 def track_compass @raw_tc.to_f * Math::PI / 128.0 end
track_compass=(val)
click to toggle source
Set the required compass reading. Input values range from 0 -> 359 degrees
# File lib/sgs/otto.rb, line 111 def track_compass=(val) while val < 0.0 val += 360.0 end val %= 360.0 @raw_tc = (val.to_f * 128.0 / Math::PI).to_i end