Skip to content
Snippets Groups Projects
Commit d31b99a1 authored by Aaron John Sabu's avatar Aaron John Sabu
Browse files

Final version for quals

parent 4d940ed3
Branches g5-5500
No related merge requests found
......@@ -13,7 +13,7 @@ def nothing(x):
detector = Detector()
def get_AT_6DOF_info(url):
def get_AT_6DOF_info(url, detectFlag = True):
tid,tx,ty,tz= 0,100000,100000,0
rx = [0.0,0.0,0.0]
ry = [0.0, 0.0, 0.0]
......@@ -29,6 +29,12 @@ def get_AT_6DOF_info(url):
gray_image = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
h, w, _ = frame.shape
if not detectFlag:
resized_frame = cv2.resize(frame,(400,300))
cv2.imshow("Image", resized_frame)
return -1,0,0,0,0,0,0
# put a dot in center of the frame
cv2.circle(frame, (w // 2, h // 2), 7, (255, 0, 0), -1)
# set camera parameters
......
......@@ -11,14 +11,21 @@
// REPLACE WITH THE MAC Address of your receiver (MASTER)
// Slave: 40:F5:20:44:B6:4C
// MAC Address of the receiver (MASTER)
uint8_t broadcastAddress[] = {0xC4, 0xDD, 0x57, 0x9E, 0x91, 0x74}; // #1
//uint8_t broadcastAddress[] = {0xC4, 0xDD, 0x57, 0x9E, 0x91, 0x74}; // #1
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xBD, 0xF8}; // #2
//uint8_t broadcastAddress[] = {0xC4, 0xDD, 0x57, 0x9E, 0x8A, 0x98}; // #3
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xB6, 0x4C}; // #4
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xC0, 0xD8}; // #5
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xDE, 0xE0}; // #6
//uint8_t broadcastAddress[] = {0x3C, 0x61, 0x05, 0x4A, 0xD3, 0x3C}; // #7
// uint8_t broadcastAddress[] = {0x3C, 0x61, 0x05, 0x9B, 0x04, 0x98}; // #8
uint8_t broadcastAddress[] = {0x3C, 0x61, 0x05, 0x9B, 0x04, 0x98}; // #8
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xBE, 0x84}; // #9
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xB9, 0x5C}; // #10
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xC1, 0xD8}; // #11
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xB6, 0xC8}; // #12
//uint8_t broadcastAddress[] = {0xC4, 0xDD, 0x57, 0x9E, 0xA1, 0x14}; // #13
//uint8_t broadcastAddress[] = {0x3C, 0x61, 0x05, 0x49, 0x4F, 0xC8}; // #14
String success;
// Define variables to store incoming readings
......
......@@ -33,7 +33,7 @@ def modifyCore():
cAddLineNums = [254, 256, 257, 258, 259]
# REPLACABLE LINE FOR DIFFERENT LOCAL COMPUTER DEVICES
coreFile = 'C:\\Users\\uclal\\.conda\\envs\\foray3\\Lib\\site-packages\\detecto\\core.py'
coreFile = 'C:\\Users\\aaronjs\\.conda\\envs\\FORAYenv\\Lib\\site-packages\\detecto\\core.py'
cModLineVals = [" def __init__(self, classes=None, device=None, pretrained=True, modelname=\'fasterrcnn_resnet50_fpn\'):\n",
" # Load a model pre-trained on COCO - User-Modified",
......@@ -81,7 +81,7 @@ def returnModel(device, labelSet, modelLoc, modelFile):
return model
#### Live Detection
def detectLive(url , model, minDetectionScore = 0.90, showSight = True):
def detectLive(url , model, minDetectionScore = 0.90, showSight = True, detectFlag = True):
'''
Descrption:
ball detection ML Functions
......@@ -104,6 +104,13 @@ def detectLive(url , model, minDetectionScore = 0.90, showSight = True):
imgnp = np.array(bytearray(img_resp.read()), dtype = np.uint8)
frame = cv2.imdecode(imgnp, -1)
if not detectFlag:
if showSight:
resized_frame = cv2.resize(frame,(400,300))
cv2.imshow('Ball Detection', resized_frame)
key = cv2.waitKey(1) & 0xFF
return gbx, gby, dist
labels, boxes, scores = model.predict(frame)
for i in range(boxes.shape[0]):
box = boxes[i]
......
......@@ -10,8 +10,14 @@
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xB6, 0x4C}; // #4
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xC0, 0xD8}; // #5
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xDE, 0xE0}; // #6
uint8_t broadcastAddress[] = {0x3C, 0x61, 0x05, 0x4A, 0xD3, 0x3C}; // #7
//uint8_t broadcastAddress[] = {0x3C, 0x61, 0x05, 0x4A, 0xD3, 0x3C}; // #7
//uint8_t broadcastAddress[] = {0x3C, 0x61, 0x05, 0x9B, 0x04, 0x98}; // #8
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xBE, 0x84}; // #9
uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xB9, 0x5C}; // #10
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xC1, 0xD8}; // #11
//uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x44, 0xB6, 0xC8}; // #12
//uint8_t broadcastAddress[] = {0xC4, 0xDD, 0x57, 0x9E, 0xA1, 0x14}; // #13
//uint8_t broadcastAddress[] = {0x3C, 0x61, 0x05, 0x49, 0x4F, 0xC8}; // #14
// ==================================== global data =================================================
String success;
// Define variables to store BME280 readings to be sent
......
......@@ -9,7 +9,7 @@ from ESP32_AT.imageTread_AT import get_AT_6DOF_info
global mc_print,ml_on,esp_cam_on,feather_data_on
url_gb = 'http://10.0.0.7/cam-hi.jpg'
url_AT = 'http://10.0.0.1/cam-hi.jpg'
url_AT = 'http://10.0.0.30/cam-hi.jpg'
mc_print = 1 # manual control print flag
ml_on = 1
......@@ -60,6 +60,8 @@ def manual_horizontal():
return abs(pwm3),abs(pwm4),dir3,dir4
def manual_control():
gbx, gby, gb_dist = ball_detection.detectLive(url_gb, model, minDetectionScore, showSight=True, detectFlag = False)
tid, tx, ty, tz, rx, ry, rz = get_AT_6DOF_info(url_AT, detectFlag = False)
pwm1,pwm2,dir1,dir2 = manual_vertical()
pwm3,pwm4,dir3,dir4 = manual_horizontal()
if mc_print == 1:
......@@ -195,6 +197,8 @@ def auto_control(serial_port,gbx, gby, gb_dist, tx, ty, tz, rx, ry, rz, LIDAR_di
return Ctl_com
def manual_in_auto(Ctl_com, serial_port, flag):
gbx, gby, gb_dist = ball_detection.detectLive(url_gb, model, minDetectionScore, showSight=True, detectFlag = False)
tid, tx, ty, tz, rx, ry, rz = get_AT_6DOF_info(url_AT, detectFlag = False)
done = 1
if joystick.get_button(axes_win.get('button_LB')):
flag = 12
......@@ -235,7 +239,7 @@ def serial_port_in_v1(serial_port):
# DEBUG Verbose
print("initiating one round of serial in ...")
for i in range(8):
for i in range(7):
line = serial_port.readline()
val = int(line.decode())
......@@ -253,9 +257,10 @@ def serial_port_in_v1(serial_port):
rz = val
elif i == 6:
LIDAR_dist1 = val
elif i == 7:
LIDAR_dist2 = val
# elif i == 7:
# LIDAR_dist2 = val
LIDAR_dist2 = 0
line = serial_port.readline()
debugM = line.decode()
......@@ -519,7 +524,7 @@ if __name__ == '__main__':
# =========== SET UP ============
# Defining Variables for ESP 32 Serial I/O
PORT = "COM9" # for Alienware
PORT = "COM11" # for Alienware
serial_port = serial.Serial(PORT, 115200)
serial_port.close()
serial_port.open()
......
......@@ -9,7 +9,7 @@ from ESP32_AT.imageTread_AT import get_AT_6DOF_info
global mc_print,ml_on,esp_cam_on,feather_data_on
url_gb = 'http://10.0.0.7/cam-hi.jpg'
url_AT = 'http://10.0.0.1/cam-hi.jpg'
url_AT = 'http://10.0.0.5/cam-hi.jpg'
mc_print = 1 # manual control print flag
ml_on = 1
......@@ -176,13 +176,17 @@ def auto_control(serial_port,gbx, gby, gb_dist, tx, ty, tz, rx, ry, rz, LIDAR_di
print("gbx,gby:{},{}".format(gbx, gby))
line = serial_port.readline()
print("line")
if feather_data_on == 1:
print("feather_data_on == 1")
if line == b'SERIAL_IN_START\r\n':
print("line == b'SERIAL_IN_START\r\n'")
tx, ty, tz, rx, ry, rz, LIDAR_dist1, LIDAR_dist2, debugM = serial_port_in_v1(serial_port)
# only getting the Lidar data back
time.sleep(waitTime) # in second
if esp_cam_on == 1:
print("esp_cam_on == 1")
# ids,txs,tys,tzs,rxs,rys,rzs = get_AT_6DOF_info_list(url_AT)
tid, tx, ty, tz, rx, ry, rz = get_AT_6DOF_info(url_AT)
# LIDAR_dist1 = 0
......@@ -519,7 +523,7 @@ if __name__ == '__main__':
# =========== SET UP ============
# Defining Variables for ESP 32 Serial I/O
PORT = "COM16" # for Alienware
PORT = "COM3" # for Alienware
serial_port = serial.Serial(PORT, 115200)
serial_port.close()
serial_port.open()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment