nbv_sim/src/active_grasp/baselines.py

38 lines
1.1 KiB
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):
def update(self, img, seg, target_id, x, q):
2021-09-12 14:40:17 +02:00
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-11-05 15:53:15 +01:00
self.done = False if self.solve_cam_ik(self.q0, 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-11-05 15:53:15 +01:00
self.done = False if self.solve_cam_ik(self.q0, self.x_d) else True
2021-08-25 21:32:47 +02:00
def update(self, img, seg, target_id, x, q):
2021-09-12 14:40:17 +02:00
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
2021-10-27 15:43:01 +02:00
class FixedTrajectory(MultiViewPolicy):
def activate(self, bbox, view_sphere):
pass
def update(self, img, seg, target_id, x, q):
2021-10-27 15:43:01 +02:00
pass