Skip to content

[WIP] Use new CA topics instead of actuator_controls/outputs #208

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 3 additions & 8 deletions Tools/parametric_model/configs/quadplane_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,14 @@ dynamics_model_config:
- "accelerometer_m_s2[0]"
- "accelerometer_m_s2[1]"
- "accelerometer_m_s2[2]"
- "gyro_rad[0]"
- "gyro_rad[1]"
- "gyro_rad[2]"
dataframe_name:
- "timestamp"
- "acc_b_x"
- "acc_b_y"
- "acc_b_z"
vehicle_angular_acceleration:
ulog_name:
- "timestamp"
- "xyz[0]"
- "xyz[1]"
- "xyz[2]"
dataframe_name:
- "timestamp"
- "ang_acc_b_x"
- "ang_acc_b_y"
- "ang_acc_b_z"
19 changes: 6 additions & 13 deletions Tools/parametric_model/configs/quadrotor_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,6 @@ dynamics_model_config:
estimate_angular_acceleration: True
data:
required_ulog_topics:
#Use with simulator logs only, disable estimate_angular_acceleration when using
# vehicle_angular_acceleration:
# ulog_name:
# - "timestamp"
# - "xyz[0]"
# - "xyz[1]"
# - "xyz[2]"
# dataframe_name:
# - "timestamp"
# - "ang_acc_b_x"
# - "ang_acc_b_y"
# - "ang_acc_b_z"
actuator_outputs:
id: 0
ulog_name:
Expand Down Expand Up @@ -159,9 +147,14 @@ dynamics_model_config:
- "accelerometer_m_s2[0]"
- "accelerometer_m_s2[1]"
- "accelerometer_m_s2[2]"
- "gyro_rad[0]"
- "gyro_rad[1]"
- "gyro_rad[2]"
dataframe_name:
- "timestamp"
- "acc_b_x"
- "acc_b_y"
- "acc_b_z"

- "ang_acc_b_x"
- "ang_acc_b_y"
- "ang_acc_b_z"
86 changes: 59 additions & 27 deletions Tools/parametric_model/configs/standardplane_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ model_config:
- rotor_4:
description: "puller rotor"
rotor_type: "RotorModel"
dataframe_name: "u4"
dataframe_name: "u_motor"
rotor_axis:
- 1
- 0
Expand All @@ -32,19 +32,19 @@ model_config:
wing_:
- control_surface_0:
description: "aileron_right"
dataframe_name: "u6"
dataframe_name: "u_aileron"

- control_surface_1:
description: "aileron_left"
dataframe_name: "u5"
dataframe_name: "u_aileron"

- control_surface_2:
description: "elevator"
dataframe_name: "u7"
dataframe_name: "u_elevator"

- control_surface_3:
description: "rudder"
dataframe_name: "u2"
dataframe_name: "u_rudder"

# - control_surface_4:
# description: "flaps"
Expand Down Expand Up @@ -110,31 +110,61 @@ dynamics_model_config:
estimate_angular_acceleration: False
data:
required_ulog_topics:
actuator_outputs:
vehicle_thrust_setpoint:
ulog_name:
- "timestamp"
- "output[2]" # Rudder
# - "output[3]" # Flaps
- "output[4]" # motor
- "output[5]" # left aileron
- "output[6]" # right aileron
- "output[7]" # elevator
- "xyz[0]" # thrust in x
dataframe_name:
- "timestamp"
- "u2"
# - "u3"
- "u4"
- "u5"
- "u6"
- "u7"
- "u_motor"
actuator_type:
- "timestamp"
- "control_surface"
# - "control_surface"
- "motor"
vehicle_torque_setpoint:
ulog_name:
- "timestamp"
- "xyz[0]" # torque in x
- "xyz[1]" # torque in y
- "xyz[2]" # torque in z
dataframe_name:
- "timestamp"
- "u_aileron"
- "u_elevator"
- "u_rudder"
actuator_type:
- "timestamp"
- "control_surface"
- "control_surface"
- "control_surface"
# actuator_motors:
# ulog_name:
# - "timestamp"
# - "control[0]"
# dataframe_name:
# - "timestamp"
# - "u_motor"
# actuator_type:
# - "timestamp"
# - "motor"
# actuator_servos:
# ulog_name:
# - "timestamp"
# - "control[0]"
# - "control[1]"
# - "control[2]"
# - "control[3]"
# dataframe_name:
# - "timestamp"
# - "u_aileron_left"
# - "u_aileron_right"
# - "u_elevator_new"
# - "u_rudder_new"
# actuator_type:
# - "timestamp"
# - "control_surface"
# - "control_surface"
# - "control_surface"
# - "control_surface"
vehicle_local_position:
ulog_name:
- "timestamp"
Expand Down Expand Up @@ -171,19 +201,21 @@ dynamics_model_config:
- "accelerometer_m_s2[0]"
- "accelerometer_m_s2[1]"
- "accelerometer_m_s2[2]"
- "gyro_rad[0]"
- "gyro_rad[1]"
- "gyro_rad[2]"
dataframe_name:
- "timestamp"
- "acc_b_x"
- "acc_b_y"
- "acc_b_z"
vehicle_angular_acceleration:
- "ang_acc_b_x"
- "ang_acc_b_y"
- "ang_acc_b_z"
vehicle_land_detected:
ulog_name:
- "timestamp"
- "xyz[0]"
- "xyz[1]"
- "xyz[2]"
- "landed"
dataframe_name:
- "timestamp"
- "ang_acc_b_x"
- "ang_acc_b_y"
- "ang_acc_b_z"
- "landed"
2 changes: 1 addition & 1 deletion Tools/parametric_model/src/models/dynamics_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, config_dict):

def prepare_regression_matrices(self):
if "V_air_body_x" not in self.data_df:
self.normalize_actuators()
# self.normalize_actuators()
self.compute_airspeed_from_groundspeed(["vx", "vy", "vz"])

# Rotor features
Expand Down
4 changes: 1 addition & 3 deletions Tools/parametric_model/src/tools/data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ def compute_resampled_dataframe(self, ulog):
else:
curr_df = pandas_from_topic(ulog, [topic_type])

if topic_type == "actuator_outputs":
fts = compute_flight_time(curr_df)
elif topic_type == "actuator_controls_0":
if topic_type == "vehicle_land_detected":
fts = compute_flight_time(curr_df)

curr_df = curr_df[topic_dict["ulog_name"]]
Expand Down
25 changes: 13 additions & 12 deletions Tools/parametric_model/src/tools/dataframe_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,23 @@
from src.tools.ulog_tools import pandas_from_topic
from src.tools.quat_utils import slerp

# pre normalization thresholds
PWM_THRESHOLD = 1000
ACTUATOR_CONTROLS_THRESHOLD = -0.2


def compute_flight_time(act_df, pwm_threshold=None, control_threshold=None):
"""This function computes the flight time by a simple thresholding of actuator outputs or control values.
This works usually well for logs from the simulator or mission flights. But in some cases the assumption of an actuator output staying higher than the trsehhold for the hole flight might not be valid."""
"""This function computes the flight time by:
Option 1: listen to vehicle_land_detected/landed
Option 2: user defined start/end time stamp (micro seconds)
"""

if pwm_threshold is None:
pwm_threshold = PWM_THRESHOLD
# # Option 1:
# print("act_df: ", act_df)
# act_df_crp = act_df[act_df.iloc[:, 4] < 1] # take part where landed is 0
# print("act_df_crp after selection: ", act_df_crp)

if control_threshold is None:
control_threshold = ACTUATOR_CONTROLS_THRESHOLD
act_df_crp = act_df[act_df.iloc[:, 2] > pwm_threshold]
act_df_crp = act_df[act_df.iloc[:, 4] > pwm_threshold]
# Option 2:
# print("act_df: ", act_df)
act_df_crp = act_df[act_df.iloc[:, 0] > 405000000]
act_df_crp = act_df_crp[act_df_crp.iloc[:, 0] < 430000000]
# print("act_df_crp after selection: ", act_df_crp)

t_start = act_df_crp.iloc[1, 0]
t_end = act_df_crp.iloc[(act_df_crp.shape[0]-1), 0]
Expand Down