Class: SGS::Otto
Constant Summary collapse
- MODE_INERT =
0- MODE_DIAGNOSTICS =
1- MODE_MANUAL =
2- MODE_TRACK_COMPASS =
3- MODE_TRACK_AWA =
4- MODE_NAMES =
[ "Inert Mode", "Diagnostics Mode", "Manual Control Mode", "Compass-Tracking Mode", "AWA-Tracking Mode" ].freeze
Instance Attribute Summary collapse
-
#bi_c ⇒ Object
Returns the value of attribute bi_c.
-
#bi_m ⇒ Object
Returns the value of attribute bi_m.
-
#bt_c ⇒ Object
Returns the value of attribute bt_c.
-
#bt_m ⇒ Object
Returns the value of attribute bt_m.
-
#bv_c ⇒ Object
Returns the value of attribute bv_c.
-
#bv_m ⇒ Object
Returns the value of attribute bv_m.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#raw_awa ⇒ Object
Returns the value of attribute raw_awa.
-
#raw_compass ⇒ Object
Returns the value of attribute raw_compass.
-
#raw_rudder ⇒ Object
Returns the value of attribute raw_rudder.
-
#raw_sail ⇒ Object
Returns the value of attribute raw_sail.
-
#raw_ta ⇒ Object
Returns the value of attribute raw_ta.
-
#raw_tc ⇒ Object
Returns the value of attribute raw_tc.
-
#rudder_c ⇒ Object
Returns the value of attribute rudder_c.
-
#rudder_m ⇒ Object
Returns the value of attribute rudder_m.
-
#sail_c ⇒ Object
Returns the value of attribute sail_c.
-
#sail_m ⇒ Object
Returns the value of attribute sail_m.
-
#sv_c ⇒ Object
Returns the value of attribute sv_c.
-
#sv_m ⇒ Object
Returns the value of attribute sv_m.
Instance Method Summary collapse
-
#awa ⇒ Object
Return the apparent wind angle (in radians).
-
#compass ⇒ Object
Return the compass angle (in radians).
-
#initialize ⇒ Otto
constructor
Set up some useful defaults.
-
#rudder ⇒ Object
Return the rudder angle in degrees.
-
#rudder=(val) ⇒ Object
Set the required rudder angle.
-
#sail ⇒ Object
Return the sail setting (0.0 -> 100.0).
-
#sail=(val) ⇒ Object
Set the required sail angle.
-
#track_awa ⇒ Object
Return the current tracking AWA.
-
#track_awa=(val) ⇒ Object
Set the required AWA for tracking.
-
#track_compass ⇒ Object
Return the compass value for tracking.
-
#track_compass=(val) ⇒ Object
Set the required compass reading.
Methods inherited from RedisBase
#count, #count_name, #load, load, #make_redis_name, #publish, redis, redis_handle, #redis_read_var, #save, #save_and_publish, setup, subscribe, to_redis, var_init
Constructor Details
#initialize ⇒ Otto
Set up some useful defaults. We assume rudder goes from 0 to 200 as does the sail angle.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# 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 |
Instance Attribute Details
#bi_c ⇒ Object
Returns the value of attribute bi_c.
35 36 37 |
# File 'lib/sgs/otto.rb', line 35 def bi_c @bi_c end |
#bi_m ⇒ Object
Returns the value of attribute bi_m.
35 36 37 |
# File 'lib/sgs/otto.rb', line 35 def bi_m @bi_m end |
#bt_c ⇒ Object
Returns the value of attribute bt_c.
35 36 37 |
# File 'lib/sgs/otto.rb', line 35 def bt_c @bt_c end |
#bt_m ⇒ Object
Returns the value of attribute bt_m.
35 36 37 |
# File 'lib/sgs/otto.rb', line 35 def bt_m @bt_m end |
#bv_c ⇒ Object
Returns the value of attribute bv_c.
35 36 37 |
# File 'lib/sgs/otto.rb', line 35 def bv_c @bv_c end |
#bv_m ⇒ Object
Returns the value of attribute bv_m.
35 36 37 |
# File 'lib/sgs/otto.rb', line 35 def bv_m @bv_m end |
#mode ⇒ Object
Returns the value of attribute mode.
34 35 36 |
# File 'lib/sgs/otto.rb', line 34 def mode @mode end |
#raw_awa ⇒ Object
Returns the value of attribute raw_awa.
33 34 35 |
# File 'lib/sgs/otto.rb', line 33 def raw_awa @raw_awa end |
#raw_compass ⇒ Object
Returns the value of attribute raw_compass.
33 34 35 |
# File 'lib/sgs/otto.rb', line 33 def raw_compass @raw_compass end |
#raw_rudder ⇒ Object
Returns the value of attribute raw_rudder.
33 34 35 |
# File 'lib/sgs/otto.rb', line 33 def raw_rudder @raw_rudder end |
#raw_sail ⇒ Object
Returns the value of attribute raw_sail.
33 34 35 |
# File 'lib/sgs/otto.rb', line 33 def raw_sail @raw_sail end |
#raw_ta ⇒ Object
Returns the value of attribute raw_ta.
33 34 35 |
# File 'lib/sgs/otto.rb', line 33 def raw_ta @raw_ta end |
#raw_tc ⇒ Object
Returns the value of attribute raw_tc.
33 34 35 |
# File 'lib/sgs/otto.rb', line 33 def raw_tc @raw_tc end |
#rudder_c ⇒ Object
Returns the value of attribute rudder_c.
34 35 36 |
# File 'lib/sgs/otto.rb', line 34 def rudder_c @rudder_c end |
#rudder_m ⇒ Object
Returns the value of attribute rudder_m.
34 35 36 |
# File 'lib/sgs/otto.rb', line 34 def rudder_m @rudder_m end |
#sail_c ⇒ Object
Returns the value of attribute sail_c.
34 35 36 |
# File 'lib/sgs/otto.rb', line 34 def sail_c @sail_c end |
#sail_m ⇒ Object
Returns the value of attribute sail_m.
34 35 36 |
# File 'lib/sgs/otto.rb', line 34 def sail_m @sail_m end |
#sv_c ⇒ Object
Returns the value of attribute sv_c.
35 36 37 |
# File 'lib/sgs/otto.rb', line 35 def sv_c @sv_c end |
#sv_m ⇒ Object
Returns the value of attribute sv_m.
35 36 37 |
# File 'lib/sgs/otto.rb', line 35 def sv_m @sv_m end |
Instance Method Details
#awa ⇒ Object
Return the apparent wind angle (in radians)
105 106 107 |
# File 'lib/sgs/otto.rb', line 105 def awa @raw_awa.to_f * Math::PI / 128.0 end |
#compass ⇒ Object
Return the compass angle (in radians)
99 100 101 |
# File 'lib/sgs/otto.rb', line 99 def compass @raw_compass.to_f * Math::PI / 128.0 end |
#rudder ⇒ Object
Return the rudder angle in degrees
79 80 81 |
# File 'lib/sgs/otto.rb', line 79 def rudder (@raw_rudder.to_f - @rudder_c) / @rudder_m end |
#rudder=(val) ⇒ Object
Set the required rudder angle. Input values range from +/- 40.0 degrees
71 72 73 74 75 |
# 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 ⇒ Object
Return the sail setting (0.0 -> 100.0)
93 94 95 |
# File 'lib/sgs/otto.rb', line 93 def sail (@raw_sail.to_f - @sail_c) / @sail_m end |
#sail=(val) ⇒ Object
Set the required sail angle. Input values range from 0 -> 90 degrees.
85 86 87 88 89 |
# 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 ⇒ Object
Return the current tracking AWA.
135 136 137 |
# File 'lib/sgs/otto.rb', line 135 def track_awa @raw_ta.to_f * Math::PI / 128.0 end |
#track_awa=(val) ⇒ Object
Set the required AWA for tracking.
127 128 129 130 131 |
# 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 ⇒ Object
Return the compass value for tracking.
121 122 123 |
# File 'lib/sgs/otto.rb', line 121 def track_compass @raw_tc.to_f * Math::PI / 128.0 end |
#track_compass=(val) ⇒ Object
Set the required compass reading. Input values range from 0 -> 359 degrees
111 112 113 114 115 116 117 |
# 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 |