Skip to content
Snippets Groups Projects
Commit e6cff465 authored by Hoa Ben The Nguyen's avatar Hoa Ben The Nguyen
Browse files

change: prepare new method for finding relative data from lidar to map

parent 15b692a7
No related branches found
No related tags found
No related merge requests found
...@@ -13,18 +13,18 @@ METER = (1 / ((2 * pi / 360) * EARTH)) / 1000 # 1 meter in degree ...@@ -13,18 +13,18 @@ METER = (1 / ((2 * pi / 360) * EARTH)) / 1000 # 1 meter in degree
def position_relative_to_pointcloud(l1, l2, p1, p2, center_lim, max_lim): def position_relative_to_pointcloud(l1, l2, p1, p2, center_lim, max_lim):
center_l = tuple((a+b)/2 for a, b in zip(l1,l2)) center_l = tuple((a+b)/2 for a, b in zip(l1,l2))
return [ return [
((p1[0] - center_lim[0]) * ((l1[0] - l2[0]) / (max_lim[1][0] - max_lim[3][0])) + center_l[0], ((p1[0] - center_lim[0]) * ((l1[0] - l2[0]) / (max_lim[2][0] - max_lim[0][0])) + center_l[0],
(p1[1] - center_lim[1]) * ((l1[1] - l2[1]) / (max_lim[1][1] - max_lim[3][1])) + center_l[1]), (p1[1] - center_lim[1]) * ((l1[1] - l2[1]) / (max_lim[2][1] - max_lim[0][1])) + center_l[1]),
((p2[0] - center_lim[0]) * ((l1[0] - l2[0]) / (max_lim[1][0] - max_lim[3][0])) + center_l[0], ((p2[0] - center_lim[0]) * ((l1[0] - l2[0]) / (max_lim[2][0] - max_lim[0][0])) + center_l[0],
(p2[1] - center_lim[1]) * ((l1[1] - l2[1]) / (max_lim[1][1] - max_lim[3][1])) + center_l[1]) (p2[1] - center_lim[1]) * ((l1[1] - l2[1]) / (max_lim[2][1] - max_lim[0][1])) + center_l[1]),
] ]
print(position_relative_to_pointcloud((-20,30), (-10,20), (1,3), (2,2), (2.5,2.5), [(0,0),(0,5),(0,0),(5,0)])) print(position_relative_to_pointcloud((-20,20), (-10,30), (1,3), (2,2), (2.5,2.5), [(5,5),(0,5),(0,0),(5,0)]))
print(position_relative_to_pointcloud((-3299999, 4608018), (-3200001, 4687153), (61.47620866851029, 8.961138281887507), (61.95241733702057, 6.8508373935926645), (61, 11), [(61.95241733702057, 15.125349549679886), (60.04758266297943, 15.125349549679886), (60.04758266297943, 6.8746504503201145), (61.95241733702057, 6.8746504503201145)])) print(position_relative_to_pointcloud((-3299999, 4608018), (-3200001, 4687153), (61.47620866851029, 8.961138281887507), (61.95241733702057, 6.8508373935926645), (61, 11), [(61.95241733702057, 15.125349549679886), (60.04758266297943, 15.125349549679886), (60.04758266297943, 6.8746504503201145), (61.95241733702057, 6.8746504503201145)]))
# check if lidar points is within range of the area selected # check if lidar points is within range of the area selected
def inArea(position, areaRange): def inArea(position, areaRange):
x, y, _ = position # position to be checked x, y, _ = position # position to be checked
#print((areaRange[0][0])," < ",x," < ",(areaRange[1][0])," and ",(areaRange[0][1])," > ",(y)," > ",(areaRange[1][1])," ",((areaRange[0][0]) < x < (areaRange[1][0])) and ((areaRange[0][1]) > (y) > (areaRange[1][1]))) print((areaRange[0][0])," < ",x," < ",(areaRange[1][0])," and ",(areaRange[0][1])," > ",(y)," > ",(areaRange[1][1])," ",((areaRange[0][0]) < x < (areaRange[1][0])) and ((areaRange[0][1]) > (y) > (areaRange[1][1])))
if ((areaRange[0][0]) < x < (areaRange[1][0])) and ((areaRange[0][1]) > y > (areaRange[1][1])): if ((areaRange[0][0]) < x < (areaRange[1][0])) and ((areaRange[0][1]) > y > (areaRange[1][1])):
return True return True
else: else:
......
...@@ -92,15 +92,15 @@ def calculate_area_data(center, body_of_water): ...@@ -92,15 +92,15 @@ def calculate_area_data(center, body_of_water):
# find the heights of each sub-area => area-heights # find the heights of each sub-area => area-heights
if len(map_data) > 0: if len(map_data) > 0:
for sub_area in grid_area_heights: for sub_area in grid_area_heights:
start = (sub_area[1][1]) start = (sub_area[1][2])
end = (sub_area[1][3]) end = (sub_area[1][0])
#test data #test data
# zone coordinates sett to be relative to the lidar data's point cloud # zone coordinates sett to be relative to the lidar data's point cloud
print("extrem", min_point, " ", max_point) print("l1 = ", min_point, " l2 = ", max_point)
print("finding", start, " ", end) print("p1 = ", start, " p2 = ", end)
print("center", center) print("center_lim = ", center)
print("limit", area_limit) print("max_lim = ", area_limit)
areazone = position_relative_to_pointcloud(min_point, max_point, start, end, center, area_limit) areazone = position_relative_to_pointcloud(min_point, max_point, start, end, center, area_limit)
print("area",areazone) print("area",areazone)
# calculate map zones height # calculate map zones height
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment