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

Added the tests for the geometric_model #199

Merged
merged 5 commits into from
Jan 23, 2024
Merged
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
3 changes: 1 addition & 2 deletions paseos/geometric_model/geometric_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def set_mesh(self):
self._actor_mesh = mesh.apply_scale(self.scale)
return self._actor_mesh

@property
def find_moment_of_inertia(self):
"""Gives the moment of inertia of the actor, assuming constant density.

Expand All @@ -89,7 +88,7 @@ def find_moment_of_inertia(self):
[Iyx Iyy Iyx]
[Izx Izy Izz]]
"""
self._actor_moment_of_inertia = self._actor_mesh.moment_inertia
self._actor_moment_of_inertia = self._actor_mesh.moment_inertia * self._actor_mass
return self._actor_moment_of_inertia

def find_center_of_gravity(self):
Expand Down
12 changes: 12 additions & 0 deletions paseos/tests/actor_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,15 @@ def test_add_comm_device():
assert len(sat1.communication_devices) == 2
assert sat1.communication_devices["dev1"].bandwidth_in_kbps == 10
assert sat1.communication_devices["dev2"].bandwidth_in_kbps == 42


def test_set_geometric_model():
"""Check if we can set the geometry, and if the moments of inertia are calculated correctly"""
_, sat1, _ = get_default_instance()
ActorBuilder.set_geometric_model(sat1, mass=100)

assert sat1.mass == 100
assert all(sat1._mesh.center_mass == np.array([0,0,0])) # check the default mesh is centered
assert sat1._mesh.volume == 1 # check the default volume is correct
assert round(sat1._moment_of_inertia[0,0], 4) == 16.6667 # for the default mesh
assert sat1._moment_of_inertia[0,1] == 0.0 # Should be zero if the mass distribution is even
Loading