Ejemplo n.º 1
0
def wheel_com_init():
    global Device1, Device2
    Device1 = BLEDevice("DD:43:89:16:43:81")  #right wheel
    Device2 = BLEDevice("F4:82:B3:50:ED:55")  #left  wheel
    Device1.writereq(0xd, '54524F5F0D0A')  #RUN_flag
    Device1.notify()
    Device2.writereq(0xd, '54524F5F0D0A')  #RUN_flag
    Device2.notify()
    Device1.writereq(0xd, '544443790D0A')  #FRONT
    Device1.notify()
    Device2.writereq(0xd, '544443790D0A')  #FRONT
    Device2.notify()

    desired_speed1(10)
    desired_speed2(10)

    time.sleep(2)
    desired_speed1(0)
    desired_speed2(0)
    global state
    state = STOP
Ejemplo n.º 2
0
import sys, time
import threading
import keyboard
import numpy as np

from bledevice import scanble, BLEDevice

Device1 = BLEDevice("DD:43:89:16:43:81")
Device2 = BLEDevice("F4:82:B3:50:ED:55")
Device1.writereq(0xd, '54524F5F0D0A')  #RUN_flag
Device1.notify()
Device2.writereq(0xd, '54524F5F0D0A')  #RUN_flag
Device2.notify()
Device1.writereq(0xd, '544443790D0A')  #FRONT
Device1.notify()
Device2.writereq(0xd, '544443790D0A')  #FRONT
Device2.notify()
desired = 0
flag = 1
now_velocity1 = 0
now_velocity2 = 0

STOP = 0
IDLE = 1
FWD = 2
LEFT = 3
RIGHT = 4
ROTATE = 6

direction1 = 1
direction2 = 1
Ejemplo n.º 3
0
 def connect(self):
     global bulb
     bulb = BLEDevice(self.bl.get())
     time.sleep(0.1)
     bulb.writereq(bulb.getvaluehandle(WRITE_CHAR_UUID), COMMAND_STX+AUTH_CMD+AUTH_ON+COMMAND_ETX*15)
Ejemplo n.º 4
0
Archivo: test_22.py Proyecto: GY-Cha/wb
import sys, time
import threading
import keyboard
import numpy as np

from bledevice import scanble, BLEDevice
Device1 = BLEDevice("DD:43:89:16:43:81")
Device2 = BLEDevice("F4:82:B3:50:ED:55")

Device1.writereq(0xd, '545246680D0A')  #STOP_flag
Device2.writereq(0xd, '545246680D0A')  #STOP_flag
Device1.writereq(0xd, '54524F5F0D0A')  #RUN_flag
Device2.writereq(0xd, '54524F5F0D0A')  #RUN_flag
Device1.writereq(0xd, '544443790D0A')  #CW forward
Device2.writereq(0xd, '544443790D0A')  #CW forward
Device1.writereq(0xd, '54571E8B0D0A')  #5km/h
Device2.writereq(0xd, '54571E8B0D0A')  #5km/h
t = 0
toggle = 1
while 1:

    if t > 1:

        if toggle == 1:

            Device1.writereq(0xd, '544457650D0A')  #CCW backward
            Device2.writereq(0xd, '544457650D0A')  #CCW backward
            time.sleep(2)

        else:
            Device1.writereq(0xd, '544443790D0A')  #CCW forward
Ejemplo n.º 5
0
 def connect(self):
     global bulb
     bulb = BLEDevice(self.bl.get())
     time.sleep(0.1)
     bulb.writereq(bulb.getvaluehandle(WRITE_CHAR_UUID),
                   COMMAND_STX + AUTH_CMD + AUTH_ON + COMMAND_ETX * 15)
Ejemplo n.º 6
0
Archivo: test2.py Proyecto: GY-Cha/wb
def fSLOWER(Device1, Device2):
    Device1.writereq(0xd, '546464380D0A')  #Spd_Down
    Device2.writereq(0xd, '546464380D0A')  #Spd_Down


def M_FWD_RIGHT(Device1, Device2):
    print("\nM_FWD_RIGHT")


def M_FWD_LEFT(Device1, Device2):
    print("\nM_FWD_LEFT")


#vh=Device1.getvaluehandle(b"0000ffe1")
Device1.writereq(0xd, '54524F5F0D0A')
Device2.writereq(0xd, '54524F5F0D0A')
time.sleep(0.5)
sum_time = 0
mean_time = 0
count = 0
while True:
    count = count + 1
    start = time.time()
    data = Device1.notify()
    sum_time = sum_time + time.time() - start
    mean_time = sum_time / count
    print(
        "time :",
        time.time() - start,
        "mean_time : ",
Ejemplo n.º 7
0
import sys, time
import threading
import keyboard
import numpy as np

from bledevice import scanble, BLEDevice
Device2 = BLEDevice("F4:82:B3:50:ED:55")
Device2.writereq(0xd, '54524F5F0D0A')  #RUN_flag

desired = 0
flag = 1
now_velocity = 0


def M_FWD():
    global now_velocity
    if now_velocity < 16:
        now_velocity = 16
    now_velocity = now_velocity + 1
    return now_velocity


def M_BWD():
    global now_velocity
    if now_velocity < 16:
        now_velocity = 16
    now_velocity = now_velocity - 1
    return now_velocity


def M_STOP():