Skip to content

Commit 2b2a997

Browse files
minor changes
1 parent a73d709 commit 2b2a997

File tree

8 files changed

+875
-258
lines changed

8 files changed

+875
-258
lines changed

code/polls/models/hole_horizontal_center.egg

Lines changed: 122 additions & 122 deletions
Large diffs are not rendered by default.

code/polls/plane_scene.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import sys
1111
import os
1212
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
13-
from utils import getCameraFromInfo
13+
from utils import getCameraFromInfo, drawSegmentationImage
1414

1515
def calcDistance(point_1, point_2):
1616
return pow(pow(point_1[0] - point_2[0], 2) + pow(point_1[1] - point_2[1], 2), 0.5)
@@ -33,6 +33,11 @@ def __init__(self, index):
3333
#cv2.imwrite('dump/alpha_0.5.png', np.zeros(self.depth[:, :, 0].shape).astype(np.uint8))
3434
self.segmentation = np.load('dump/' + str(index) + '_segmentation.npy')
3535

36+
#print(self.segmentation.shape)
37+
self.segmentation[self.segmentation == -1] = 10
38+
cv2.imwrite('dump/2_segmentation.png', drawSegmentationImage(self.segmentation, blackIndex=10))
39+
exit(1)
40+
3641
width = 640
3742
height = 480
3843
self.depth = cv2.resize(self.depth, (width, height))
@@ -444,3 +449,45 @@ def calcHorizontalPlanes(self):
444449

445450
def getHorizontalPlanes(self):
446451
return self.gravityDirection, self.horizontalPlanes
452+
453+
def getHolePos(self):
454+
floorPlaneIndex = 2
455+
closePoint = np.array([0., 1.22, -0.2])
456+
plane = self.planes[floorPlaneIndex]
457+
planeD = np.linalg.norm(plane)
458+
planeNormal = plane / planeD
459+
distance = planeD - np.dot(planeNormal, closePoint)
460+
distance *= 0.99
461+
holePos = closePoint + planeNormal * distance
462+
463+
H = P = R = 0
464+
H = -90 + np.rad2deg(np.arctan2(planeNormal[1], planeNormal[0]))
465+
#P = 90 - np.rad2deg(np.arccos(np.abs(planeNormal[2])))
466+
P = -90 + np.rad2deg(np.arccos(np.abs(planeNormal[2])))
467+
#print(H, P, R)
468+
return holePos, np.array([H, P, R])
469+
470+
471+
def getPortalPos(self):
472+
wallPlaneIndex = 1
473+
closePoint_1 = np.array([0.5, 1.35, -0.5])
474+
closePoint_2 = np.array([-0.4, 1, 0.19])
475+
plane = self.planes[wallPlaneIndex]
476+
planeD = np.linalg.norm(plane)
477+
planeNormal = plane / planeD
478+
479+
distance = planeD - np.dot(planeNormal, closePoint_1)
480+
distance *= 0.95
481+
portalPos_1 = closePoint_1 + planeNormal * distance
482+
483+
distance = planeD - np.dot(planeNormal, closePoint_2)
484+
distance *= 0.95
485+
portalPos_2 = closePoint_2 + planeNormal * distance
486+
487+
H = P = R = 0
488+
H = -90 + np.rad2deg(np.arctan2(planeNormal[1], planeNormal[0]))
489+
#P = 90 - np.rad2deg(np.arccos(np.abs(planeNormal[2])))
490+
P = -90 + np.rad2deg(np.arccos(-np.abs(planeNormal[2])))
491+
#print(H, P, R)
492+
return portalPos_1, np.array([H, P, R]), portalPos_2, np.array([H, P, R]), planeNormal
493+

0 commit comments

Comments
 (0)