Share view computation among all policies

This commit is contained in:
Michel Breyer
2021-09-11 14:52:27 +02:00
parent 3550b49669
commit 4ebd587553
5 changed files with 49 additions and 45 deletions

View File

@@ -1,7 +1,6 @@
import numpy as np
from .policy import SingleViewPolicy, MultiViewPolicy
from vgn.utils import look_at
from .policy import SingleViewPolicy, MultiViewPolicy, compute_error
class InitialView(SingleViewPolicy):
@@ -14,23 +13,19 @@ class InitialView(SingleViewPolicy):
class TopView(SingleViewPolicy):
def activate(self, bbox):
super().activate(bbox)
eye = np.r_[self.center[:2], self.bbox.max[2] + self.min_z_dist]
up = np.r_[1.0, 0.0, 0.0]
self.x_d = look_at(eye, self.center, up)
self.x_d = self.view_sphere.get_view(0.0, 0.0)
self.done = False if self.is_view_feasible(self.x_d) else True
class TopTrajectory(MultiViewPolicy):
def activate(self, bbox):
super().activate(bbox)
eye = np.r_[self.center[:2], self.bbox.max[2] + self.min_z_dist]
up = np.r_[1.0, 0.0, 0.0]
self.x_d = look_at(eye, self.center, up)
self.x_d = self.view_sphere.get_view(0.0, 0.0)
self.done = False if self.is_view_feasible(self.x_d) else True
def update(self, img, x):
self.integrate(img, x)
linear, angular = self.compute_error(self.x_d, x)
linear, angular = compute_error(self.x_d, x)
if np.linalg.norm(linear) < 0.02:
self.done = True
return np.zeros(6)