Skip to content

Commit

Permalink
sim - vis - pdf: support multiple CFs
Browse files Browse the repository at this point in the history
The current implementation overrides the output pdf file for each UAV. This changes the implementation to write the data for all UAVs in one PDF.
  • Loading branch information
whoenig committed Jan 10, 2024
1 parent ec7344c commit 911293e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crazyflie_sim/crazyflie_sim/visualization/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ def step(self, t, states: list[State], states_desired: list[State], actions: lis
self.all_actions.append(copy.deepcopy(actions))

def shutdown(self):
with PdfPages(self.filename) as pdf:

for k, name in enumerate(self.names):
for k, name in enumerate(self.names):

cf_states = np.array([s[k]._state for s in self.all_states])
cf_states_desired = np.array([s[k]._state for s in self.all_states_desired])
cf_actions = np.array([s[k]._action for s in self.all_actions])

with PdfPages(self.filename) as pdf:
cf_states = np.array([s[k]._state for s in self.all_states])
cf_states_desired = np.array([s[k]._state for s in self.all_states_desired])
cf_actions = np.array([s[k]._action for s in self.all_actions])

# position
fig, axs = plt.subplots(3, 1, sharex=True)
fig.suptitle(name + " position")
axs[0].set_ylabel('px [m]')
axs[1].set_ylabel('py [m]')
axs[2].set_ylabel('pz [m]')
Expand All @@ -55,6 +55,7 @@ def shutdown(self):

# velocity
fig, axs = plt.subplots(3, 1, sharex=True)
fig.suptitle(name + " velocity")
axs[0].set_ylabel('vx [m/s]')
axs[1].set_ylabel('vy [m/s]')
axs[2].set_ylabel('vz [m/s]')
Expand All @@ -69,6 +70,7 @@ def shutdown(self):

# orientation
fig, axs = plt.subplots(3, 1, sharex=True)
fig.suptitle(name + " orientation")
axs[0].set_ylabel('roll [deg]')
axs[1].set_ylabel('pitch [deg]')
axs[2].set_ylabel('yaw [deg]')
Expand All @@ -87,6 +89,7 @@ def shutdown(self):

# omega
fig, axs = plt.subplots(3, 1, sharex=True)
fig.suptitle(name + " angular velocity")
axs[0].set_ylabel('wx [deg/s]')
axs[1].set_ylabel('wy [deg/s]')
axs[2].set_ylabel('wz [deg/s]')
Expand All @@ -101,6 +104,7 @@ def shutdown(self):

# actions
fig, axs = plt.subplots(2, 2, sharex=True, sharey=True)
fig.suptitle(name + " motor actions")
axs[0, 0].set_ylabel('rpm')
axs[1, 0].set_ylabel('rpm')
axs[1, 0].set_xlabel('Time [s]')
Expand Down

0 comments on commit 911293e

Please sign in to comment.