Merge branch 'main' of https://github.com/rookiepeng/hexapod
This commit is contained in:
commit
e51f97b817
@ -28,6 +28,8 @@ import socket
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class BluetoothServer(Thread):
|
class BluetoothServer(Thread):
|
||||||
ERROR = -1
|
ERROR = -1
|
||||||
@ -47,6 +49,12 @@ class BluetoothServer(Thread):
|
|||||||
with open('./config.json', 'r') as read_file:
|
with open('./config.json', 'r') as read_file:
|
||||||
self.config = json.load(read_file)
|
self.config = json.load(read_file)
|
||||||
|
|
||||||
|
stream = os.popen('hciconfig hci0')
|
||||||
|
output = stream.read()
|
||||||
|
device_id = "hci0"
|
||||||
|
bt_mac = output.split("{}:".format(device_id))[1].split(
|
||||||
|
"BD Address: ")[1].split(" ")[0].strip()
|
||||||
|
|
||||||
# import commands
|
# import commands
|
||||||
# cmd = "hciconfig"
|
# cmd = "hciconfig"
|
||||||
# device_id = "hci0"
|
# device_id = "hci0"
|
||||||
@ -54,7 +62,7 @@ class BluetoothServer(Thread):
|
|||||||
# bt_mac = output.split("{}:".format(device_id))[1].split("BD Address: ")[1].split(" ")[0].strip()
|
# bt_mac = output.split("{}:".format(device_id))[1].split("BD Address: ")[1].split(" ")[0].strip()
|
||||||
# print bt_mac
|
# print bt_mac
|
||||||
|
|
||||||
self.mac = '192.168.1.127'
|
self.mac = bt_mac
|
||||||
self.port = 10
|
self.port = 10
|
||||||
self.bt_socket = socket.socket(
|
self.bt_socket = socket.socket(
|
||||||
socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
|
socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
|
||||||
|
@ -146,7 +146,6 @@ class Hexapod(Thread):
|
|||||||
|
|
||||||
self.standby()
|
self.standby()
|
||||||
# self.laydown()
|
# self.laydown()
|
||||||
# self.leg_0.move_junctions([90,45,135])
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
# self.leg_0.set_angle(1, 30)
|
# self.leg_0.set_angle(1, 30)
|
||||||
@ -379,10 +378,13 @@ class Hexapod(Thread):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
q = Queue()
|
q = Queue()
|
||||||
tcp_server = TCPServer(q)
|
tcp_server = TCPServer(q)
|
||||||
tcp_server.start()
|
tcp_server.start()
|
||||||
|
|
||||||
|
bt_server = BluetoothServer(q)
|
||||||
|
bt_server.start()
|
||||||
|
|
||||||
hexapod = Hexapod(q)
|
hexapod = Hexapod(q)
|
||||||
hexapod.start()
|
hexapod.start()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user