Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor gravity initialization and update post-init conversion to use default tensor type #119

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/adam/parametric/pytorch/computations_parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def __init__(
joints_name_list: list,
links_name_list: list,
root_link: str = None,
gravity: np.array = torch.tensor(
[0, 0, -9.80665, 0, 0, 0], dtype=torch.float64
),
gravity: np.array = torch.tensor([0, 0, -9.80665, 0, 0, 0]),
) -> None:
"""
Args:
Expand Down
4 changes: 1 addition & 3 deletions src/adam/pytorch/computations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def __init__(
urdfstring: str,
joints_name_list: list = None,
root_link: str = None,
gravity: np.array = torch.tensor(
[0, 0, -9.80665, 0, 0, 0], dtype=torch.float64
),
gravity: np.array = torch.tensor([0, 0, -9.80665, 0, 0, 0]),
) -> None:
"""
Args:
Expand Down
6 changes: 3 additions & 3 deletions src/adam/pytorch/torch_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class TorchLike(ArrayLike):
array: torch.Tensor

def __post_init__(self):
"""Converts array to double precision"""
if self.array.dtype != torch.float64:
self.array = self.array.double()
"""Converts array to the default type used in the library"""
if self.array.dtype != torch.get_default_dtype():
self.array = self.array.to(torch.get_default_dtype())

def __setitem__(self, idx, value: Union["TorchLike", ntp.ArrayLike]) -> "TorchLike":
"""Overrides set item operator"""
Expand Down
Loading