Skip to content

Commit c5651e1

Browse files
Nicholas Lawrancemanumerous
authored andcommitted
Minor code refactor
- Remove unnecessary imports - Minor plot changes - Minor spelling
1 parent fce76ad commit c5651e1

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

Tools/parametric_model/configs/quadrotor_model.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
# general information
3-
model_name: "Gazebo Standart Multirotor"
3+
model_name: "Gazebo Standard Multirotor"
44
model_type: "Standard Multirotor"
55
model_class: "MultiRotorModel"
66

Tools/parametric_model/generate_parametric_model.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
"""
3333

3434
import os
35-
import sys
36-
import inspect
37-
from src.models import MultiRotorModel
38-
from src.models.model_config import ModelConfig
3935
import src.models as models
4036
from src.tools import DataHandler
4137
import argparse
@@ -55,13 +51,12 @@ def str2bool(v):
5551

5652

5753
def start_model_estimation(config, log_path, data_selection=False):
58-
data_selection_enabled = data_selection
59-
print("Visual Data selection enabled: ", data_selection_enabled)
54+
print("Visual Data selection enabled: ", data_selection)
6055

6156
data_handler = DataHandler(config)
6257
data_handler.loadLogs(log_path)
6358

64-
if data_selection_enabled:
59+
if data_selection:
6560
data_handler.visually_select_data()
6661
data_handler.visualize_data()
6762

Tools/parametric_model/src/models/dynamics_model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,23 +448,23 @@ def plot_scatter(ax, title, dataframe_x, dataframe_y, dataframe_z, color='blue')
448448
if (self.estimate_forces and self.estimate_moments):
449449
y_forces_pred = y_pred[0:self.y_forces.shape[0]]
450450
y_moments_pred = y_pred[self.y_forces.shape[0]:]
451-
model_plots.plot_force_predeictions(
451+
model_plots.plot_force_predictions(
452452
self.y_forces, y_forces_pred, self.data_df["timestamp"])
453-
model_plots.plot_moment_predeictions(
453+
model_plots.plot_moment_predictions(
454454
self.y_moments, y_moments_pred, self.data_df["timestamp"])
455455
model_plots.plot_airspeed_and_AoA(
456456
self.data_df[["V_air_body_x", "V_air_body_y", "V_air_body_z", "angle_of_attack"]], self.data_df["timestamp"])
457457

458458
elif (self.estimate_forces):
459459
y_forces_pred = y_pred
460-
model_plots.plot_force_predeictions(
460+
model_plots.plot_force_predictions(
461461
self.y_forces, y_forces_pred, self.data_df["timestamp"])
462462
model_plots.plot_airspeed_and_AoA(
463463
self.data_df[["V_air_body_x", "V_air_body_y", "V_air_body_z", "angle_of_attack"]], self.data_df["timestamp"])
464464

465465
elif (self.estimate_moments):
466466
y_moments_pred = y_pred
467-
model_plots.plot_moment_predeictions(
467+
model_plots.plot_moment_predictions(
468468
self.y_moments, y_moments_pred, self.data_df["timestamp"])
469469
model_plots.plot_airspeed_and_AoA(
470470
self.data_df[["V_air_body_x", "V_air_body_y", "V_air_body_z", "angle_of_attack"]], self.data_df["timestamp"])

Tools/parametric_model/src/models/model_plots/linear_model_plots.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ def plot_covariance_mat(X, coef_name_list):
1111
corrMatrix = df.corr()
1212
fig, ax = plt.subplots(1)
1313
ax = sns.heatmap(corrMatrix, annot=True)
14+
ax.set_title('Coefficient covariance')

Tools/parametric_model/src/models/model_plots/model_plots.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@
3434
import matplotlib.pyplot as plt
3535
import numpy as np
3636
import math
37+
plt.rcParams['mathtext.fontset']='cm'
3738

3839
"""The functions in this file can be used to plot data of any kind of model"""
3940

4041

41-
def plot_force_predeictions(stacked_force_vec, stacked_force_vec_pred, timestamp_array):
42+
def plot_force_predictions(stacked_force_vec, stacked_force_vec_pred, timestamp_array):
4243
"""
4344
Input:
4445
stacked_force_vec: numpy array of shape (3*n,1) containing stacked accelerations [a_x_1, a_y_1, a_z_1, a_x_2, ...]^T in body frame
@@ -62,15 +63,15 @@ def plot_force_predeictions(stacked_force_vec, stacked_force_vec_pred, timestamp
6263
ax3.plot(timestamp_array, acc_mat[:, 2], label='measurement')
6364
ax3.plot(timestamp_array, acc_mat_pred[:, 2], label='prediction')
6465

65-
ax1.set_ylabel('x')
66-
ax2.set_ylabel('y')
67-
ax3.set_ylabel('z')
66+
ax1.set_ylabel('$x$')
67+
ax2.set_ylabel('$y$')
68+
ax3.set_ylabel('$z$')
6869
ax3.set_xlabel('time [s]')
6970
plt.legend()
7071
return
7172

7273

73-
def plot_moment_predeictions(stacked_moment_vec, stacked_moment_vec_pred, timestamp_array):
74+
def plot_moment_predictions(stacked_moment_vec, stacked_moment_vec_pred, timestamp_array):
7475
"""
7576
Input:
7677
stacked_moment_vec: numpy array of shape (3*n,1) containing stacked angular accelerations [w_x_1, w_y_1, w_z_1, w_x_2, ...]^T in body frame
@@ -94,9 +95,9 @@ def plot_moment_predeictions(stacked_moment_vec, stacked_moment_vec_pred, timest
9495
ax3.plot(timestamp_array, acc_mat[:, 2], label='measurement')
9596
ax3.plot(timestamp_array, acc_mat_pred[:, 2], label='prediction')
9697

97-
ax1.set_ylabel('x')
98-
ax2.set_ylabel('y')
99-
ax3.set_ylabel('z')
98+
ax1.set_ylabel('$x$')
99+
ax2.set_ylabel('$y$')
100+
ax3.set_ylabel('$z$')
100101
ax3.set_xlabel('time [s]')
101102
plt.legend()
102103
return
@@ -119,10 +120,10 @@ def plot_airspeed_and_AoA(airspeed_mat, timestamp_array):
119120
ax2.plot(timestamp_array, airspeed_mat[:, 1], label='measurement')
120121
ax3.plot(timestamp_array, airspeed_mat[:, 2], label='measurement')
121122
ax4.plot(timestamp_array, airspeed_mat[:, 3], label='measurement')
122-
ax1.set_title('airspeed in x direction of body frame [m/s^2]')
123-
ax2.set_title('airspeed in y direction of body frame [m/s^2]')
124-
ax3.set_title('airspeed in z direction of body frame [m/s^2]')
125-
ax4.set_title("Aoa in body frame [radiants]")
123+
ax1.set_title(r'Airspeed in body-$x$ [m/s^2]')
124+
ax2.set_title(r'Airspeed in body-$y$ [m/s^2]')
125+
ax3.set_title(r'Airspeed in body-$z$ [m/s^2]')
126+
ax4.set_title("AoA in body frame [radians]")
126127
plt.legend()
127128
return
128129

0 commit comments

Comments
 (0)