nbv_sim/src/active_grasp/baselines.py

30 lines
893 B
Python
Raw Normal View History

2021-07-07 17:46:11 +02:00
import numpy as np
from .policy import SingleViewPolicy, MultiViewPolicy, compute_error
2021-07-07 17:46:11 +02:00
2021-08-25 18:29:10 +02:00
class InitialView(SingleViewPolicy):
2021-09-12 14:40:17 +02:00
def update(self, img, x, q):
self.x_d = x
super().update(img, x, q)
2021-07-07 17:46:11 +02:00
2021-08-25 21:32:47 +02:00
class TopView(SingleViewPolicy):
2021-09-11 20:49:55 +02:00
def activate(self, bbox, view_sphere):
super().activate(bbox, view_sphere)
self.x_d = self.view_sphere.get_view(0.0, 0.0)
2021-09-12 00:21:58 +02:00
self.done = False if self.is_feasible(self.x_d) else True
2021-07-07 17:46:11 +02:00
2021-07-08 09:36:51 +02:00
2021-08-25 21:32:47 +02:00
class TopTrajectory(MultiViewPolicy):
2021-09-11 20:49:55 +02:00
def activate(self, bbox, view_sphere):
super().activate(bbox, view_sphere)
self.x_d = self.view_sphere.get_view(0.0, 0.0)
2021-09-12 00:21:58 +02:00
self.done = False if self.is_feasible(self.x_d) else True
2021-08-25 21:32:47 +02:00
2021-09-12 14:40:17 +02:00
def update(self, img, x, q):
self.integrate(img, x, q)
2021-09-11 20:49:55 +02:00
linear, _ = compute_error(self.x_d, x)
2021-09-04 15:50:29 +02:00
if np.linalg.norm(linear) < 0.02:
2021-08-25 21:32:47 +02:00
self.done = True