|
@@ -1,11 +1,14 @@
|
|
|
import modulecommpython
|
|
|
import numpy as np
|
|
|
import time
|
|
|
+import sys
|
|
|
|
|
|
import proto.gpsimu_pb2 as gpsimu_pb2
|
|
|
#import gpsimu_pb2
|
|
|
import proto.mapdata_pb2 as mapdata_pb2
|
|
|
import proto.decition_pb2 as decition_pb2
|
|
|
+import proto.object_pb2 as object_pb2
|
|
|
+from proto import objectarray_pb2 as objectarray_pb2
|
|
|
|
|
|
from PyModuleCommModule import PyModuleComm
|
|
|
from decisiondemo import DecisionDemo
|
|
@@ -16,11 +19,15 @@ msg_gpsimu = gpsimu_pb2.gpsimu()
|
|
|
time_mapdata = 0
|
|
|
msg_mapdata = mapdata_pb2.tracemap()
|
|
|
|
|
|
+time_objectarray = 0
|
|
|
+msg_objectarray = objectarray_pb2.objectarray()
|
|
|
+
|
|
|
gdecision = DecisionDemo()
|
|
|
|
|
|
|
|
|
def gpsimu_callback(arr : np,nsize,time):
|
|
|
global msg_gpsimu
|
|
|
+ global time_gpsimu
|
|
|
# print("Python callback function called from C++!. time: ",time)
|
|
|
# print(" size: ",nsize)
|
|
|
sub_arr = arr[0:nsize]
|
|
@@ -34,6 +41,7 @@ def gpsimu_callback(arr : np,nsize,time):
|
|
|
|
|
|
def mapdata_callback(arr : np,nsize,time):
|
|
|
global msg_mapdata
|
|
|
+ global time_mapdata
|
|
|
sub_arr = arr[0:nsize]
|
|
|
databytes = sub_arr.tobytes() #sub_arr.tostring()
|
|
|
msg = mapdata_pb2.tracemap()
|
|
@@ -42,18 +50,31 @@ def mapdata_callback(arr : np,nsize,time):
|
|
|
time_mapdata = time
|
|
|
length = len(msg_mapdata.point)
|
|
|
print("map point lenth: ",length)
|
|
|
+
|
|
|
+def objectarray_callback(arr : np,nsize,time):
|
|
|
+ global msg_objectarray
|
|
|
+ global time_objectarray
|
|
|
+ sub_arr = arr[0:nsize]
|
|
|
+ databytes = sub_arr.tobytes() #sub_arr.tostring()
|
|
|
+ msg = objectarray_pb2.objectarray()
|
|
|
+ msg.ParseFromString(databytes)
|
|
|
+ msg_objectarray = msg
|
|
|
+ time_objectarray = time
|
|
|
+ # length = len(msg_objectarray.obj)
|
|
|
+ # print("obj size: ",length)
|
|
|
+ pass
|
|
|
|
|
|
def SendDefDecision(md : PyModuleComm):
|
|
|
pass
|
|
|
|
|
|
-def MakeDecision(md : PyModuleComm, mapdata : mapdata_pb2.tracemap, gpsimu : gpsimu_pb2.gpsimu):
|
|
|
+def MakeDecision(md : PyModuleComm, mapdata : mapdata_pb2.tracemap, gpsimu : gpsimu_pb2.gpsimu,xobjarray : objectarray_pb2.objectarray):
|
|
|
global gdecision
|
|
|
length = len(mapdata.point)
|
|
|
if length < 1 :
|
|
|
print(" no tracemap")
|
|
|
return
|
|
|
- print("map1 point lenth: ",length)
|
|
|
- xdecision = gdecision.CalcDecision(mapdata,gpsimu)
|
|
|
+# print("map1 point lenth: ",length)
|
|
|
+ xdecision = gdecision.CalcDecision(mapdata,gpsimu,xobjarray)
|
|
|
serialized_str = xdecision.SerializeToString()
|
|
|
serialized_array = np.frombuffer(serialized_str, dtype=np.uint8)
|
|
|
length = len(serialized_array)
|
|
@@ -66,7 +87,6 @@ def main():
|
|
|
|
|
|
# 初始化一个变量
|
|
|
count = 0
|
|
|
-
|
|
|
count = 3.5/1.5
|
|
|
count = int(count)
|
|
|
print("count = ",count)
|
|
@@ -77,11 +97,14 @@ def main():
|
|
|
mmap = PyModuleComm("newtracemap")
|
|
|
mmap.RegisterRecv(mapdata_callback)
|
|
|
|
|
|
+ mobj = PyModuleComm("lidar_track")
|
|
|
+ mobj.RegisterRecv(objectarray_callback)
|
|
|
+
|
|
|
md = PyModuleComm("deciton")
|
|
|
md.RegiseterSend(100000,1)
|
|
|
# 使用while循环,只要count小于10,就继续循环
|
|
|
while count < 10:
|
|
|
- MakeDecision(md,msg_mapdata,msg_gpsimu)
|
|
|
+ MakeDecision(md,msg_mapdata,msg_gpsimu,msg_objectarray)
|
|
|
time.sleep(0.05)
|
|
|
|
|
|
|