Skip to content

Commit 99d2ea0

Browse files
manumerousJaeyoung-Lim
authored andcommitted
Compute angular accelerations using numerical differentiation
This PR implements the possibility to compute the angular accelerations from nummerically differentiating the angular velocities using second order accurate central differences. The computation of the angular acceleration is applied before the resampling and filtering on the raw data. This is needed for all flight logs since the angular acceleration topic is only present in logs from the sim.
1 parent 0774f9e commit 99d2ea0

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

Tools/parametric_model/configs/quadplane_model.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ dynamics_model_config:
104104
estimate_forces: True
105105
estimate_moments: True
106106
resample_freq: 100.0
107+
estimate_angular_acceleration: False
107108
data:
108109
required_ulog_topics:
109110
actuator_outputs:

Tools/parametric_model/configs/quadrotor_model.yaml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,21 @@ dynamics_model_config:
8989
estimate_forces: True
9090
estimate_moments: True
9191
resample_freq: 100.0
92+
estimate_angular_acceleration: True
9293
data:
9394
required_ulog_topics:
95+
# Use with simulator logs only, disable estimate_angular_acceleration when using
96+
# vehicle_angular_acceleration:
97+
# ulog_name:
98+
# - "timestamp"
99+
# - "xyz[0]"
100+
# - "xyz[1]"
101+
# - "xyz[2]"
102+
# dataframe_name:
103+
# - "timestamp"
104+
# - "ang_acc_b_x"
105+
# - "ang_acc_b_y"
106+
# - "ang_acc_b_z"
94107
actuator_outputs:
95108
ulog_name:
96109
- "timestamp"
@@ -151,14 +164,4 @@ dynamics_model_config:
151164
- "acc_b_x"
152165
- "acc_b_y"
153166
- "acc_b_z"
154-
vehicle_angular_acceleration:
155-
ulog_name:
156-
- "timestamp"
157-
- "xyz[0]"
158-
- "xyz[1]"
159-
- "xyz[2]"
160-
dataframe_name:
161-
- "timestamp"
162-
- "ang_acc_b_x"
163-
- "ang_acc_b_y"
164-
- "ang_acc_b_z"
167+

Tools/parametric_model/configs/standardplane_model.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ dynamics_model_config:
107107
estimate_forces: True
108108
estimate_moments: True
109109
resample_freq: 50.0
110+
estimate_angular_acceleration: False
110111
data:
111112
required_ulog_topics:
112113
actuator_outputs:

Tools/parametric_model/src/tools/data_handler.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def __init__(self, config_file):
7171
assert bool(config_dict), 'req_topics_dict can not be empty'
7272
self.config_dict = config_dict
7373
self.resample_freq = config_dict["resample_freq"]
74+
self.estimate_angular_acceleration = config_dict["estimate_angular_acceleration"]
7475
print("Resample frequency: ", self.resample_freq, "Hz")
7576
self.req_topics_dict = config_dict["data"]["required_ulog_topics"]
7677

@@ -155,9 +156,23 @@ def compute_resampled_dataframe(self, ulog):
155156
assert (len(topic_dict["dataframe_name"]) == len(topic_dict["ulog_name"])), (
156157
'could not rename topics of type', topic_type, "due to rename list not having an entry for every topic.")
157158
curr_df.columns = topic_dict["dataframe_name"]
158-
df_list.append(curr_df)
159159
topic_type_bar.next()
160+
if (topic_type == "vehicle_angular_velocity" and self.estimate_angular_acceleration):
161+
print(curr_df)
162+
ang_vel_np = curr_df[["ang_vel_x",
163+
"ang_vel_y", "ang_vel_z"]].to_numpy()
164+
time_in_secods_np = (curr_df[["timestamp"]].to_numpy()/1000000)
165+
time_in_secods_np = time_in_secods_np.flatten()
166+
print(ang_vel_np)
167+
ang_acc_np = np.gradient(ang_vel_np, time_in_secods_np, axis=0)
168+
print(ang_acc_np)
169+
topic_type_bar.next()
170+
curr_df[["ang_acc_b_x", "ang_acc_b_y",
171+
"ang_acc_b_z"]] = ang_acc_np
172+
df_list.append(curr_df)
173+
160174
topic_type_bar.finish()
175+
print(df_list)
161176
resampled_df = resample_dataframe_list(
162177
df_list, fts, self.resample_freq)
163178
return resampled_df.dropna()

0 commit comments

Comments
 (0)