Skip to content

Commit

Permalink
Minor optimizations; now using set_angle() to manipulate all servos
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestaylr committed Aug 20, 2015
1 parent 084de82 commit 7d9ba16
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/modules/logic.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@

import logging, socket, time, modules.calc
from .control_thread import StoppableThread
from .utils import SocketType

logger = logging.getLogger('log')

class LogicThread(StoppableThread):

data = None
values = None
data = values = None

def __init__(self, *args, **kwargs):
super(LogicThread, self).__init__(*args, **kwargs)

global data
global data, values
data = self._kwargs['data']

global values
values = self._kwargs['values']

def station_keeping(self):
Expand All @@ -36,7 +34,6 @@ def run(self):
values['start_time'] = time.time()

while True:

if self.stopped():
break

Expand Down Expand Up @@ -145,7 +142,7 @@ def turn_rudder(self):
values['rudder_angle'] = a * (values['max_rudder_angle'] / values['max_turn_rate_angle'])

logger.debug('Set the rudder angle to: %f' % values['rudder_angle'])
self._kwargs['data_thread'].set_rudder_angle(values['rudder_angle'])
self._kwargs['data_thread'].set_angle(values['rudder_angle'], SocketType.rudder)

def turn_winch(self):
a = data['wind_dir']
Expand All @@ -164,4 +161,4 @@ def turn_winch(self):
values['winch_angle'] = 80 - 40 * (a / (180 - values['gybe_angle'] - values['tack_angle']))

logger.debug('Set the winch angle to: %f' % values['winch_angle'])
self._kwargs['data_thread'].set_winch_angle(values['winch_angle'])
self._kwargs['data_thread'].set_angle(values['winch_angle'], SocketType.winch)

0 comments on commit 7d9ba16

Please sign in to comment.