コード例 #1
0
def instantiate_components(arguments):
    demosetup = arguments.demo
    testsetup = arguments.testsetup
    configfile = arguments.config
    # name of the servothread
    st = 'st'
    print('instantiating components')
    if demosetup == False:
        setup_lcec(configfile)
        # write lcec-read-all first
        hal.addf('lcec.read-all', st)
        # load other stuff
        print(configfile)
        if configfile != './ek1100el1008el2008.xml':
            setup_joints(st)
            connect_lcec(st, testsetup)
        # do some final writing of functions to the thread
        # write lcec-write-all last
        hal.addf('lcec.write-all', st)
    else:
        # create a demo joint for when EtherCAT not available
        setup_joints(st)
        connect_sim(st)
    # start threads for executing functions
    hal.start_threads()
    # create jplan joints and wire them to the plumbing
    if configfile != './ek1100el1008el2008.xml':
        finish_jplan_plumbing()
コード例 #2
0
def test_loadrt_or2():
    global rt
    rt.newinst("or2", "or2.0")
    rt.newthread("servo-thread", 1000000, fp=True)
    hal.addf("or2.0", "servo-thread")
    hal.start_threads()
    time.sleep(0.2)
コード例 #3
0
ファイル: test_rtapi.py プロジェクト: 13788593535/machinekit
def test_loadrt_or2():
    global rt
    rt.newinst("or2", "or2.0")
    rt.newthread("servo-thread", 1000000, fp=True)
    hal.addf("or2.0", "servo-thread")
    hal.start_threads()
    time.sleep(0.2)
コード例 #4
0
ファイル: robot.py プロジェクト: zhijunlian/borunte_hal
def configure_hal(thread):
    os.environ['PATH'] = '{}:{}'.format(os.environ['PATH'], COMPONENT_PATH)

    config = BorunteConfig(thread=thread)
    config.init()
    config.setup()

    # ready to start the threads
    hal.start_threads()
コード例 #5
0
 def setUp(self):
     self.cfg = ConfigParser()
     self.cfg.read(os.getenv("MACHINEKIT_INI"))
     self.uuid = self.cfg.get("MACHINEKIT", "MKUUID")
     self.rt = rtapi.RTAPIcommand(uuid=self.uuid)
     self.rt.newinst("or2", "or2.0")
     self.rt.newthread("servo-thread", 1000000, fp=True)
     hal.addf("or2.0", "servo-thread")
     hal.start_threads()
コード例 #6
0
ファイル: unittest_or2.py プロジェクト: ArcEye/machinekit
    def setUp(self):

        self.cfg = ConfigParser.ConfigParser()
        self.cfg.read(os.getenv("MACHINEKIT_INI"))
        self.uuid = self.cfg.get("MACHINEKIT", "MKUUID")
        self.rt = rtapi.RTAPIcommand(uuid=self.uuid)
        self.rt.newinst("or2", "or2.0")
        self.rt.newthread("servo-thread",1000000,fp=True)
        hal.addf("or2.0","servo-thread")
        hal.start_threads()
コード例 #7
0
    def test_runthread(self):
        cpe = hal.Pin("charge-pump.enable")
        cpe.set(0)

        rt.newthread("fast", 1000000, fp=True)
        rt.newthread("slow", 100000000, fp=True)
        hal.addf("ringread", "fast")
        hal.addf("ringwrite", "slow")
        hal.addf("charge-pump", "slow")
        hal.start_threads()
        cpe.set(1)  # enable charge_pump
        time.sleep(3)  # let rt thread write a bit to ring
コード例 #8
0
def test_runthread():
    cpe = hal.Pin("charge-pump.enable")
    cpe.set(0)

    rt.newthread("fast",1000000, fp=True)
    rt.newthread("slow",100000000, fp=True)
    hal.addf("ringread","fast")
    hal.addf("ringwrite","slow")
    hal.addf("charge-pump","slow")
    hal.start_threads()
    cpe.set(1)    # enable charge_pump
    time.sleep(3) # let rt thread write a bit to ring
コード例 #9
0
def instantiate_components(arguments):
    configfile = arguments.config
    # name of the servothread
    st = 'st'
    print('instantiating components')
    setup_lcec(configfile)
    # write lcec-read-all first
    hal.addf('lcec.0.read', st)
    # write lcec-write-all last
    hal.addf('lcec.0.write', st)
    # start threads for executing functions
    hal.start_threads()
コード例 #10
0
ファイル: main.py プロジェクト: yazici/stepper-test
def main():
    c.load_ini('hardware.ini')

    init_hardware()
    configure_stepgen()
    create_rcomp()
    setup_functions()

    # ready to start the threads
    hal.start_threads()

    # start haltalk server after everything is initialized
    # else binding the remote components on the UI might fail
    hal.loadusr('haltalk', wait=True)
コード例 #11
0
ファイル: conftest.py プロジェクト: zhijunlian/borunte_hal
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()
コード例 #12
0
poller = zmq.Poller()
poller.register(socket, zmq.POLLIN)

# allocate the rings
(command, mfcommand) = multiframe_ring(cname)
(response, mfresponse) = multiframe_ring(rname)

# reflect role - visible in halcmd:
command.writer = os.getpid()
response.reader = os.getpid()

rt.loadrt("micromot", "command=%s" % cname, "response=%s" % rname)
rt.newthread("fast", 1000000, use_fp=True)

hal.addf("micromot", "fast")
hal.start_threads()

subprocess.call("webtalk --plugin ./demowtplugin.o",
                shell=True,
                stderr=subprocess.STDOUT)

# mainloop:
#     receive zeroMQ messages and stuff them down the command ring
#     send off any messages read from response ring
try:
    while True:
        events = dict(poller.poll(timeout))
        if socket in events and events[socket] == zmq.POLLIN:
            request = socket.recv_multipart()
            n = 0
            for frame in request:
コード例 #13
0
def test_loadrt_ringwrite():
    rt.loadrt("ringwrite", "ring=ring1")
    rt.newthread("servo-thread", 1000000, fp=True)
    hal.addf("ringwrite", "servo-thread")
    hal.start_threads()
    time.sleep(1)  # let rt thread write a bit to ring
コード例 #14
0
ファイル: anddemo.py プロジェクト: strahlex/anddemo
# create the signal for connecting the components
input0 = hal.newsig('input0', hal.HAL_BIT)
input1 = hal.newsig('input1', hal.HAL_BIT)
output = hal.newsig('output', hal.HAL_BIT)

# and2 component
and2 = rt.newinst('and2', 'and2.demo')
and2.pin('in0').link(input0)
and2.pin('in1').link(input1)
and2.pin('out').link(output)
hal.addf(and2.name, 'main-thread')

# create remote component
rcomp = hal.RemoteComponent('anddemo', timer=100)
rcomp.newpin('button0', hal.HAL_BIT, hal.HAL_OUT)
rcomp.newpin('button1', hal.HAL_BIT, hal.HAL_OUT)
rcomp.newpin('led', hal.HAL_BIT, hal.HAL_IN)
rcomp.ready()

# link remote component pins
rcomp.pin('button0').link(input0)
rcomp.pin('button1').link(input1)
rcomp.pin('led').link(output)

# ready to start the threads
hal.start_threads()

# start haltalk server after everything is initialized
# else binding the remote components on the UI might fail
hal.loadusr('haltalk')
コード例 #15
0
ファイル: test_ring.py プロジェクト: 13788593535/machinekit
def test_loadrt_ringwrite():
    rt.loadrt("ringwrite","ring=ring1")
    rt.newthread("servo-thread",1000000,fp=True)
    hal.addf("ringwrite","servo-thread")
    hal.start_threads()
    time.sleep(1) # let rt thread write a bit to ring