Skip to content

Commit

Permalink
Merge pull request #168 from Visual-Behavior/camera_calib
Browse files Browse the repository at this point in the history
camera calin
  • Loading branch information
thibo73800 authored Apr 14, 2022
2 parents 698251c + 026fea2 commit 523c4db
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions aloscene/camera_calib.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ class CameraExtrinsic(AugmentedTensor):
"""

@staticmethod
def __new__(cls, x, *args, **kwargs):
tensor = super().__new__(cls, x, *args, **kwargs)
def __new__(cls, x, *args, names=(None, None), **kwargs):
tensor = super().__new__(cls, x, *args, names=names, **kwargs)
return tensor

def translation_with(self, tgt_pos):
Expand All @@ -204,6 +204,21 @@ def translation_with(self, tgt_pos):
translation = Ttgt2self[..., :3, -1]
return translation

def distance_with(self, tgt_pos):
""" Compute the distance with an other pos
Parameters
----------
tgt_pos: aloscene.Pose
Target pose to compute the distance with
Returns
-------
n_pos: torch.tensor
Translation tensor of shape (..., 3)
"""
return torch.linalg.norm(self.translation_with(tgt_pos), dim=-1)

def __init__(self, x, *args, **kwargs):
assert x.shape[-2] == 4 and x.shape[-1] == 4
super().__init__(x)
Expand Down

0 comments on commit 523c4db

Please sign in to comment.