Ejemplo n.º 1
0
def has_imops():
    """ get the imops.so library, does a crude check to see if it needs makeing,
    and if so does it """
    import ctypes
    imops_fname = whichlib(IMOPS_PYNAOQI_SO)
    HOME = os.environ['HOME']
    src_imops = '%s/src/burst/src/imops/imops.cpp' % HOME
    bad_architecture = imops_fname and is_64bit_elf(imops_fname) != is64() or False
    if (not imops_fname or os.stat(imops_fname)[stat.ST_MTIME] < os.stat(src_imops)[stat.ST_MTIME]
        or bad_architecture):
        if bad_architecture: # force make to remake the so file
            os.system('cd %s/src/burst/src/imops; make clean' % HOME)
        # make it (either it doesn't exist, is too old, or doesn't match the architecture)
        os.system('cd %s/src/burst/src/imops; make pynaoqi -j %s' % (HOME, get_num_cores() + 1))
    try:
        imops = ctypes.CDLL(imops_fname)
    except:
        print "missing imops (you might want to add burst/lib to LD_LIBRARY_PATH)"
        return None
    return imops
Ejemplo n.º 2
0
    def __init__(self, main_behavior_class=None):
        super(ExternalMainLoop, self).__init__(main_behavior_class = main_behavior_class)
        self._keep_the_loop = True

        # need to call burst.init first
        burst.init()

        self.initMainObjectsAndPlayer()
        self.preMainLoopInit() # Start point for Player / GameController
        # Now just call self.doSingleStep

    def profile_filename(self):
        return '%s.kcachegrind' % sys.argv[0].rsplit('.',1)[0]

    def profile_player_filename(self):
        return '%s_player.kcachegrind' % sys.argv[0].rsplit('.',1)[0]

    def _exitApp(self, _):
        self._keep_the_loop = False


################################################################################

from burst_util import is64
if is64() or burst.options.use_pynaoqi:
    MainLoop = TwistedMainLoop
else:
    # default loop doesn't use twisted
    MainLoop = SimpleMainLoop

Ejemplo n.º 3
0
# Constants

WEBOTS_LOCALHOST_URL = "http://localhost:9560/"

foot = lambda foot: ['Device/SubDeviceList/%sFoot/Bumper/%s/Sensor/Value' % (a,foot) for a in ['L', 'R']]

BUTTON_VARS = dict(left_foot = foot('Left'), right_foot = foot('Right'),
                chest = ['Device/SubDeviceList/ChestBoard/Button/Sensor/Value'])
ON, OFF = 1.0, 0.0
LIFESPAN_INFINITE = 0


################################################################################
# Image Ops

IMOPS_PYNAOQI_SO = is64() and 'imops_pynaoqi_64.so' or 'imops_pynaoqi_32.so'

def has_imops():
    """ get the imops.so library, does a crude check to see if it needs makeing,
    and if so does it """
    import ctypes
    imops_fname = whichlib(IMOPS_PYNAOQI_SO)
    HOME = os.environ['HOME']
    src_imops = '%s/src/burst/src/imops/imops.cpp' % HOME
    bad_architecture = imops_fname and is_64bit_elf(imops_fname) != is64() or False
    if (not imops_fname or os.stat(imops_fname)[stat.ST_MTIME] < os.stat(src_imops)[stat.ST_MTIME]
        or bad_architecture):
        if bad_architecture: # force make to remake the so file
            os.system('cd %s/src/burst/src/imops; make clean' % HOME)
        # make it (either it doesn't exist, is too old, or doesn't match the architecture)
        os.system('cd %s/src/burst/src/imops; make pynaoqi -j %s' % (HOME, get_num_cores() + 1))
Ejemplo n.º 4
0
# must be the first import - you can only import naoqi after this
from base import *
from options import *
import burst_target as target

# Finally we load the networking/ipc library to connect to naoqi which does
# actually talk to the hardware. We have two implementations and two development
# hosts, namely 64 bit and 32bit, so this gets a little complex.

from burst_util import is64
import sys

using_pynaoqi = False

if 'pynaoqi' in sys.modules or is64() or options.use_pynaoqi:
    if is64():
        print "64 bit architecture - LESS TESTED"
    else:
        print "32 bit + pynaoqi - LESS TESTED"
    from naoqi_pynaoqi import *
    using_pynaoqi = True

    def init(*args, **kw):
        pass

else:
    # put all of naoqi namespace in burst (wrapped in try to work under pynaoqi
    # import burst.moves as moves)
    try:
        from naoqi import *
Ejemplo n.º 5
0
from Queue import Queue
from threading import Thread

import burst_target
import burst_util
import burst

if burst_util.is64():
    print "ERROR: ALProxyThread not implemented for pynaoqi yet. can't use --newmove in 64 bits."
    import sys

    sys.exit(-1)


class ALProxyThread(Thread):
    """ New input from aldebaran suggests that ALProxy is blocking,
    but using multiple ALProxys, one per thread, should work. So
    the former ActionThread becomes ALProxyThread, and it won't be
    joined until the very end of the program (which is better anyhow),
    and it will now have an incoming queue to be fed new moves.
    """

    QUIT = False

    def __init__(self, *args, **kw):
        super(ALProxyThread, self).__init__(*args, **kw)
        # XXX First place where Deferred code isn't used - this will blocks..
        self._motion = burst.ALProxy("ALMotion", burst_target.ip, burst_target.port)
        self.in_queue = Queue()
        self.out_queue = Queue()
        self.verbose = burst.options.verbose_movecoordinator
Ejemplo n.º 6
0
Archivo: base.py Proyecto: alon/burst
            pass

    if 'naoqi' not in sys.modules and 'aldebaran' not in sys.modules:
        fix_sys_path()

    print_warning = False
    try:
        from aldebaran import naoqi
    except:
        try:
            import naoqi
        except Exception, e:
            print "naoqi import caused exception (after path fix):", e
            print_warning = True
        except:
            print_warning = True

    if print_warning:
        print "burst did its best to find naoqi - you are probably either"
        print "forgetting to setup AL_DIR or on a 64 bit machine. Either way"
        print "burst will let you continue, but expect everything to explode."


# maybe this is already taken care of? test first.
if is64():
    print "burst.base - 64 bit architecture, not looking for naoqi"
else:
    find_naoqi()