Пример #1
0
 def __init__(self, BLE_MAC_ADDR, BLE_ADAPTOR_ID):
     from m2controller import m2controller
     from m2controller import m2Const
     import signal
     import time
     # Initialise
     self.m_telemetry = None
     self.throttle = 0
     self.steering = 0
     self.m_BLE_MAC_ADDR = BLE_MAC_ADDR
     self.m_BLE_ADAPTOR_ID = BLE_ADAPTOR_ID
     self.controller = m2controller.BleCtrller(m2Const.etDebian, None,
                                               self.m_BLE_MAC_ADDR,
                                               self.m_BLE_ADAPTOR_ID)
     self.controller.clearPreviousCmd()
     self.controller.setPWM_n_pm1(0, 0)
     self.controller.setPWM_n_pm1(2, 0)
     self.controller.SendCmdTransBlking()
     time.sleep(0.1)
if usrCfg.ctrlType == CONST.etAndroid:
    print("maneuver command needs to be sent from PC or internet")
    quit()

requestExit = False


def signal_handler(sig, frame):
    global requestExit
    print('user Ctrl-C exit request')
    quit()


signal.signal(signal.SIGINT, signal_handler)

controller = m2controller.BleCtrller(None)
controller.connect()


def stopEverything():
    controller.motorHbridgeCtrl_pm1(CONST.spiderPWMchSpeed, 0.0)
    controller.motorHbridgeCtrl_pm1(CONST.spiderPWMchSteer, 0.0)
    controller.SendCmdTransBlking(False, True)


def on_press(key):
    global requestExit
    #print('%s key pressed'%key)
    if key == keyboard.Key.left:
        controller.motorHbridgeCtrl_pm1(CONST.spiderPWMchSteer, -1.0)
    elif key == keyboard.Key.right:
Пример #3
0
iSMstep = 0
iSMsubstep = 0


def move2nextSMstate():
    global iSMstep, iSMsubstep
    iSMstep += 1
    iSMsubstep = 0


if usrCfg.ctrlType != CONST.etAndroid and usrCfg.ctrlType != CONST.etInternet:
    print(
        "microscope needs phone camera to take sample images for further computer vision processing"
    )
    sys.exit()
controller = m2controller.BleCtrller("", callbackfunc)
#controller = m2controller.BleCtrller(usrCfg.BleMACaddress,callbackfunc)

controller.connect()
if sanityCheck():
    print("controller HW setting error")
else:
    while True:
        if requestExit:
            controller.stop()
            break
        iLoopCnt += 1
        if iLoopCnt == 50:
            break
        print("step(%d,%d)" % (iSMstep, iSMsubstep))
        controller.setSeqID(iSMstep)
        return True
    if (not hardware_settings['CH2dutyCycleMode']):
        return True
    if (not hardware_settings['CH3dutyCycleMode']):
        return True
    if (not hardware_settings['CH01_merged2be_H_bridge']):
        return True
    if (not hardware_settings['CH23_merged2be_H_bridge']):
        return True
    return False


bUseCallBack = True  #True False, choose to exituse callback or explicit read request for telemetry data retrieval
#controller = m2controller.BleCtrller("",callbackfunc)
if bUseCallBack:
    controller = m2controller.BleCtrller(usrCfg.BleMACaddress, callbackfunc)
else:
    controller = m2controller.BleCtrller(usrCfg.BleMACaddress, None)
controller.connect()
if sanityCheck():
    print("controller HW setting error")
    return

controller.setTime0()

while True:
    time.sleep(0.1)
    if danceStepii >= len(DanceSeq):
        break
    if requestExit:
        break