Skip to content

Commit

Permalink
Merge pull request #107 from open-dynamic-robot-initiative/fkloss/cam…
Browse files Browse the repository at this point in the history
…eras

get_width/height of cameras & save original camera matrix
  • Loading branch information
luator authored Aug 20, 2024
2 parents 6e9b504 + c594db7 commit 498486c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions trifinger_simulation/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ class BaseCamera:
def get_image(
self, renderer=pybullet.ER_BULLET_HARDWARE_OPENGL
) -> np.ndarray:
"""Render an image."""
raise NotImplementedError()

def get_width(self) -> int:
"""Get width of the images rendered by this camera instance."""
raise NotImplementedError()

def get_height(self) -> int:
"""Get height of the images rendered by this camera instance."""
raise NotImplementedError()


Expand Down Expand Up @@ -197,6 +206,12 @@ def __init__(
physicsClientId=self._pybullet_client_id,
)

def get_width(self) -> int:
return self._width

def get_height(self) -> int:
return self._height

def get_image(
self, renderer=pybullet.ER_BULLET_HARDWARE_OPENGL
) -> np.ndarray:
Expand Down Expand Up @@ -285,6 +300,9 @@ def __init__(
pybullet_client_id: Id of the pybullet client (needed when
multiple clients are running in parallel).
"""
# store the original camera matrix for use in C++ bindings (trifinger_cameras)
self._original_camera_matrix = camera_matrix

self._pybullet_client_id = pybullet_client_id

#: Width of the output images.
Expand Down Expand Up @@ -359,6 +377,12 @@ def __init__(
)
self._proj_matrix = proj_mat.flatten(order="F")

def get_width(self) -> int:
return self._output_width

def get_height(self) -> int:
return self._output_height

def distort_image(self, image):
"""Distort an image based on the cameras distortion coefficients.
Expand Down

0 comments on commit 498486c

Please sign in to comment.