Exemple #1
0
def main(addr_port):
    if not hasattr(G, "initialized"):
        try:
            import conf; missing = conf.load()
            if missing:
                fatal('missing configuration entries: %s' % missing)

            if hasattr(conf, 'DEBUG_MODE') and conf.DEBUG_MODE:
                # set system-wide logging level
                import comm; comm.set_default_logging(debug=True)

            cont = initialize(conf.lightHead_server)
            G.server.set_listen_timeout(0.001)
            G.server.start()
        except conf.LoadException, e:
            fatal('in file {0[0]}: {0[1]}'.format(e)) 
        except Exception, e:
            fatal(e)
Exemple #2
0
# communication.py

import threading, time, socket
import comm, config

if hasattr(config, 'DEBUG') and config.DEBUG:
    comm.set_default_logging(debug=config.DEBUG)
LOG = comm.LOG

class CommBase(comm.BaseClient):
    
    def __init__(self, server_addrPort):
        comm.BaseClient.__init__(self, server_addrPort)
        self.set_timeout(5)
        threading.Thread(target=self.connect_and_run).start()

        # information blocks
        self.last_ack = None
        self.last_nack = None
        self.lips_info = None
        self.gaze_info = None
        self.face_info = None

    def handle_connect(self):
        """Callback for sucessful connection.
        Inits communication and set robot on origin"""
        if type(self.target_addr) == type(''):
            LOG.info("Connected to server on {0}".format(self.target_addr))
            return
        LOG.info("Connected to server {0[0]}:{0[1]}".format(self.target_addr))
Exemple #3
0
#
# The spine module controls orientation and position of the robot torso and neck
# It provides a high-level API and relies on the backend implemented in the
#  module 'spine_backend'
#
# The API is limited to hardware implementation and indeed results are hardware-
#  dependant. However as long as the hardware provides the required DOF and
#  backend provides required functions, the end-result should be similar.
#
import comm, conf
import logging

if hasattr(conf,'DEBUG_MODE') and conf.DEBUG_MODE:
    comm.set_default_logging(debug=True)
    LOG = comm.LOG
else:
    LOG = logging.getLogger(__package__)


class SpineProtocolError(comm.ProtocolError):
    pass

class SpineError(comm.CmdError):
    pass

class NotImplemented(SpineError):
    pass


class SpineElementInfo(object):
    """Capabilities and Information about an element of the spine"""