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

sim - vis - pdf: support multiple CFs #397

Merged
merged 2 commits into from
Jan 11, 2024
Merged
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
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
Loading