Ejemplo n.º 1
0
def hal_config():
    from machinekit import launcher

    launcher.cleanup_session()
    comp_path = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
        '../components/absolute_joint.icomp',
    )
    launcher.install_comp(comp_path)
    launcher.start_realtime()
    rt.init_RTAPI()

    config = HalConfig(thread=THREAD)
    rt.newthread(config.thread.name, config.thread.period_ns, fp=True)
    hal.start_threads()

    yield config

    hal.stop_threads()
    launcher.end_session()
Ejemplo n.º 2
0
        events = dict(poller.poll(timeout))
        if socket in events and events[socket] == zmq.POLLIN:
            request = socket.recv_multipart()
            n = 0
            for frame in request:
                mfcommand.write(frame, False if n == 0 else 1)
                n += 1
            mfcommand.flush()

        # poll response ring
        if mfresponse.ready():
            reply = []
            for frame in mfresponse.read():
                #print "got:",(frame.data.tobytes(), frame.flags)
                reply.append(frame.data)
            mfresponse.shift()

            if reply:
                socket.send_multipart(reply)

except (KeyboardInterrupt, zmq.error.ZMQError) as e:
    # cleanup
    hal.stop_threads()
    command.writer = 0
    response.reader = 0

    rt.delthread("fast")
    rt.unloadrt("micromot")
    subprocess.call("realtime stop", shell=True, stderr=subprocess.STDOUT)
    subprocess.call("killall webtalk", shell=True, stderr=subprocess.STDOUT)
Ejemplo n.º 3
0
def test_unloadrt_or2():
    hal.stop_threads()
    rt.delthread("servo-thread")
    rt.unloadrt("or2")
Ejemplo n.º 4
0
def test_unloadrt_or2():
    hal.stop_threads()
    rt.delthread("servo-thread")
    rt.unloadrt("or2")
Ejemplo n.º 5
0
        events = dict(poller.poll(timeout))
        if socket in events and events[socket] == zmq.POLLIN:
            request = socket.recv_multipart()
            n = 0
            for frame in request:
                mfcommand.write(frame, False if n == 0 else 1)
                n += 1
            mfcommand.flush()

        # poll response ring
        if mfresponse.ready():
            reply = []
            for frame in mfresponse.read():
                #print "got:",(frame.data.tobytes(), frame.flags)
                reply.append(frame.data)
            mfresponse.shift()

            if reply:
                socket.send_multipart(reply)

except (KeyboardInterrupt,zmq.error.ZMQError) as e:
    # cleanup
    hal.stop_threads()
    command.writer  = 0
    response.reader = 0

    rt.delthread("fast")
    rt.unloadrt("micromot")
    subprocess.call("realtime stop", shell=True,stderr=subprocess.STDOUT)
    subprocess.call("killall webtalk", shell=True,stderr=subprocess.STDOUT)