Skip to content

Commit

Permalink
visual test for attitude plotting cleaned up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Medina committed Jan 19, 2024
1 parent db97bd7 commit 0f68861
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions test_attitude_code/test_attitude_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# Define central body
earth = pk.planet.jpl_lp("earth")

# Define spacecraft actor
sat1 = ActorBuilder.get_actor_scaffold("sat1", SpacecraftActor, pk.epoch(0))
sat2 = ActorBuilder.get_actor_scaffold("sat2", SpacecraftActor, pk.epoch(0))

ActorBuilder.set_orbit(
sat1,
Expand All @@ -23,21 +23,7 @@
epoch=pk.epoch(0),
central_body=earth,
)
"""
ActorBuilder.set_orbit(
sat1,
position=[10000000, 3000000, 0],
velocity=[0, 8000, 2000],
epoch=pk.epoch(0),
central_body=earth,
)
"""
ActorBuilder.set_geometric_model(sat1, mass=500)
print(sat1._moment_of_inertia)

ActorBuilder.set_geometric_model(sat2, mass=5000)
print(sat2._moment_of_inertia)


ActorBuilder.set_thermal_model(
sat1,
Expand All @@ -50,33 +36,25 @@
actor_emissive_area=18,
actor_thermal_capacity=0.89,
)
# following used to check if model is correct. Pure rotations around pointing vector should not move the pointing vector.
pure_axis_rotation = [[0.00158, 0.0, 0.0], [0.0, 0.00158, 0.0], [0.0, 0.0, 0.00158]]
axes_list = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
axis = 1 # x:0, y:1, z:2

# when i = 21 in loop, 0.00158 rad/sec will rotate 180 deg about 1 axis
ActorBuilder.set_attitude_model(
sat1,
#actor_initial_angular_velocity=pure_axis_rotation[1],
#actor_pointing_vector_body=axes_list[0],
actor_initial_angular_velocity=[0.0, 0.00158, 0.0],
actor_pointing_vector_body=[0.0, 0.0, 1.0],
actor_initial_attitude_in_rad=[0.0, 0.0, 0.0]
)
# disturbances:
ActorBuilder.set_disturbances(sat1,True, True)

sim = paseos.init_sim(sat1)
plt.close()
# Plot current status of PASEOS and get a plotter
#%%
# Run some operations and inbetween update PASEOS

pos = []
x = []
y = []
z = []
pointing_vector = []
ratio = 100/440


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
Expand All @@ -92,6 +70,7 @@
# pointing vector:
vector = sat1.pointing_vector()
vector[np.isclose(vector, np.zeros(3))] = 0
# scale for plotting
vector = vector * 2e6

# angular velocity vector:
Expand All @@ -102,14 +81,16 @@
else:
ang_vel = sat1.angular_velocity() / np.linalg.norm(sat1.angular_velocity())
ang_vel[np.isclose(ang_vel, np.zeros(3))] = 0

# scale for plotting
ang_vel = ang_vel * 2e6

# print(i, vector / 2e6, sat1.attitude_in_deg(), sat1.angular_velocity() / 2e6)

# plot vectors
ax.quiver(pos[0], pos[1], pos[2], ang_vel[0], ang_vel[1], ang_vel[2], color="m")
ax.quiver(pos[0], pos[1], pos[2], vector[0], vector[1], vector[2])

sim.advance_time(100, 0)

# 3D figure limits
axmin = min([min(x), min(y), min(z)])*1.1
axmax = max([max(x), max(y), max(z)])*1.1

Expand Down

0 comments on commit 0f68861

Please sign in to comment.