Exemplo n.º 1
0
 def __init__(self, map, req):
    Thread.__init__(self)
    #system('svctrl --start wifi_sensor > /dev/null')
    self.gps_reader = _GPS_Reader(map['gps'])
    self.measure_reader = _MeasureReader(map['net'])
    self.combined_publisher = _CombinedPublisher(map['pub_server'], self.gps_reader, self.measure_reader)
    self.map = map
    self.req = req
    self.factory = ICARUS_MissionFactory()
    self.client = ICARUS_SynClient(map['ctrl'], map['state'])
Exemplo n.º 2
0
class LocMission(Thread):

   """
   - manages a measurement publisher
   - executes a configurable zigzag mission
   """

   def __init__(self, map, req):
      Thread.__init__(self)
      #system('svctrl --start wifi_sensor > /dev/null')
      self.gps_reader = _GPS_Reader(map['gps'])
      self.measure_reader = _MeasureReader(map['net'])
      self.combined_publisher = _CombinedPublisher(map['pub_server'], self.gps_reader, self.measure_reader)
      self.map = map
      self.req = req
      self.factory = ICARUS_MissionFactory()
      self.client = ICARUS_SynClient(map['ctrl'], map['state'])

   def run(self):
      self.gps_reader.start()
      self.measure_reader.start()
      self.combined_publisher.start()
      for x, y in self._zigzag_gen(0.0, 0.0, 0.1, 0.1, 10):
         self.client.execute(self.factory.move_xy(x, y))
      self.combined_publisher.term()
      self.measure_reader.term()
      self.gps_reader.term()
      self.req.status = MissionMessage.DONE
      self.map['pub_server'].send(self.req.SerializeToString())


   def _zigzag_gen(self, x, y, width, height, breaks):
      for i in range(breaks):
         yield x + width / 2.0, y
         y += (height / breaks) / 2.0
         yield x - width / 2.0, y
         y += (height / breaks) / 2.0
      yield width / 2.0, height
Exemplo n.º 3
0
from scl import generate_map
from icarus_interface import ICARUS_SynClient, ICARUS_MissionFactory
from misc import user_data_dir

# set-up command history:
_path = user_data_dir + os.sep + 'ICARUS_shell.history'
_history = os.path.expanduser(_path)


def _save_history(historyPath=_history):
    readline.write_history_file(_history)


if os.path.exists(_history):
    readline.read_history_file(_history)
readline.parse_and_bind("tab: complete")
atexit.register(_save_history)

# define
_map = generate_map('mission')
_client = ICARUS_SynClient(_map['icarus_ctrl'], _map['icarus_state'])
i = ICARUS_MissionFactory()


def request(item):
    try:
        _client.execute(item)
    except Exception, e:
        print e