Skip to content

Commit 4421862

Browse files
manumerousJaeyoung-Lim
authored andcommitted
Moving angular acceleration differentiation to after resampling
1 parent 9a23d2e commit 4421862

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

Tools/parametric_model/configs/quadrotor_model.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
# general information
32
model_name: "Gazebo Standard Multirotor"
43
model_type: "Standard Multirotor"
@@ -84,15 +83,15 @@ dynamics_model_config:
8483
vertical_c_m_leaver_quad: !!python/tuple [0.0, 2.0]
8584
vertical_c_m_rolling: !!python/tuple [0.0, 2.0]
8685
vertical_rot_drag_lin: !!python/tuple [0.0, 2.0]
87-
vertical_rot_thrust_lin: !!python/tuple [-1.0, 0.0]
88-
vertical_rot_thrust_quad: !!python/tuple [0.0, 10.0]
86+
vertical_rot_thrust_lin: !!python/tuple [-5.0, 0.0]
87+
vertical_rot_thrust_quad: !!python/tuple [0.0, 50.0]
8988
estimate_forces: True
9089
estimate_moments: True
91-
resample_freq: 100.0
90+
resample_freq: 250.0
9291
estimate_angular_acceleration: True
9392
data:
9493
required_ulog_topics:
95-
# Use with simulator logs only, disable estimate_angular_acceleration when using
94+
#Use with simulator logs only, disable estimate_angular_acceleration when using
9695
# vehicle_angular_acceleration:
9796
# ulog_name:
9897
# - "timestamp"

Tools/parametric_model/src/tools/data_handler.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,42 @@ def compute_resampled_dataframe(self, ulog):
158158
curr_df.columns = topic_dict["dataframe_name"]
159159
topic_type_bar.next()
160160
if (topic_type == "vehicle_angular_velocity" and self.estimate_angular_acceleration):
161-
print(curr_df)
162-
ang_vel_np = curr_df[["ang_vel_x",
161+
ang_vel_mat = curr_df[["ang_vel_x",
163162
"ang_vel_y", "ang_vel_z"]].to_numpy()
164163
time_in_secods_np = (curr_df[["timestamp"]].to_numpy()/1000000)
165164
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)
165+
ang_acc_np = np.gradient(
166+
ang_vel_mat, time_in_secods_np, axis=0)
169167
topic_type_bar.next()
170168
curr_df[["ang_acc_b_x", "ang_acc_b_y",
171169
"ang_acc_b_z"]] = ang_acc_np
170+
172171
df_list.append(curr_df)
173172

174173
topic_type_bar.finish()
175-
print(df_list)
176174
resampled_df = resample_dataframe_list(
177175
df_list, fts, self.resample_freq)
176+
if (self.estimate_angular_acceleration):
177+
ang_vel_mat = resampled_df[["ang_vel_x",
178+
"ang_vel_y", "ang_vel_z"]].to_numpy()
179+
for i in range(3):
180+
ang_vel_mat[:, i] = np.convolve(
181+
ang_vel_mat[:, i], np.ones(33), mode='same') / 33
182+
183+
# Alternate forward differentiation version
184+
# ang_vel_mat_1 = np.roll(ang_vel_mat, -1, axis=0)
185+
# diff_angular_acc_mat = (
186+
# ang_vel_mat_1 - ang_vel_mat) * self.resample_freq
187+
# resampled_df[["ang_acc_b_x", "ang_acc_b_y",
188+
# "ang_acc_b_z"]] = diff_angular_acc_mat
189+
190+
time_in_secods_np = (
191+
resampled_df[["timestamp"]].to_numpy()/1000000)
192+
time_in_secods_np = time_in_secods_np.flatten()
193+
ang_acc_np = np.gradient(ang_vel_mat, time_in_secods_np, axis=0)
194+
topic_type_bar.next()
195+
resampled_df[["ang_acc_b_x", "ang_acc_b_y",
196+
"ang_acc_b_z"]] = ang_acc_np
178197
return resampled_df.dropna()
179198

180199
def visually_select_data(self, plot_config_dict=None):

Tools/parametric_model/src/tools/dataframe_tools.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from src.tools.quat_utils import slerp
4343

4444
# pre normalization thresholds
45-
PWM_THRESHOLD = 1500
45+
PWM_THRESHOLD = 1050
4646
ACTUATOR_CONTROLS_THRESHOLD = -0.2
4747

4848

@@ -63,7 +63,7 @@ def compute_flight_time(ulog, pwm_threshold=None, control_threshold=None):
6363
if "actuator_outputs" in topic_type_list:
6464
act_df = pandas_from_topic(ulog, ["actuator_outputs"])
6565
# choose first actuator data
66-
act_df_crp = act_df[act_df.iloc[:, 4] > pwm_threshold]
66+
act_df_crp = act_df[act_df.iloc[:, 2] > pwm_threshold]
6767

6868
# special case for aero mini tilt wing for asl
6969
elif "actuator_controls_0" in topic_type_list:
@@ -74,7 +74,6 @@ def compute_flight_time(ulog, pwm_threshold=None, control_threshold=None):
7474
else:
7575
print("could not select flight time due to missing actuator topic")
7676
exit(1)
77-
7877
# set start and end time of flight duration
7978
t_start = act_df_crp.iloc[1, 0]
8079
t_end = act_df_crp.iloc[(act_df_crp.shape[0]-1), 0]

0 commit comments

Comments
 (0)